falseen / PySocket

PySocket ,一个通过猴子补丁(monkey patch)动态修改 socket 的项目。在不修改源码的情况下给 socket 增加一些诸如限制客户端数量、前置代理之类的功能。让我们将 Monkey Patch 进行到底吧!
https://falseen.github.io/PySocket/
Apache License 2.0
107 stars 43 forks source link

一个客户端断开了以后,另一个客户端永远连不上 #4

Open WalkerWalker opened 7 years ago

WalkerWalker commented 7 years ago

成功实现了限制某个端口访问不能超过一个,撒花,么么哒! 但是我在电脑上断开连接以后,手机4G也迟迟连不上去,等了10分钟多了也连不上去。服务器上的日志一直是

Mar 19 09:46:39 ip-172-31-12-118.us-west-1.compute.internal python[826]: 2017-03-19 09:46:39 ERROR    [socket] the server_addrs *:8333 client more then the 1
Mar 19 09:47:14 ip-172-31-12-118.us-west-1.compute.internal python[826]: 2017-03-19 09:47:14 ERROR    [socket] the server_addrs *:8333 client more then the 1
Mar 19 09:47:26 ip-172-31-12-118.us-west-1.compute.internal python[826]: 2017-03-19 09:47:26 ERROR    [socket] the server_addrs *:8333 client more then the 1
Mar 19 09:48:15 ip-172-31-12-118.us-west-1.compute.internal python[826]: 2017-03-19 09:48:15 ERROR    [socket] the server_addrs *:8333 client more then the 1
Mar 19 09:48:40 ip-172-31-12-118.us-west-1.compute.internal python[826]: 2017-03-19 09:48:40 ERROR    [socket] the server_addrs *:8333 client more then the 1
Mar 19 09:49:18 ip-172-31-12-118.us-west-1.compute.internal python[826]: 2017-03-19 09:49:18 ERROR    [socket] the server_addrs *:8333 client more then the 1
Mar 19 09:49:34 ip-172-31-12-118.us-west-1.compute.internal python[826]: 2017-03-19 09:49:34 ERROR    [socket] the server_addrs *:8333 client more then the 1
Mar 19 09:50:59 ip-172-31-12-118.us-west-1.compute.internal python[826]: 2017-03-19 09:50:59 ERROR    [socket] the server_addrs *:8333 client more then the 1
Mar 19 09:51:17 ip-172-31-12-118.us-west-1.compute.internal python[826]: 2017-03-19 09:51:17 ERROR    [socket] the server_addrs *:8333 client more then the 1
Mar 19 09:52:06 ip-172-31-12-118.us-west-1.compute.internal python[826]: 2017-03-19 09:52:06 ERROR    [socket] the server_addrs *:8333 client more then the 1

我电脑用的客户端是 shadowsocksX-NG 手机用的是ssrconnect

对了,应该是 more than, 不是 more then

WalkerWalker commented 7 years ago

我把电脑客户端上又连去了另一台ss 服务器,再等了十分钟,手机那里还是上不去,完全没有释放的意思。所以我觉得应该不是客户端断开连接方式的问题。

WalkerWalker commented 7 years ago

我在ss 服务器上把进程重启了一下,手机重新连上去了。这时候电脑就上不去了(good),然后手机断开以后,电脑上还是连不上去。错误信息还是相同。(not good)

WalkerWalker commented 7 years ago

不知道我还有什么办法可以给出更多有用的日志吗?

falseen commented 7 years ago

debug模式可以看到更多的日志,你可以用 python sever.py -v 开启。我的补丁的日志都会以[socket]开头。

另外你说的断开连接是指关闭浏览器还是关闭ss?

WalkerWalker commented 7 years ago

不是关闭浏览器, 是断开ss连接,甚至还连了另一个ss server

falseen commented 7 years ago

你试试关闭浏览器或关闭ss。某些浏览器会一直保持长连接,或一直尝试连接(即使你没打开网页)。

falseen commented 7 years ago

@WalkerWalker 看了一下代码,我把所有的debug都注释掉了,所以你用debug模式也看不到更多的日志。

你再测一下吧,如果实在不行,就只能是调整规则,对指定时间无数据传输的连接进行强制关闭了。但我觉得这样可能会误伤,因为有长连接的存在。

WalkerWalker commented 7 years ago

....我刚想说,我怎么没看到更多的日志 下面日志可以看到,我的一个连接原本在看youtube,11:39分断开,然后几乎啥也没发生,11:45分用手机连,一直都连不上,

