From ef690349fd4c9dd845cf3e92e7c8d1055c24eb57 Mon Sep 17 00:00:00 2001 From: mercury Date: Sun, 22 Dec 2024 14:33:00 +0400 Subject: [PATCH] fix change transport xray --- app/bot.php | 16 ++--- config/nginx_default.conf | 122 ++++++++++++++++++-------------------- config/sing.json | 4 ++ 3 files changed, 71 insertions(+), 71 deletions(-) diff --git a/app/bot.php b/app/bot.php index c571f2b..325415e 100644 --- a/app/bot.php +++ b/app/bot.php @@ -5959,7 +5959,7 @@ DNS-over-HTTPS with IP: "network" => "ws", "security" => "tls", "wsSettings" => [ - "path" => "/ws?ed=2560" + "path" => "/ws$hash?ed=2560" ], "tlsSettings" => [ "allowInsecure" => false, @@ -5994,7 +5994,7 @@ DNS-over-HTTPS with IP: unset($c['outbounds'][$index]['flow']); $c['outbounds'][$index]["transport"] = [ "type" => "ws", - "path" => "/ws" + "path" => "/ws$hash" ]; $c['outbounds'][$index]['tls']['server_name'] = '~domain~'; } else { @@ -6012,7 +6012,7 @@ DNS-over-HTTPS with IP: unset($c['proxies'][$index]['flow']); unset($c['proxies'][$index]['reality-opts']); $c['proxies'][$index]["network"] = "ws"; - $c['proxies'][$index]["ws-opts"]['path'] = '/ws'; + $c['proxies'][$index]["ws-opts"]['path'] = "/ws$hash"; $c['proxies'][$index]["skip-cert-verify"] = false; $c['proxies'][$index]['servername'] = '~domain~'; } else { @@ -6348,11 +6348,11 @@ DNS-over-HTTPS with IP: $template = file_get_contents('/config/nginx_default.conf'); $template = preg_replace('~server_name ip~', "server_name {$this->ip}", $template); $template = preg_replace('~server_name domain~', "server_name " . ($conf['domain'] ? " *.{$conf['domain']} {$conf['domain']}" : '_'), $template); - if (!empty($conf['letsencrypt'])) { + if ($conf['domain'] && $conf['letsencrypt']) { $template = preg_replace('/#~([^\n]+)?/', "#~{$conf['letsencrypt']}", $template); - preg_match_all('~#-ssl.+?#-ssl~s', $template, $m); + preg_match_all('~#-domain.+?#-domain~s', $template, $m); foreach ($m[0] as $v) { - $template = preg_replace('~#-ssl.+?#-ssl~s', $this->uncomment($v, 'ssl'), $template, 1); + $template = preg_replace('~#-domain.+?#-domain~s', $this->uncomment($v, 'domain'), $template, 1); } } $h = $this->getHashBot(); @@ -7096,7 +7096,9 @@ DNS-over-HTTPS with IP: $p = $this->getPacConf(); $x = $this->getXray(); $h = $this->getHashBot(); - $p['transport'] = $ws ? 'Websocket' : 'Reality'; + $p['reality']['domain'] = $p['reality']['domain'] ?: 'web.telegram.org'; + $p['reality']['destination'] = $p['reality']['destination'] ?: $p['reality']['domain'] . ':443'; + $p['transport'] = $ws ? 'Websocket' : 'Reality'; if (!empty($ws)) { $p['reality']['domain'] = $x['inbounds'][0]['streamSettings']['realitySettings']['serverNames'][0] ?: $p['reality']['domain']; $p['reality']['destination'] = $x['inbounds'][0]['streamSettings']['realitySettings']['dest'] ?: $p['reality']['destination']; diff --git a/config/nginx_default.conf b/config/nginx_default.conf index af78992..2f8cb4d 100644 --- a/config/nginx_default.conf +++ b/config/nginx_default.conf @@ -35,8 +35,6 @@ http { } } - #~ - server { server_name ip; listen 10.10.0.2:443 ssl http2 proxy_protocol; @@ -103,74 +101,70 @@ http { proxy_pass https://ad/dns-query; } } - server { - server_name domain; - listen 10.10.0.2:443 ssl http2 proxy_protocol; - listen 10.10.1.2:443 ssl http2; - #-ssl - # ssl_certificate /certs/cert_public; - # ssl_certificate_key /certs/cert_private; - #-ssl - ssl_certificate /certs/self_public; - ssl_certificate_key /certs/self_private; - access_log /logs/nginx_domain_access; + #~ - location / { - root /app; - index override.html login.html; - try_files $uri $uri/ =404; - } + #-domain + # server { + # server_name domain; + # listen 10.10.0.2:443 ssl http2 proxy_protocol; + # listen 10.10.1.2:443 ssl http2; + # ssl_certificate /certs/cert_public; + # ssl_certificate_key /certs/cert_private; - location /tlgrm { - access_log /logs/nginx_tlgrm_access; - proxy_pass http://php; - } + # access_log /logs/nginx_domain_access; - location @php { - proxy_pass http://php; - } + # location / { + # root /app; + # index override.html login.html; + # try_files $uri $uri/ =404; + # } - location /adguard/ { - } + # location @php { + # proxy_pass http://php; + # } - location /webapp { - access_log /logs/nginx_webapp_access; - alias /app; - index index.html; - try_files $uri $uri/ @php; - } + # location /adguard/ { + # } - location /pac { - access_log /logs/nginx_pac_access; - proxy_set_header Host $http_host; - proxy_pass http://php; - } + # location /webapp { + # access_log /logs/nginx_webapp_access; + # alias /app; + # index index.html; + # try_files $uri $uri/ @php; + # } - location /ws { - proxy_pass http://xr:443; - proxy_redirect off; - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "upgrade"; - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_read_timeout 5d; - } - # The DoH server block - location /dns-query { - access_log /logs/nginx_doh_access; - proxy_http_version 1.1; - proxy_set_header Connection ""; - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-Proto https; - proxy_set_header X-Forwarded-For $remote_addr; - proxy_set_header X-Forwarded-Host $remote_addr; - proxy_cache doh_cache; - proxy_cache_key $scheme$proxy_host$uri$is_args$args$request_body; - proxy_pass https://ad/dns-query; - } - } + # location /pac { + # access_log /logs/nginx_pac_access; + # proxy_set_header Host $http_host; + # proxy_pass http://php; + # } + + # location /ws { + # proxy_pass http://xr:443; + # proxy_redirect off; + # proxy_http_version 1.1; + # proxy_set_header Upgrade $http_upgrade; + # proxy_set_header Connection "upgrade"; + # proxy_set_header Host $host; + # proxy_set_header X-Real-IP $remote_addr; + # proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + # proxy_read_timeout 5d; + # } + # # The DoH server block + # location /dns-query { + # access_log /logs/nginx_doh_access; + # proxy_http_version 1.1; + # proxy_set_header Connection ""; + # proxy_set_header Host $host; + # proxy_set_header X-Real-IP $remote_addr; + # proxy_set_header X-Forwarded-Proto https; + # proxy_set_header X-Forwarded-For $remote_addr; + # proxy_set_header X-Forwarded-Host $remote_addr; + # proxy_cache doh_cache; + # proxy_cache_key $scheme$proxy_host$uri$is_args$args$request_body; + # proxy_pass https://ad/dns-query; + # } + # } + #-domain } diff --git a/config/sing.json b/config/sing.json index ebc80fe..6c10501 100644 --- a/config/sing.json +++ b/config/sing.json @@ -110,6 +110,10 @@ "protocol": "dns", "outbound": "dns-out" }, + { + "addruleset": true, + "outbound": "direct" + }, { "addruleset": true, "createruleset": [