Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问如何连接到本地socks服务 #20

Open
Ir1Ka opened this issue Sep 7, 2021 · 6 comments
Open

请问如何连接到本地socks服务 #20

Ir1Ka opened this issue Sep 7, 2021 · 6 comments
Labels
bug Something isn't working upstream Awaiting further action from upstream

Comments

@Ir1Ka
Copy link

Ir1Ka commented Sep 7, 2021

我使用$$-windows作为本地socks服务器。【Windows的通用应用的loopback限制已使用Enable AppContainer Loopback解除】。
maple版本:0.5.0/0.4.0
在maple中,配置.conf文件,配置如下:

[General]
# Log are for debug only
loglevel = error
# Do not remove tun-fd option
tun-fd = 233
dns-server = 223.5.5.5, 114.114.114.114

[Proxy]
Direct = direct
Reject = reject

Sock_local_1080 = sock, 127.0.0.1, 1080

[Proxy Group]
# fallback 等效于 failover
Fallback = fallback, Sock_local_1080, interval=600, timeout=5

# url-test 等效于 failover=false 的 failover
UrlTest = url-test, Sock_local_1080, interval=600, timeout=5

Failover = failover, Sock_local_1080, health-check=true, check-interval=600, fail-timeout=5, failover=true
Tryall = tryall, Sock_local_1080, delay-base=0
Random = random, Sock_local_1080

[Rule]
# 代理服务器
DOMAIN-SUFFIX, my.proxy.server.domain, Direct
# 执行文件目录当中必需有 `site.dat` 文件
EXTERNAL, site:category-ads-all, Reject

# Arbitrary file access is forbidden within an app container.
# Make sure `geosite.dat` exists in the config folder.
# 也可以指定 `dat` 文件所在路径
EXTERNAL, site:geosite.dat:category-ads-all, Reject

IP-CIDR, 8.8.8.8/32, Fallback
DOMAIN, www.google.com, Fallback
DOMAIN-SUFFIX, google.com, Fallback
DOMAIN-KEYWORD, google, Fallback

# 等效于 EXTERNAL, mmdb:cn, Direct
GEOIP, cn, Direct

EXTERNAL, site:geolocation-cn, Direct

FINAL, Fallback

[Host]
# 对指定域名返回一个或多个静态 IP
example.com = 192.168.0.1, 192.168.0.2

也使用过json,但是似乎也无法使用。.json配置文件如下:

{
    "log": {
      "level": "error"
    },
    "dns": {
      "servers": [
        "223.5.5.5",
        "8.8.8.8",
        "8.8.4.4"
      ],
      "hosts": {
        "localhost": [
          "127.0.0.1"
        ]
      }
    },
    "inbounds": [
      {
        "protocol": "tun",
        "settings": {
          "name": "utun8",
          "address": "10.10.0.2",
          "netmask": "255.255.255.0",
          "gateway": "10.10.0.1",
          "mtu": 1500,
          "fakeDnsInclude": [
            "google"
          ]
        },
        "tag": "tun_in"
      }
    ],
    "outbounds": [
      {
        "protocol": "failover",
        "settings": {
          "actors": [
            "my.proxy.server.domain:12345_out",
            "localhost:1080_out"
          ],
          "failTimeout": 4,
          "healthCheck": true,
          "checkInterval": 300,
          "failover": true,
          "fallbackCache": false,
          "cacheSize": 256,
          "cacheTimeout": 60
        },
        "tag": "failover_out"
      },
      {
        "protocol": "chain",
        "settings": {
          "actors": [
            "ss_tls",
            "ss_ws",
            "my.proxy.server.domain:12345"
          ]
        },
        "tag": "my.proxy.server.domain:123456_out"
      },
      {
        "protocol": "tls",
        "tag": "ss_tls"
      },
      {
        "protocol": "ws",
        "settings": {
          "path": "/"
        },
        "tag": "ss_ws"
      },
      {
        "protocol": "shadowsocks",
        "settings": {
          "address": "my.proxy.server.domain",
          "method": "aes-128-gcm",
          "password": "passwd",
          "port": 12345
        },
        "tag": "my.proxy.server.domain:12345"
      },
      {
        "protocol": "socks",
        "settings": {
          "address": "127.0.0.1",
          "port": 1080
        },
        "tag": "localhost:1080_out"
      },
      {
        "protocol": "direct",
        "tag": "direct_out"
      },
      {
        "protocol": "drop",
        "tag": "drop_out"
      }
    ],
    "rules": [
      {
        "ip": [
          "8.8.8.8",
          "8.8.4.4"
        ],
        "target": "failover_out"
      },
      {
        "domain": [
          "www.google.com"
        ],
        "target": "failover_out"
      },
      {
        "domainSuffix": [
          "my.proxy.server.domain"
        ],
        "target": "direct_out"
      },
      {
        "domainSuffix": [
          "google.com",
          "goo.gl",
          "goo.gle",
          "cloudflare.com"
        ],
        "target": "failover_out"
      },
      {
        "domainKeyword": [
          "metax"
        ],
        "target": "direct_out"
      },
      {
        "domainKeyword": [
          "google",
          "github"
        ],
        "target": "failover_out"
      },
      {
        "geoip": [
          "cn"
        ],
        "target": "direct_out"
      },
      {
        "geoip": [
          "us",
          "jp"
        ],
        "target": "failover_out"
      },
      {
        "external": [
          "site:cn"
        ],
        "target": "direct_out"
      },
      {
        "external": [
          "site:us",
          "site:jp"
        ],
        "target": "failover_out"
      },
      {
        "external": [
          "mmdb:cn"
        ],
        "target": "direct_out"
      },
      {
        "external": [
          "mmdb:us"
        ],
        "target": "failover_out"
      }
    ]
  }
