feat: Добавлен веб-сервер на Python для управления VPN-прокси, Dockerfile для sing-box и обновлен README.
This commit is contained in:
@@ -139,18 +139,27 @@ def parse_vless_url(url: str) -> dict:
|
||||
def generate_vless_config(vless_params: dict) -> dict:
|
||||
"""Generate sing-box configuration from VLESS parameters"""
|
||||
config = {
|
||||
"dns": {
|
||||
"independent_cache": True
|
||||
},
|
||||
"log": {
|
||||
"level": "info",
|
||||
"level": "debug",
|
||||
"disabled": True,
|
||||
"timestamp": True
|
||||
},
|
||||
"route": {
|
||||
"final": vless_params['tag'],
|
||||
"auto_detect_interface": True
|
||||
},
|
||||
"inbounds": [
|
||||
{
|
||||
"type": "mixed",
|
||||
"tag": "mixed-in",
|
||||
"type": "mixed",
|
||||
"sniff": True,
|
||||
"users": [],
|
||||
"listen": "0.0.0.0",
|
||||
"listen_port": 8082,
|
||||
"sniff": True,
|
||||
"sniff_override_destination": True
|
||||
"set_system_proxy": False
|
||||
}
|
||||
],
|
||||
"outbounds": [
|
||||
@@ -159,36 +168,27 @@ def generate_vless_config(vless_params: dict) -> dict:
|
||||
"tag": vless_params['tag'],
|
||||
"server": vless_params['server'],
|
||||
"server_port": vless_params['server_port'],
|
||||
"uuid": vless_params['uuid'],
|
||||
"flow": vless_params['flow'],
|
||||
"tls": {
|
||||
"enabled": True,
|
||||
"server_name": vless_params['server_name'],
|
||||
"utls": {
|
||||
"enabled": True,
|
||||
"fingerprint": vless_params['fingerprint']
|
||||
},
|
||||
"reality": {
|
||||
"enabled": True,
|
||||
"public_key": vless_params['public_key'],
|
||||
"short_id": vless_params['short_id']
|
||||
},
|
||||
"utls": {
|
||||
"enabled": True,
|
||||
"fingerprint": vless_params['fingerprint']
|
||||
}
|
||||
},
|
||||
"packet_encoding": "xudp"
|
||||
"uuid": vless_params['uuid']
|
||||
},
|
||||
{
|
||||
"type": "direct",
|
||||
"tag": "direct"
|
||||
},
|
||||
{
|
||||
"type": "block",
|
||||
"tag": "block"
|
||||
"tag": "direct",
|
||||
"type": "direct"
|
||||
}
|
||||
],
|
||||
"route": {
|
||||
"final": vless_params['tag'],
|
||||
"auto_detect_interface": True
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
return config
|
||||
@@ -447,10 +447,35 @@ class ProxyControlHandler(http.server.BaseHTTPRequestHandler):
|
||||
# Add selected server as main outbound
|
||||
new_outbounds.insert(0, selected_outbound)
|
||||
|
||||
# Update route rules to use selected server
|
||||
routes = config.get("route", {})
|
||||
final_outbound = selected_tag
|
||||
routes["final"] = final_outbound
|
||||
# Update route - remove incompatible fields and set only final
|
||||
# Some subscription configs have route.rules with "action" field which is not supported
|
||||
routes = {
|
||||
"final": selected_tag,
|
||||
"auto_detect_interface": True
|
||||
}
|
||||
|
||||
# Simplify DNS configuration to match client.json format
|
||||
config["dns"] = {
|
||||
"independent_cache": True
|
||||
}
|
||||
|
||||
# Remove platform-specific and experimental fields from root config
|
||||
config.pop("platform", None)
|
||||
config.pop("experimental", None)
|
||||
|
||||
# Replace TUN inbounds with mixed proxy (TUN requires privileges in Docker)
|
||||
# Use mixed proxy on 127.0.0.1:2412 instead
|
||||
config["inbounds"] = [
|
||||
{
|
||||
"tag": "mixed-in",
|
||||
"type": "mixed",
|
||||
"sniff": True,
|
||||
"users": [],
|
||||
"listen": "0.0.0.0",
|
||||
"listen_port": 8082,
|
||||
"set_system_proxy": False
|
||||
}
|
||||
]
|
||||
|
||||
config["outbounds"] = new_outbounds
|
||||
config["route"] = routes
|
||||
|
||||
Reference in New Issue
Block a user