Compare commits
No commits in common. "879661a2acbfa5aba2ce2c9b438ca0e0eeb920c3" and "f9fab223e8205431e4c9ed7ffa75103646a51100" have entirely different histories.
879661a2ac
...
f9fab223e8
54
Caddyfile
54
Caddyfile
@ -1,36 +1,32 @@
|
|||||||
#edit for deployment
|
u2b.cx {
|
||||||
#u2b.cx {
|
import common
|
||||||
:80 {
|
route {
|
||||||
log
|
@www path / /favicon.ico
|
||||||
handle_path /proxy/* {
|
redir @www https://www.u2b.cx{uri} permanent
|
||||||
@gv path_regexp gvurl ^\/([a-z0-9-]+\.googlevideo\.com)
|
|
||||||
handle @gv {
|
|
||||||
uri strip_prefix /{re.gvurl.1}
|
|
||||||
reverse_proxy {
|
|
||||||
to {re.gvurl.1}:443
|
|
||||||
header_up Host {re.gvurl.1}
|
|
||||||
transport http {
|
|
||||||
tls
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
handle {
|
|
||||||
respond 400
|
|
||||||
}
|
|
||||||
}
|
|
||||||
handle {
|
|
||||||
route {
|
|
||||||
@www path / /favicon.ico
|
|
||||||
redir @www https://www.u2b.cx{uri} permanent
|
|
||||||
|
|
||||||
respond /robots.txt "User-agent: *
|
respond /robots.txt "User-agent: *
|
||||||
Disallow: /
|
Disallow: /
|
||||||
"
|
"
|
||||||
respond /.* 403
|
respond /.* 403
|
||||||
@notget not method GET
|
@notget not method GET
|
||||||
respond @notget 403
|
respond @notget 403
|
||||||
|
|
||||||
reverse_proxy http://app:8080
|
reverse_proxy http://127.29.151.200:52482
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
proxy.u2b.cx {
|
||||||
|
import common
|
||||||
|
@gv path_regexp gvurl ^\/([a-z0-9-]+\.googlevideo\.com)
|
||||||
|
handle @gv {
|
||||||
|
uri strip_prefix /{re.gvurl.1}
|
||||||
|
#uri strip_prefix {re.gvurl.0} doesn't work for some reason despite that value being equal to /{re.gvurl.1}
|
||||||
|
reverse_proxy {
|
||||||
|
to {re.gvurl.1}:443
|
||||||
|
header_up Host {re.gvurl.1}
|
||||||
|
transport http {
|
||||||
|
tls
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
FROM python:3.11
|
|
||||||
RUN useradd -r -m u2b
|
|
||||||
RUN apt update && apt install -y ffmpeg
|
|
||||||
RUN pip install --no-cache-dir python-ffmpeg yt-dlp
|
|
||||||
COPY . /app
|
|
||||||
WORKDIR /app
|
|
||||||
USER u2b
|
|
||||||
ENV PORT=8080
|
|
||||||
CMD ["python", "server.py"]
|
|
@ -1,22 +0,0 @@
|
|||||||
version: "3.8"
|
|
||||||
name: "u2bcx"
|
|
||||||
services:
|
|
||||||
app:
|
|
||||||
build: .
|
|
||||||
restart: always
|
|
||||||
environment:
|
|
||||||
- PROXY=/proxy/
|
|
||||||
caddy:
|
|
||||||
image: caddy:2.6
|
|
||||||
restart: always
|
|
||||||
ports:
|
|
||||||
- "80:80"
|
|
||||||
- "443:443"
|
|
||||||
- "443:443/udp"
|
|
||||||
volumes:
|
|
||||||
- ./Caddyfile:/etc/caddy/Caddyfile
|
|
||||||
- caddy_data:/data
|
|
||||||
- caddy_config:/config
|
|
||||||
volumes:
|
|
||||||
caddy_data:
|
|
||||||
caddy_config:
|
|
11
server.py
11
server.py
@ -3,9 +3,8 @@ from importlib.metadata import version
|
|||||||
print("yt-dlp version", version("yt_dlp"))
|
print("yt-dlp version", version("yt_dlp"))
|
||||||
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
||||||
from urllib.parse import unquote, urlparse, parse_qs
|
from urllib.parse import unquote, urlparse, parse_qs
|
||||||
from threading import Event, Thread
|
from threading import Event
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from time import sleep
|
|
||||||
from os import environ
|
from os import environ
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
@ -23,14 +22,6 @@ def get_expire(url):
|
|||||||
ctx_cache = {}
|
ctx_cache = {}
|
||||||
ips_running_ytdl = []
|
ips_running_ytdl = []
|
||||||
|
|
||||||
def cache_prune_loop():
|
|
||||||
while True:
|
|
||||||
sleep(3600)
|
|
||||||
for query, ctx in ctx_cache:
|
|
||||||
if datetime.now() >= ctx['expire']:
|
|
||||||
del ctx[query]
|
|
||||||
Thread(target=cache_prune_loop).start()
|
|
||||||
|
|
||||||
class Handler(BaseHTTPRequestHandler):
|
class Handler(BaseHTTPRequestHandler):
|
||||||
def address_string(self):
|
def address_string(self):
|
||||||
return getattr(self, 'headers', {}).get('X-Forwarded-For', '').split(',')[0] or self.client_address[0]
|
return getattr(self, 'headers', {}).get('X-Forwarded-For', '').split(',')[0] or self.client_address[0]
|
||||||
|
Loading…
Reference in New Issue
Block a user