2017-03-19 11:39:47 INFO     connecting mtalk.google.com:5228 from 183.193.***.***:37074
2017-03-19 11:39:47 DEBUG    hit cache: mtalk.google.com
2017-03-19 11:39:48 DEBUG    destroy: yt3.ggpht.com:443
2017-03-19 11:39:48 DEBUG    destroying remote
2017-03-19 11:39:48 DEBUG    destroying local
2017-03-19 11:39:53 DEBUG    destroy: www.youtube.com:443
2017-03-19 11:39:53 DEBUG    destroying remote
2017-03-19 11:39:53 DEBUG    destroying local
2017-03-19 11:39:55 DEBUG    destroy: youtubei.youtube.com:443
2017-03-19 11:39:55 DEBUG    destroying remote
2017-03-19 11:39:55 DEBUG    destroying local
2017-03-19 11:39:55 DEBUG    destroy: clients4.google.com:443
2017-03-19 11:39:55 DEBUG    destroying remote
2017-03-19 11:39:55 DEBUG    destroying local
2017-03-19 11:39:55 DEBUG    destroy: s.youtube.com:443
2017-03-19 11:39:55 DEBUG    destroying remote
2017-03-19 11:39:55 DEBUG    destroying local
2017-03-19 11:39:55 DEBUG    destroy: i.ytimg.com:443
2017-03-19 11:39:55 DEBUG    destroying remote
2017-03-19 11:39:55 DEBUG    destroying local
2017-03-19 11:39:55 DEBUG    destroy: mtalk.google.com:5228
2017-03-19 11:39:55 DEBUG    destroying remote
2017-03-19 11:39:55 DEBUG    destroying local
2017-03-19 11:39:55 DEBUG    destroy: r9---sn-n4v7kn76.googlevideo.com:443
2017-03-19 11:39:55 DEBUG    destroying remote
2017-03-19 11:39:55 DEBUG    destroying local
2017-03-19 11:39:55 DEBUG    destroy: r9---sn-n4v7kn76.googlevideo.com:443
2017-03-19 11:39:55 DEBUG    destroying remote
2017-03-19 11:39:55 DEBUG    destroying local
2017-03-19 11:42:05 DEBUG    1 keys swept
2017-03-19 11:42:45 DEBUG    1 keys swept
2017-03-19 11:42:55 DEBUG    16 keys swept
2017-03-19 11:43:05 DEBUG    1 keys swept
2017-03-19 11:43:35 WARNING  timed out: r7---sn-o097znel.googlevideo.com:443
2017-03-19 11:43:35 DEBUG    already destroyed
2017-03-19 11:43:45 DEBUG    4 keys swept
2017-03-19 11:44:55 DEBUG    1 keys swept
2017-03-19 11:45:31 DEBUG    accept
2017-03-19 11:45:31 ERROR    [socket] the server_addrs *:8333 client more then the 1
2017-03-19 11:45:32 DEBUG    accept
2017-03-19 11:45:35 DEBUG    accept
2017-03-19 11:45:36 DEBUG    accept
2017-03-19 11:45:44 DEBUG    accept
2017-03-19 11:45:44 ERROR    [socket] the server_addrs *:8333 client more then the 1
2017-03-19 11:45:48 DEBUG    accept
2017-03-19 11:45:48 DEBUG    accept
2017-03-19 11:45:49 DEBUG    accept
2017-03-19 11:45:49 DEBUG    accept
2017-03-19 11:45:49 DEBUG    accept
2017-03-19 11:45:53 DEBUG    accept
2017-03-19 11:46:15 DEBUG    accept
2017-03-19 11:46:15 ERROR    [socket] the server_addrs *:8333 client more then the 1
2017-03-19 11:46:15 DEBUG    accept
2017-03-19 11:46:15 DEBUG    accept
2017-03-19 11:46:17 DEBUG    accept
2017-03-19 11:46:22 DEBUG    accept
2017-03-19 11:46:22 DEBUG    accept
2017-03-19 11:46:22 DEBUG    accept
2017-03-19 11:46:27 DEBUG    accept
2017-03-19 11:46:27 ERROR    [socket] the server_addrs *:8333 client more then the 1
2017-03-19 11:46:27 DEBUG    accept
2017-03-19 11:46:28 DEBUG    accept
2017-03-19 11:46:28 DEBUG    accept
2017-03-19 11:46:29 DEBUG    accept
WalkerWalker commented 7 years ago

