Template
Fix NaiveProxy share links to always include port 443.
v2rayN treated links without an explicit port as invalid/80 and failed TLS. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -232,9 +232,13 @@ class NaiveProxyManager:
|
||||
# Keep a non-shared bootstrap user so the proxy is never open
|
||||
auth_lines = [f' basic_auth bootstrap {_rand_token(24)}']
|
||||
auth_block = '\n'.join(auth_lines)
|
||||
# probe_resistance looks like a fake domain to browsers
|
||||
probe = (probe_path or _rand_token(12)).strip('/')
|
||||
if '.' not in probe:
|
||||
probe = f'{probe}.com'
|
||||
return f"""{{
|
||||
order forward_proxy before file_server
|
||||
admin off
|
||||
log {{
|
||||
exclude http.log.error
|
||||
}}
|
||||
@@ -242,16 +246,14 @@ class NaiveProxyManager:
|
||||
:443, {domain} {{
|
||||
tls {email}
|
||||
encode
|
||||
route {{
|
||||
forward_proxy {{
|
||||
forward_proxy {{
|
||||
{auth_block}
|
||||
hide_ip
|
||||
hide_via
|
||||
probe_resistance {probe}
|
||||
}}
|
||||
file_server {{
|
||||
root /var/www/html
|
||||
}}
|
||||
hide_ip
|
||||
hide_via
|
||||
probe_resistance {probe}
|
||||
}}
|
||||
file_server {{
|
||||
root /var/www/html
|
||||
}}
|
||||
}}
|
||||
"""
|
||||
@@ -398,13 +400,21 @@ CMD ["caddy", "run", "--config", "/etc/caddy/Caddyfile", "--adapter", "caddyfile
|
||||
self._start_container()
|
||||
|
||||
def _build_share_uri(self, domain, username, password, name, port=443):
|
||||
"""v2rayN / NekoRay / sing-box compatible share link.
|
||||
|
||||
Always include an explicit port — without `:443` v2rayN often treats
|
||||
the port as empty/80 and shows «Свойство Порт недопустимо» / SSL errors.
|
||||
"""
|
||||
# Keep credentials unescaped when alphanumeric (our generator); quote otherwise.
|
||||
user = quote(username or '', safe='')
|
||||
pw = quote(password or '', safe='')
|
||||
host = domain or ''
|
||||
host = (domain or '').strip().lower()
|
||||
port = int(port or 443)
|
||||
authority = f'{user}:{pw}@{host}' if port == 443 else f'{user}:{pw}@{host}:{port}'
|
||||
fragment = quote(name or 'naiveproxy', safe='')
|
||||
return f'naive+https://{authority}#{fragment}'
|
||||
if port < 1 or port > 65535:
|
||||
port = 443
|
||||
# Remark: ASCII-safe, no spaces that break some importers
|
||||
remark = re.sub(r'[^\w.\-]+', '-', (name or 'naiveproxy').strip())[:48] or 'naiveproxy'
|
||||
return f'naive+https://{user}:{pw}@{host}:{port}#{remark}'
|
||||
|
||||
# ===================== INSTALL / REMOVE =====================
|
||||
|
||||
|
||||
Reference in New Issue
Block a user