lxzan / gws

simple, fast, reliable websocket server & client, supports running over tcp/kcp/unix domain socket. keywords: ws, proxy, chat, go, golang...
https://pkg.go.dev/github.com/lxzan/gws
Apache License 2.0
1.37k stars 86 forks source link

Issues trying to connect to IPv6 Servers #115

Open sksar opened 2 hours ago

sksar commented 2 hours ago

When I try to connect to an IPv6 server using such URL: wss://[2500:6280:100:d0::1c2c:4001]:7000, it gives the error dial tcp: address 2500:6280:100:d0::1c2c:4001:7000: too many colons in address.

For some reason it seems it adds the port to the last, something like :7000 in the above example, making it part of the IPv6 address itself. I have investigated a lot, and seems the issue is coming from within gws code.

sksar commented 2 hours ago

https://github.com/lxzan/gws/blob/586e980cec513a3c985d83b2075ece54f4421f13/client.go#L52C1-L53C92

Seems like these two lines here are causing the issue, to get the square brackets removed completely, from the IPv6.