嗯,时间小的话会误伤。时间大的话,每次切换设备都要等好久也是蛮蛋疼的。。。

不过为什么要关闭连接呢?

可不可以维护一个ip的集合,对指定时间无数据传输的连接,把那个ip从集合里挪出去。新的连接来了,再判断集合是不是满了,满了就拒绝,没满把ip加进集合。

falseen commented 7 years ago

那就奇怪了,我比较想知道的是你有没有关闭浏览器或ss?关闭ss应该是会直接断开连接的,从我的测试来看,只有手机版的ss会出现关闭ss之后连接仍然存在的问题。或者你可以试着把 set_close_timeout 改成 True ?

我更新了一下代码,把logging.debug显示出来了,你再看看有没有更多的日志。

falseen commented 7 years ago

如果不关闭连接的话那之前的设备仍然是可以上网的,只要那个连接存在。如果只是根据时间来判定的话可能会误伤一些长连接。

WalkerWalker commented 7 years ago

我又测试了一下

https://gist.github.com/WalkerWalker/f349e086e0219a244733d0f00c73e17b

这次的log信息量多很多了!你看看能不能有帮助

我看到有70个add,35个close,是不是add两次是不应该的?如果拒绝的时候,能在log里面打出目前占用的连接,就更明确了。

falseen commented 7 years ago

确实不应该出现两次同样地址和端口的add,一定是哪里出错了。

falseen commented 7 years ago

但奇怪的是我这里一切正常。你用了两个端口还是只用了一个端口 ?有没有开负载均衡 ?按理说不管你怎么配置都不影响的,但还是先了解一下情况再说吧。

falseen commented 7 years ago

这样,你先用其他客户端试一下,比如直接运行 local.py,先不要用shadowsocksX-NG。 我怀疑可能是shadowsocksX-NG 的连接跟别的客户端不一样。

另外我更新了一个 dev 分支,你试试看能不能解决你的问题 地址 :https://github.com/falseen/PySocket/tree/dev

git clone -b dev https://github.com/falseen/PySocket

WalkerWalker commented 7 years ago

我突然在想会不会是因为我用了锐速来加速?我以前知道是有个没节操的双倍发包的算法,来减少丢包率的,但我没用那个。锐速不知道是不是同样的底层算法

那个没节操的叫做net-speeder,是会双倍发包的。锐速查了一下,似乎不是多倍发包的,网上似乎说是说不是的都有,好尴尬。我等下回去了看看关掉锐速是不是就没这个问题了。不过锐速真的能提速好多好多好多,超大区别

我刚刚试了一下听了锐速,还是有两个add,没差别。

WalkerWalker commented 7 years ago

看来确实是客户端的关系。不过我用 shadowsocksX-NG 和手机上的 ssrconnect 都是如此,都有两个连续的一模一样的add,

运行哪个客户端好呢? local.py 是什么?

falseen commented 7 years ago

先试一下常规的客户端会不会出现两个add,比如windows或安卓的客户端。或者你电脑上有python的话也可以直接运行 python local.py,跟sever.py的用法基本一致。

falseen commented 7 years ago

或者你先试下dev版本

WalkerWalker commented 7 years ago

dev 可以用,一看你的commit 我就觉得有戏。只加一次ip,干净对了 log在这里 https://gist.github.com/WalkerWalker/1fc1aa4fdd630f4be62bab14ac493c78

我是先在电脑上开了youtube,socket 建立 (line 5) 然后关了浏览器,都不用断vpn,socket就被干掉了 (line 119) 然后手机连上去,开了youtube,socket 建立 (line 127) 关了youtube应用,socket 也断了 (line 183)

后面发生的事情有点莫名其妙,大概是我电脑的某个进程突然开始访问google了,蛮奇怪的。。。先不管了,我等下再测试一下手机一边放youtube,一遍从4G切换成wifi,会是什么情况。

falseen commented 7 years ago

但是这样可能会引起一些新的问题,还是要弄明白为什么会出现两次add。我比较想知道你用其他客户端会不会出现这个问题。如果不会的话,我看能不能找个苹果系统测试一下。因为我是用windows和安卓的,没用过苹果。

WalkerWalker commented 7 years ago

那个基本测试成功了,没啥大问题。我手边也没有 windows 和 android。。。。你说的 local.py 是什么文件?

falseen commented 7 years ago

跟server.py在同一个文件夹。dev 的代码是不完善的,还需要进一步处理。

WalkerWalker commented 7 years ago

