Compare commits

...

7 Commits

Author SHA1 Message Date
lamp f704098473 use host network mode 2023-08-15 19:19:47 -07:00
lamp d5ead66a07 rename env 2023-08-15 11:35:48 -07:00
lamp f8436927cf use env for caddy site 2023-08-15 11:34:02 -07:00
lamp 3b4ee632b1 why do I have log template but then don't log 2023-08-15 11:29:30 -07:00
lamp 6b868c2b63 Disable PC vrchat bypass 2023-08-15 11:26:52 -07:00
lamp 40bda207e1 skip streaming manifests 2023-08-01 00:35:51 -07:00
lamp ea8bf8fa1e porkbun dns 2023-07-31 21:34:04 -07:00
5 changed files with 33 additions and 25 deletions
+1
View File
@@ -1,3 +1,4 @@
.vscode
__pycache__
test.mp4
env
+8 -3
View File
@@ -13,9 +13,14 @@
}
}
:80 {
#nl.u2b.cx u2b.cx {
{$CADDY_SITE:":80"} {
log
tls {
dns porkbun {
api_key {env.PORKBUN_API_KEY}
api_secret_key {env.PORKBUN_API_SECRET}
}
}
handle_path /proxy/* {
@gv path_regexp gvurl ^\/([a-z0-9-]+\.googlevideo\.com)
handle @gv {
@@ -45,7 +50,7 @@ Disallow: /
@notget not method GET
respond @notget 403
reverse_proxy http://app:8080
reverse_proxy http://127.0.0.1:8080
}
}
}
+3 -1
View File
@@ -1,4 +1,6 @@
FROM caddy:2.6-builder AS builder
RUN xcaddy build --with github.com/caddyserver/transform-encoder
RUN xcaddy build \
--with github.com/caddyserver/transform-encoder \
--with github.com/caddy-dns/porkbun
FROM caddy:2.6
COPY --from=builder /usr/bin/caddy /usr/bin/caddy
+4 -4
View File
@@ -8,20 +8,20 @@ services:
- ./:/app/
working_dir: /app/
environment:
- ADDRESS=127.0.0.1
- PORT=8080
- PROXY=/proxy/
network_mode: host
command: python server.py
caddy:
build: caddy
restart: always
ports:
- "80:80"
- "443:443"
- "443:443/udp"
network_mode: host
volumes:
- ./caddy/Caddyfile:/etc/caddy/Caddyfile
- caddy_data:/data
- caddy_config:/config
env_file: env
volumes:
caddy_data:
caddy_config:
+16 -16
View File
@@ -26,10 +26,10 @@ class Handler(BaseHTTPRequestHandler):
def address_string(self):
return getattr(self, 'headers', {}).get('X-Forwarded-For', '').split(',')[0] or self.client_address[0]
def is_pc_vrchat(self):
ua = self.headers.get('User-Agent', '')
ae = self.headers.get('Accept-Encoding', '')
return ua.startswith("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/") and ua.endswith(" Safari/537.36") and ae == "identity"
#def is_pc_vrchat(self):
# ua = self.headers.get('User-Agent', '')
# ae = self.headers.get('Accept-Encoding', '')
# return ua.startswith("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/") and ua.endswith(" Safari/537.36") and ae == "identity"
def send_error(self, code, message=""):
body = bytes(message, "utf-8")
@@ -48,11 +48,11 @@ class Handler(BaseHTTPRequestHandler):
path = unquote(self.path)
match = re.match("\/(?:id\/|(?:https?:\/\/)?(?:(?:www\.|music\.|m\.)?youtube\.com\/(?:watch\?v=|shorts\/)|youtu\.be\/))([A-Za-z0-9_-]{11})", path)
if match:
if self.is_pc_vrchat():
self.send_response(302)
self.send_header("Location", "https://www.youtube.com/watch?v=" + match[1])
self.end_headers()
return
#if self.is_pc_vrchat():
# self.send_response(302)
# self.send_header("Location", "https://www.youtube.com/watch?v=" + match[1])
# self.end_headers()
# return
query = match[1]
else:
query = "ytsearch:" + path[1:]
@@ -70,7 +70,7 @@ class Handler(BaseHTTPRequestHandler):
'event': Event(),
'expire': datetime.now() + timedelta(hours=5)
}
with YoutubeDL() as ydl:
with YoutubeDL({'extractor_args': {'youtube': {'skip': ['dash', 'hls']}}}) as ydl:
info = ydl.extract_info(query, download=False)
selection = info
@@ -103,12 +103,12 @@ class Handler(BaseHTTPRequestHandler):
elif 'url' not in ctx:
ctx['event'].wait(60)
if self.is_pc_vrchat():
if ctx.get('id'):
self.send_response(302)
self.send_header("Location", "https://www.youtube.com/watch?v=" + ctx['id'])
self.end_headers()
return
#if self.is_pc_vrchat():
# if ctx.get('id'):
# self.send_response(302)
# self.send_header("Location", "https://www.youtube.com/watch?v=" + ctx['id'])
# self.end_headers()
# return
if not ctx.get('url'):
if 'exception' in ctx: