sntp
sntp copied to clipboard
spliteAddr: support IPv6
When given an IPv4 address, the string spliteAddr receives looks like: 1.2.3.4:123 Splitting on ":" is fine, because the IP address contains only integers and "." chars.
When given an IPv6 address, the string spliteAddr receives looks like: [2001:0db8:85a3:0000:0000:8a2e:0370:7334]:123
The existing implementation fails on such a string. Colons are used within IPv6 addresses.
My patch splits on the last ":" character, which works for both IPv4 and IPv6 addresses.
I'm not sure how this happened, but I actually only intended one commit (93ba5e96fa406e0403b913cc291d21946f9e41c1) in the pull request. This commit adds IPv6 support. Thanks.