啊,这方面我不太懂 运行了 local.py 然后呢?

[root@ip-172-31-12-118 shadowsocks]# python local.py -c /etc/shadowsocks.json 
INFO: loading config from /etc/shadowsocks.json
2017-03-19 18:18:39 INFO     loading libsodium from libsodium.so.13
2017-03-19 18:18:39 INFO     starting local at 127.0.0.1:1080
falseen commented 7 years ago

设置浏览器的代理为 127.0.0.1:1080,类型 socks5。

WalkerWalker commented 7 years ago

唔。。这对我来说有点太快了。我执行了下面几步

  1. 我是应该在我的aws ec2 上面是用老的socket.py (不会判断同一个ip只加一次),
  2. 跑同样的server
  3. 然后在mac上面,git clone下来shadowscoks项目,
  4. 然后在mac上面,配置和server一模一样的config.json,
  5. 运行local.py,参数是config.json
  6. 然后去另一个窗口运行下面的命令打开chrome
    open -a /Applications/Google\ Chrome.app --args --proxy-server="socks5://127.0.0.1:1080":host-resolver-rules="MAP * 0.0.0.0 , EXCLUDE localhost"
  7. 访问youtube

但这样下来,并咩有什么反应,我的mac没有连接到ss服务器上。。。也没有什么地方报什么奇怪的错误信息

falseen commented 7 years ago

不能跟config.json 一模一样的, local.py 的 config.json 的 server 选项要填你的服务器地址,其他的一样。

WalkerWalker commented 7 years ago

哦哦,那个当然是填了服务器的地址,还是没用

falseen commented 7 years ago

那就是你的代理没有设置成功,你直接在chrome里面设置代理吧。

WalkerWalker commented 7 years ago

成功了!!刚刚我都要睡着想下个周末再弄了 https://gist.github.com/WalkerWalker/7c53659e5a08f9f4334d412ff366ba78

还是有两个add...

falseen commented 7 years ago

那就真是怪事了。。。这不符合tcp/ip协议规范啊。。我先查一下,如果真的有这种情况的话我再修改下代码。

另外我想知道你的服务端是怎么配的,socket.py文件是直接放在shadowsocks目录中,没有放其他地方吧?

WalkerWalker commented 7 years ago

对,socket.py放在和server.py同一个地方,一个字没改过,连参数都还没来得及改。当年网络课没好好学,什么tcp/ip, tcp,udp都不懂。。。靠你了啊

[centos@ip-172-31-12-118 shadowsocks]$ ls -la
总用量 332
drwxr-xr-x. 3 root root  4096 3月  19 20:45 .
drwxr-xr-x. 7 root root  4096 3月  19 09:21 ..
-rw-r--r--. 1 root root 17640 3月  19 09:21 asyncdns.py
-rw-r--r--. 1 root root 14377 3月  19 09:31 asyncdns.pyc
-rw-r--r--. 1 root root  9598 3月  19 09:21 common.py
-rw-r--r--. 1 root root 11290 3月  19 09:31 common.pyc
drwxr-xr-x. 2 root root  4096 3月  19 09:31 crypto
-rw-r--r--. 1 root root  6640 3月  19 09:21 cryptor.py
-rw-r--r--. 1 root root  7297 3月  19 09:31 cryptor.pyc
-rw-r--r--. 1 root root  5602 3月  19 09:21 daemon.py
-rw-r--r--. 1 root root  5458 3月  19 09:31 daemon.pyc
-rw-r--r--. 1 root root  7268 3月  19 09:21 eventloop.py
-rw-r--r--. 1 root root  9704 3月  19 09:31 eventloop.pyc
-rw-r--r--. 1 root root   686 3月  19 09:21 __init__.py
-rw-r--r--. 1 root root   300 3月  19 09:31 __init__.pyc
-rwxr-xr-x. 1 root root  2132 3月  19 09:21 local.py
-rw-r--r--. 1 root root  4286 3月  19 09:21 lru_cache.py
-rw-r--r--. 1 root root  4171 3月  19 09:31 lru_cache.pyc
-rw-r--r--. 1 root root  9816 3月  19 09:21 manager.py
-rw-r--r--. 1 root root  9307 3月  19 09:31 manager.pyc
-rwxr-xr-x. 1 root root  4882 3月  19 09:21 server.py
-rw-r--r--. 1 root root 17052 3月  19 09:21 shell.py
-rw-r--r--. 1 root root 15940 3月  19 09:31 shell.pyc
-rw-r--r--. 1 root root  9903 3月  19 20:45 socket.py
-rw-r--r--. 1 root root  6816 3月  19 20:45 socket.pyc
-rw-r--r--. 1 root root 35105 3月  19 09:21 tcprelay.py
-rw-r--r--. 1 root root 23675 3月  19 09:31 tcprelay.pyc
-rwxr-xr-x. 1 root root  2645 3月  19 09:21 tunnel.py
-rw-r--r--. 1 root root 14212 3月  19 09:21 udprelay.py
-rw-r--r--. 1 root root  9659 3月  19 09:31 udprelay.pyc
falseen commented 7 years ago

