Mahdi-zarei / nekoray

Qt based cross-platform GUI proxy configuration manager (backend: sing-box)
GNU General Public License v3.0
250 stars 17 forks source link

关于路由的问题 #64

Open sjjiqtkgg opened 4 days ago

sjjiqtkgg commented 4 days ago

刚刚更新了最新版本4.0.8,路由设置了中国IP段的规则,中国有的网页还是走代理。有的直接打不开。在同一个代理节点的情况下我在github下载,4.0.8只有4.0.6的一半。4.0.8下载速度5-8M左右。而4.0.6下载速度15-21左右。所以我又退回用4.0.6。 希望在路由规则加强优化。感谢作者的付出

Mahdi-zarei commented 4 days ago

对中国流量绕行的路由规则如下:

[
  {
    "outbound": "dns-out",
    "protocol": "dns"
  },
  {
    "outbound": "direct",
    "rule_set": [
      "cn_IP",
      "geolocation-cn_SITE"
    ]
  },
  {
    "ip_is_private": true,
    "outbound": "direct"
  }
]

如果您对此有任何建议,我乐于听取。

Malus-risus commented 4 days ago

对中国流量绕行的路由规则如下:

[
  {
    "outbound": "dns-out",
    "protocol": "dns"
  },
  {
    "outbound": "direct",
    "rule_set": [
      "cn_IP",
      "geolocation-cn_SITE"
    ]
  },
  {
    "ip_is_private": true,
    "outbound": "direct"
  }
]

如果您对此有任何建议,我乐于听取。

试了一下手动设置,还是一样的问题

AreChen commented 1 day ago

遇到了同样的问题一样的绕行规则,不管是使用tun模式还是系统代理,比如打开百度,访问速度会变慢

Mahdi-zarei commented 1 day ago

可以尝试使用 sing-box 1.9.3 和您的配置一起运行,看看问题是否解决。 请报告问题是否已解决。

AreChen commented 7 hours ago

可以尝试使用 sing-box 1.9.3 和您的配置一起运行,看看问题是否解决。 请报告问题是否已解决。

通过sing-box 1.9.3执行以下命令 .\sing-box.exe run -c "C:\WERE\nekoraya\config\config.json" 虽然系统代理没工作,但是国内网络访问是正常的,秒开水平,是我哪里写错了吗? 以下是config.json内容(从软件导出的配置),关键内容已脱敏

{
    "dns": {
        "independent_cache": true,
        "rules": [
            {
                "domain": [
                    "www.xxxxx.com"
                ],
                "server": "dns-direct"
            }
        ],
        "servers": [
            {
                "address": "https://8.8.8.8/dns-query",
                "address_resolver": "dns-local",
                "detour": "proxy",
                "strategy": "ipv4_only",
                "tag": "dns-remote"
            },
            {
                "address": "local",
                "address_resolver": "dns-local",
                "detour": "direct",
                "strategy": "ipv4_only",
                "tag": "dns-direct"
            },
            {
                "address": "rcode://success",
                "tag": "dns-block"
            },
            {
                "address": "local",
                "detour": "direct",
                "tag": "dns-local"
            }
        ]
    },
    "inbounds": [
        {
            "domain_strategy": "ipv4_only",
            "listen": "127.0.0.1",
            "listen_port": 2082,
            "sniff": true,
            "sniff_override_destination": false,
            "tag": "mixed-in",
            "type": "mixed"
        }
    ],
    "log": {
        "level": "info"
    },
    "outbounds": [
        {
            "domain_strategy": "ipv4_only",
            "flow": "",
            "packet_encoding": "",
            "server": "www.xxxxx.com",
            "server_port": xxxxx,
            "tag": "proxy",
            "tls": {
                "enabled": true,
                "server_name": "www.xxxxx.com",
                "utls": {
                    "enabled": true,
                    "fingerprint": "chrome"
                }
            },
            "transport": {
                "headers": {
                    "Host": "www.xxxxx.com"
                },
                "path": "/xxxxx",
                "type": "ws"
            },
            "type": "vless",
            "uuid": "xxxxxxxxxxxxxxxxxxx"
        },
        {
            "tag": "direct",
            "type": "direct"
        },
        {
            "tag": "block",
            "type": "block"
        },
        {
            "tag": "dns-out",
            "type": "dns"
        }
    ],
    "route": {
        "auto_detect_interface": true,
        "final": "proxy",
        "rule_set": [
            {
                "format": "binary",
                "path": "C:/WERE/nekoraya/config/rule_sets/cn_IP.srs",
                "tag": "cn_IP",
                "type": "local"
            },
            {
                "format": "binary",
                "path": "C:/WERE/nekoraya/config/rule_sets/geolocation-cn_SITE.srs",
                "tag": "geolocation-cn_SITE",
                "type": "local"
            }
        ],
        "rules": [
            {
                "ip_version": 4,
                "outbound": "dns-out",
                "protocol": "dns"
            },
            {
                "ip_is_private": true,
                "ip_version": 4,
                "outbound": "direct"
            },
            {
                "ip_version": 4,
                "outbound": "direct",
                "rule_set": [
                    "cn_IP",
                    "geolocation-cn_SITE"
                ]
            }
        ]
    }
}
Mahdi-zarei commented 7 hours ago

