shadowsocks / ShadowsocksX-NG

Next Generation of ShadowsocksX
GNU General Public License v3.0
32.4k stars 7.94k forks source link

Kcptun ipv6 address not config correctly, need add a crochet[] #544

Closed LiJinyao closed 7 years ago

LiJinyao commented 7 years ago

System and Shadowsocksx-NG version:

Expected behavior: using correct config to connect kcptun via ipv6

Actual behavior:

ipv6 address format lost a [], need to add [] when using ipv6 address.

currently, remoteaddr was configured by add IP address directly to kcptun config, thats works fine when using ipv4, but doesn't work in ipv6, because kcptun require add [], like [2001:19f0:7001:15ac:5300:00ff:fe61:6f48:6a89] when using ipv6 address.

I copy the kcpclient from the ShadowsocksX-NG package folder and test it with a custom json config file, only adding [] in ipv6 address and it works fine.

Steps to reproduce:

connect to a ssserver via ipv6.

kcptun_client.log

log with no [] in current version, ipv6 won't work.(the ipv6 address in the log is a fork one )

2017/10/10 21:37:37 version: 20170322
2017/10/10 21:37:37 listening on: 127.0.0.1:8388
2017/10/10 21:37:37 encryption: aes-192
2017/10/10 21:37:37 nodelay parameters: 1 20 2 1
2017/10/10 21:37:37 remote address: 2001:19f0:7001:15ac:5300:00ff:fe61:6f48:6a89
2017/10/10 21:37:37 sndwnd: 128 rcvwnd: 512
2017/10/10 21:37:37 compression: true
2017/10/10 21:37:37 mtu: 1350
2017/10/10 21:37:37 datashard: 10 parityshard: 3
2017/10/10 21:37:37 acknodelay: false
2017/10/10 21:37:37 dscp: 0
2017/10/10 21:37:37 sockbuf: 4194304
2017/10/10 21:37:37 keepalive: 10
2017/10/10 21:37:37 conn: 1
2017/10/10 21:37:37 autoexpire: 0
2017/10/10 21:37:37 scavengettl: 600
2017/10/10 21:37:37 snmplog: 
2017/10/10 21:37:37 snmpperiod: 60

log with [] in ipv6 address, works. note the last line tell us the connection is established.

2017/10/10 21:47:25 version: 20170322
2017/10/10 21:47:25 listening on: [::]:6666
2017/10/10 21:47:25 encryption: aes-192
2017/10/10 21:47:25 nodelay parameters: 1 20 2 1
2017/10/10 21:47:25 remote address: [2001:19f0:7001:15ac:5300:00ff:fe61:6f48:6a89]:6789
2017/10/10 21:47:25 sndwnd: 512 rcvwnd: 512
2017/10/10 21:47:25 compression: true
2017/10/10 21:47:25 mtu: 1350
2017/10/10 21:47:25 datashard: 10 parityshard: 3
2017/10/10 21:47:25 acknodelay: false
2017/10/10 21:47:25 dscp: 0
2017/10/10 21:47:25 sockbuf: 4194304
2017/10/10 21:47:25 keepalive: 10
2017/10/10 21:47:25 conn: 1
2017/10/10 21:47:25 autoexpire: 0
2017/10/10 21:47:25 scavengettl: 600
2017/10/10 21:47:25 snmplog:
2017/10/10 21:47:25 snmpperiod: 60
2017/10/10 21:47:25 SetDSCP: setsockopt: invalid argument
2017/10/10 21:47:25 connection: [2001:da8:204:2512::1:49e8]:49863 -> [2001:19f0:7001:15ac:5300:00ff:fe61:6f48:6a89]:6789
LiJinyao commented 7 years ago

目前的解决方法是使用一个域名解析到对应的ipv6地址,然后填入这个域名。