啊,你放在这个目录了啊,我是想让你放shadowsocks根目录的,即有setup.py的目录。我当初测试的时候发现放shadowsocks/shadowsocks目录的话会出现一些意料之外的情况,我也不明白为什么会这样。但是放根目录就没问题。

WalkerWalker commented 7 years ago

哦对了,我下午的时候傻傻以为两句add会不会一个是tcp一个是udp ,我去改了下log的语句,后来发现两个都是tcp

不过你大概肯定是知道的。

WalkerWalker commented 7 years ago

。。。。这也能有差别?那我去换一下试试看

WalkerWalker commented 7 years ago

还真的。。。只有一个add了

2017-03-19 22:03:25 INFO     starting server at 172.31.12.118:8333
2017-03-19 22:03:25 DEBUG    using event model: epoll
2017-03-19 22:03:26 DEBUG    accept
2017-03-19 22:03:26 DEBUG    [socket] add 13.124.***.***:31976
2017-03-19 22:03:26 INFO     connecting chrome.google.com:443 from 13.124.***.***:31976
2017-03-19 22:03:26 DEBUG    resolving chrome.google.com with type 1 using server 172.31.0.2
2017-03-19 22:03:27 DEBUG    accept
2017-03-19 22:03:27 DEBUG    [socket] add 13.124.***.***:31977
2017-03-19 22:03:27 INFO     connecting live.github.com:443 from 13.124.***.***:31977
2017-03-19 22:03:27 DEBUG    resolving live.github.com with type 1 using server 172.31.0.2
2017-03-19 22:03:28 DEBUG    accept
2017-03-19 22:03:28 DEBUG    [socket] add 13.124.***.***:31978
2017-03-19 22:03:28 INFO     connecting live.github.com:443 from 13.124.***.***:31978
2017-03-19 22:03:28 DEBUG    hit cache: live.github.com
2017-03-19 22:03:29 DEBUG    destroy: live.github.com:443
2017-03-19 22:03:29 DEBUG    destroying remote
2017-03-19 22:03:29 DEBUG    destroying local
2017-03-19 22:03:29 DEBUG    [socket] close the client socket 13.124.***.***:31977
2017-03-19 22:03:30 DEBUG    accept
2017-03-19 22:03:30 DEBUG    [socket] add 13.124.***.***:31980
2017-03-19 22:03:30 INFO     connecting live.github.com:443 from 13.124.***.***:31980
2017-03-19 22:03:30 DEBUG    hit cache: live.github.com
2017-03-19 22:03:34 DEBUG    accept
2017-03-19 22:03:34 DEBUG    [socket] add 13.124.***.***:31981
2017-03-19 22:03:34 INFO     connecting live.github.com:443 from 13.124.***.***:31981
2017-03-19 22:03:34 DEBUG    hit cache: live.github.com
2017-03-19 22:03:38 DEBUG    accept
2017-03-19 22:03:38 DEBUG    [socket] add 13.124.***.***:31982
2017-03-19 22:03:38 INFO     connecting www.google.com:443 from 13.124.***.***:31982
2017-03-19 22:03:38 DEBUG    resolving www.google.com with type 1 using server 172.31.0.2
2017-03-19 22:03:38 DEBUG    accept
2017-03-19 22:03:38 DEBUG    [socket] add 13.124.***.***:31983
2017-03-19 22:03:38 INFO     connecting www.gstatic.com:443 from 13.124.***.***:31983
2017-03-19 22:03:38 DEBUG    resolving www.gstatic.com with type 1 using server 172.31.0.2
2017-03-19 22:03:38 DEBUG    accept
2017-03-19 22:03:38 DEBUG    [socket] add 13.124.***.***:31984
2017-03-19 22:03:38 INFO     connecting fonts.gstatic.com:443 from 13.124.***.***:31984
2017-03-19 22:03:38 DEBUG    resolving fonts.gstatic.com with type 1 using server 172.31.0.2
2017-03-19 22:03:38 DEBUG    accept
2017-03-19 22:03:38 DEBUG    [socket] add 13.124.***.***:31985
2017-03-19 22:03:38 INFO     connecting www.google.com:443 from 13.124.***.***:31985
2017-03-19 22:03:38 DEBUG    hit cache: www.google.com
2017-03-19 22:03:38 DEBUG    accept
2017-03-19 22:03:38 DEBUG    [socket] add 13.124.***.***:31986
2017-03-19 22:03:38 INFO     connecting www.google.com:443 from 13.124.***.***:31986
2017-03-19 22:03:38 DEBUG    hit cache: www.google.com
2017-03-19 22:03:39 DEBUG    accept
2017-03-19 22:03:39 DEBUG    [socket] add 13.124.***.***:31987
2017-03-19 22:03:39 INFO     connecting ip:80 from 13.124.***.***:31987
2017-03-19 22:03:39 DEBUG    resolving ip with type 1 using server 172.31.0.2
2017-03-19 22:03:39 DEBUG    resolving ip with type 28 using server 172.31.0.2
2017-03-19 22:03:39 ERROR    unknown hostname ip when handling connection from 13.124.***.***:31987
2017-03-19 22:03:39 DEBUG    destroy: ip:80
2017-03-19 22:03:39 DEBUG    destroying local
2017-03-19 22:03:39 DEBUG    [socket] close the client socket 13.124.***.***:31987
2017-03-19 22:03:43 DEBUG    accept
2017-03-19 22:03:43 DEBUG    [socket] add 13.124.***.***:31988
2017-03-19 22:03:43 INFO     connecting facebook.com:443 from 13.124.***.***:31988
2017-03-19 22:03:43 DEBUG    resolving facebook.com with type 1 using server 172.31.0.2
2017-03-19 22:03:43 DEBUG    accept
2017-03-19 22:03:43 DEBUG    [socket] add 13.124.***.***:31989
2017-03-19 22:03:43 INFO     connecting www.facebook.com:443 from 13.124.***.***:31989
2017-03-19 22:03:43 DEBUG    resolving www.facebook.com with type 1 using server 172.31.0.2
2017-03-19 22:03:45 DEBUG    accept
2017-03-19 22:03:45 DEBUG    [socket] add 13.124.***.***:31990
2017-03-19 22:03:45 INFO     connecting clients1.google.com:443 from 13.124.***.***:31990
2017-03-19 22:03:45 DEBUG    resolving clients1.google.com with type 1 using server 172.31.0.2
falseen commented 7 years ago