国内网站打开速度快的原因正如您所说,系统代理未设置,因此流量完全绕过了 sing-box。为了找出根本原因,您需要使用代理模式运行 nekoray,并测试速度,查看是否存在变慢的情况。然后使用相同的配置和 sing-box 命令行,手动设置系统代理并再次测试速度,看看是否有任何差异。如果没有区别,则很可能是配置问题或 sing-box 1.9.3 版本问题。

另外我也注意到几个问题:

我们没有将中国域名设置为由本地 DNS 服务器解析,这可能会进一步增加延迟,因为 DNS 解析是在远程服务器上完成的,这会增加一些延迟。我还建议您使用 8.8.8.8 作为远程 DNS,前提是您的国外 VPS 在免费国家/地区。 仅使用 IPv4 有时可能会降低速度。我建议您使用本地 DNS 解析中国域名,或者在您的国外 VPS 中也设置仅限 IPv4。

AreChen commented 7 hours ago

国内网站打开速度快的原因正如您所说,系统代理未设置,因此流量完全绕过了 sing-box。为了找出根本原因,您需要使用代理模式运行 nekoray,并测试速度,查看是否存在变慢的情况。然后使用相同的配置和 sing-box 命令行,手动设置系统代理并再次测试速度,看看是否有任何差异。如果没有区别,则很可能是配置问题或 sing-box 1.9.3 版本问题。

另外我也注意到几个问题:

我们没有将中国域名设置为由本地 DNS 服务器解析,这可能会进一步增加延迟,因为 DNS 解析是在远程服务器上完成的,这会增加一些延迟。我还建议您使用 8.8.8.8 作为远程 DNS,前提是您的国外 VPS 在免费国家/地区。 仅使用 IPv4 有时可能会降低速度。我建议您使用本地 DNS 解析中国域名,或者在您的国外 VPS 中也设置仅限 IPv4。

应该不是singbox的问题,因为我是用nekoray原始项目的4.0beta1版本,是正常的(国内解析速度极快国内使用local进行解析)

AreChen commented 7 hours ago

原始nekoray导出的配置如下

