Compare commits

..

No commits in common. "879661a2acbfa5aba2ce2c9b438ca0e0eeb920c3" and "f9fab223e8205431e4c9ed7ffa75103646a51100" have entirely different histories.

4 changed files with 28 additions and 72 deletions

View File

@ -1,24 +1,5 @@
#edit for deployment
#u2b.cx {
:80 {
log
handle_path /proxy/* {
@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 {
u2b.cx {
import common
route {
@www path / /favicon.ico
redir @www https://www.u2b.cx{uri} permanent
@ -30,7 +11,22 @@ Disallow: /
@notget not method GET
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
}
}
}
}

View File

@ -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"]

View File

@ -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:

View File

@ -3,9 +3,8 @@ from importlib.metadata import version
print("yt-dlp version", version("yt_dlp"))
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
from urllib.parse import unquote, urlparse, parse_qs
from threading import Event, Thread
from threading import Event
from datetime import datetime, timedelta
from time import sleep
from os import environ
import logging
import re
@ -23,14 +22,6 @@ def get_expire(url):
ctx_cache = {}
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):
def address_string(self):
return getattr(self, 'headers', {}).get('X-Forwarded-For', '').split(',')[0] or self.client_address[0]