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
|
# Keep a non-shared bootstrap user so the proxy is never open
|
||||||
auth_lines = [f' basic_auth bootstrap {_rand_token(24)}']
|
auth_lines = [f' basic_auth bootstrap {_rand_token(24)}']
|
||||||
auth_block = '\n'.join(auth_lines)
|
auth_block = '\n'.join(auth_lines)
|
||||||
|
# probe_resistance looks like a fake domain to browsers
|
||||||
probe = (probe_path or _rand_token(12)).strip('/')
|
probe = (probe_path or _rand_token(12)).strip('/')
|
||||||
|
if '.' not in probe:
|
||||||
|
probe = f'{probe}.com'
|
||||||
return f"""{{
|
return f"""{{
|
||||||
order forward_proxy before file_server
|
order forward_proxy before file_server
|
||||||
|
admin off
|
||||||
log {{
|
log {{
|
||||||
exclude http.log.error
|
exclude http.log.error
|
||||||
}}
|
}}
|
||||||
@@ -242,7 +246,6 @@ class NaiveProxyManager:
|
|||||||
:443, {domain} {{
|
:443, {domain} {{
|
||||||
tls {email}
|
tls {email}
|
||||||
encode
|
encode
|
||||||
route {{
|
|
||||||
forward_proxy {{
|
forward_proxy {{
|
||||||
{auth_block}
|
{auth_block}
|
||||||
hide_ip
|
hide_ip
|
||||||
@@ -252,7 +255,6 @@ class NaiveProxyManager:
|
|||||||
file_server {{
|
file_server {{
|
||||||
root /var/www/html
|
root /var/www/html
|
||||||
}}
|
}}
|
||||||
}}
|
|
||||||
}}
|
}}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -398,13 +400,21 @@ CMD ["caddy", "run", "--config", "/etc/caddy/Caddyfile", "--adapter", "caddyfile
|
|||||||
self._start_container()
|
self._start_container()
|
||||||
|
|
||||||
def _build_share_uri(self, domain, username, password, name, port=443):
|
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='')
|
user = quote(username or '', safe='')
|
||||||
pw = quote(password or '', safe='')
|
pw = quote(password or '', safe='')
|
||||||
host = domain or ''
|
host = (domain or '').strip().lower()
|
||||||
port = int(port or 443)
|
port = int(port or 443)
|
||||||
authority = f'{user}:{pw}@{host}' if port == 443 else f'{user}:{pw}@{host}:{port}'
|
if port < 1 or port > 65535:
|
||||||
fragment = quote(name or 'naiveproxy', safe='')
|
port = 443
|
||||||
return f'naive+https://{authority}#{fragment}'
|
# 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 =====================
|
# ===================== INSTALL / REMOVE =====================
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user