@bdbai bdbai added the configuration All about Leaf Configuration label Sep 7, 2021
@bdbai
Copy link
Member

bdbai commented Sep 7, 2021

看一下设置里的接口设置对不对。以及 Shadowsocks 为什么不用内置的?

@Ir1Ka
Copy link
Author

Ir1Ka commented Sep 7, 2021

看一下设置里的接口设置对不对。以及 Shadowsocks 为什么不用内置的?

因为我用到了v2ray-plugin插件,似乎要用到这个插件,只能使用json配置文件,不过我使用json配置(上面有贴出来),也无法使用,网络接口设置我看了应该是没有问题。

@Ir1Ka
Copy link
Author

Ir1Ka commented Sep 7, 2021

请帮忙看一下我配置的 .json 文件有没有哪里配置错误,非常感谢。

@bdbai
Copy link
Member

bdbai commented Sep 7, 2021

可以先从这个最小的 conf 配置开始排查,看看能不能连接本地的 SOCKS5 服务。

[General]
loglevel = error
tun-fd = 233
dns-server = 223.5.5.5, 114.114.114.114

[Proxy]
Direct = direct
Reject = reject

# Shadowsocks
Sock_local_1080 = socks, 127.0.0.1, 1080

[Rule]
IP-CIDR, 224.0.0.0/8, Direct
IP-CIDR, 239.0.0.0/8, Direct
DOMAIN, my.proxy.server.domain, Direct
FINAL, Sock_local_1080

@Ir1Ka
Copy link
Author

Ir1Ka commented Sep 8, 2021

使用这个最小配置,也无法使用。看起来像是和socks的连接受阻。
我使用的shadowsocks-windows做的socks服务端,运行在本地。
测试时,shadowsocks-windows的图标上也没有流量上下行动画(一般有数据时会上下行标识)。

@bdbai
Copy link
Member

bdbai commented Sep 8, 2021

本地试了一下,这个配置可以连 Clash,但是连不了 shadowsocks-windows。原因是 Leaf 用的 SOCKS5 支持库发的请求比较离谱,碰巧 shadowsocks-windows 的 SOCKS5 服务也没有处理恰当。

以下是具体细节:
async-socks5 发出来的包是这样的:
image
原因是这个库真就一点一点写入的:
https://github.com/ark0f/async-socks5/blob/f2fb8730233165fc4ac61b985136920bd26cc633/src/lib.rs#L248-L251
然后 shadowsocks-windows 大概手搓的 SOCKS5 服务并没有正确处理拆分的请求。
虽然 Leaf 这边有人提过 fix:
eycorsican/leaf#177
但是我也不赞成直接套 BufStream,这会影响整个下行链路的行为。

已经给 shadowsocks-windows 提 issue 了: shadowsocks/shadowsocks-windows#3237

@bdbai bdbai added bug Something isn't working and removed configuration All about Leaf Configuration labels Nov 21, 2021
@bdbai bdbai added the upstream Awaiting further action from upstream label Nov 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working upstream Awaiting further action from upstream
Projects
None yet
Development

No branches or pull requests

2 participants