那就对了!回头有空的时候再慢慢查一下为什么不能放子目录。你先这样用着吧。自定义端口的功能等会添加。

WalkerWalker commented 7 years ago

嗯嗯好,辛苦你啦,陪着我瞎折腾!今天搞不动了,明天重新测一遍。。。

yehaihuakai commented 6 years ago

请教下,两位说的shadowsocks根目录,我这边并没有shadowsocks/shadowsocks两层嵌套的目录。有一个shadowsocks-3.0.0-py2.6.egg的目录,貌似就是二位说的根目录,但是目录下没有setup.py文件。

falseen commented 6 years ago

@yehaihuakai 你是用pip安装的。我们是直接下载的源码。

yehaihuakai commented 6 years ago

@falseen 好的,谢谢

ChacesXia commented 6 years ago

falseen, 非常感谢你的项目,我和该楼主遇到了同样的问题,一个windows和Android设备。我服务器限制了同时只能登陆一个客户端。现在的情况是,我先用Android手机登陆是成功的,同时在windows设备上登陆,确实达到了限制的效果。但是问题来了,然后我在Android的ss客户端中关闭连接,然后退出SS客户端之后,windows设备怎么都连不上。我查看了log之后发现你这个socket.py程序还是提示我“client more than 1”。 我应该如何修改设置或者代码,才能达到正常的效果,Can you fix it, Thanks.

gsum0417 commented 6 years ago

老哥,你在吗? 15年的版本,限制同一端口连接数没有问题,能够随意切换,不过没有黑白名单功能,所以我试了下17年的版本,问题来了。 用自家网络连接(无论用什么设备和端口),断开后用邻居家网络(或4G)都无法连接原来的端口,重启后还是出现同样的问题。我怀疑是断开的ip地址没有清理成功。请问怎么改代码。。。在线等老哥。。。