{
    "dns": {
        "independent_cache": true,
        "rules": [
            {
                "domain": [
                    "www.xxxxxxxxxxxxxxxxxx.com"
                ],
                "domain_keyword": [],
                "domain_regex": [],
                "domain_suffix": [],
                "geosite": [
                    "cn"
                ],
                "server": "dns-direct"
            },
            {
                "query_type": [
                    32,
                    33
                ],
                "server": "dns-block"
            },
            {
                "domain_suffix": ".lan",
                "server": "dns-block"
            }
        ],
        "servers": [
            {
                "address": "https://8.8.8.8/dns-query",
                "address_resolver": "dns-local",
                "detour": "proxy",
                "strategy": "ipv4_only",
                "tag": "dns-remote"
            },
            {
                "address": "local",
                "address_resolver": "dns-local",
                "detour": "direct",
                "strategy": "ipv4_only",
                "tag": "dns-direct"
            },
            {
                "address": "rcode://success",
                "tag": "dns-block"
            },
            {
                "address": "local",
                "detour": "direct",
                "tag": "dns-local"
            }
        ]
    },
    "inbounds": [
        {
            "domain_strategy": "ipv4_only",
            "listen": "127.0.0.1",
            "listen_port": 2082,
            "sniff": true,
            "sniff_override_destination": false,
            "tag": "mixed-in",
            "type": "mixed"
        }
    ],
    "log": {
        "level": "info"
    },
    "outbounds": [
        {
            "domain_strategy": "ipv4_only",
            "flow": "",
            "packet_encoding": "",
            "server": "www.xxxxxxxxxxxxxxxxxx.com",
            "server_port": xxxxx,
            "tag": "proxy",
            "tls": {
                "enabled": true,
                "server_name": "www.xxxxxxxxxxxxxxxxxx.com",
                "utls": {
                    "enabled": true,
                    "fingerprint": "chrome"
                }
            },
            "transport": {
                "headers": {
                    "Host": "www.xxxxxxxxxxxxxxxxxx.com"
                },
                "path": "/xxxxxx",
                "type": "ws"
            },
            "type": "vless",
            "uuid": "xxxxxxxxxxxxxxxxx"
        },
        {
            "tag": "direct",
            "type": "direct"
        },
        {
            "tag": "bypass",
            "type": "direct"
        },
        {
            "tag": "block",
            "type": "block"
        },
        {
            "tag": "dns-out",
            "type": "dns"
        }
    ],
    "route": {
        "final": "proxy",
        "rules": [
            {
                "outbound": "dns-out",
                "protocol": "dns"
            },
            {
                "domain": [],
                "domain_keyword": [],
                "domain_regex": [],
                "domain_suffix": [
                    "appcenter.ms",
                    "firebase.io",
                    "crashlytics.com"
                ],
                "geosite": [
                    "category-ads-all"
                ],
                "outbound": "block"
            },
            {
                "domain": [],
                "domain_keyword": [],
                "domain_regex": [],
                "domain_suffix": [],
                "geosite": [
                    "cn"
                ],
                "outbound": "bypass"
            },
            {
                "geoip": [
                    "cn",
                    "private"
                ],
                "ip_cidr": [],
                "outbound": "bypass"
            },
            {
                "network": "udp",
                "outbound": "block",
                "port": [
                    135,
                    137,
                    138,
                    139,
                    5353
                ]
            },
            {
                "ip_cidr": [
                    "224.0.0.0/3",
                    "ff00::/8"
                ],
                "outbound": "block"
            },
            {
                "outbound": "block",
                "source_ip_cidr": [
                    "224.0.0.0/3",
                    "ff00::/8"
                ]
            }
        ]
    }
}
Mahdi-zarei commented 6 hours ago

好的,我理解了,现在一切都说通了。变慢问题很可能是由于 DNS 解析发生在远程服务器上造成的。我猜您是从原始仓库配置的 nekoray 直接路由了中国地理位置网站。在下个版本中,我将添加一个简单的选项,只需通过直接 DNS 发送中国或伊朗的 DNS 请求,这将解决变慢问题,为当前造成的不便深表歉意。

AreChen commented 6 hours ago

好的,我理解了,现在一切都说通了。变慢问题很可能是由于 DNS 解析发生在远程服务器上造成的。我猜您是从原始仓库配置的 nekoray 直接路由了中国地理位置网站。在下个版本中,我将添加一个简单的选项,只需通过直接 DNS 发送中国或伊朗的 DNS 请求,这将解决变慢问题,为当前造成的不便深表歉意。

很期待下个版本!非常感激您的工作!请不要说什么歉意! I'm really looking forward to the next version! I'm very grateful for your work! Please don't say anything apologetic!