~ancarda/tls-redirector

ref: 5f0b9ad56965a4fa1f18e3734f574c80e6e7340f tls-redirector/util_test.go -rw-r--r-- 992 bytes
Improve detection of IPv6 addresses

This commit strips the square brackets that IPv6 addresses can be in when a
port number is suffixed on the end. The presence of these square brackets
would cause the `net.ParseIP' function to (correctly) determine the string to
not be an IP address.

If an IPv6 address with a port number is sent, it is already handled because
the `net.SplitHostPort' function is able to detect that. This commit fixes the
edge case where no port number is present, but square brackets are.

Issue: https://todo.sr.ht/~ancarda/tls-redirector/4
Add unit tests for isIPAddress

This commit moves `isIPAddress' out of main.go to util.go so some
basic unit tests can be written for this function
Next