Please rewrite this to 

1) Not use `!!!Integer(...)`, that's honestly too much back and forth
2) Not use exceptions for control flow. Just check if it's a number by applying a regexp or another way that avoids exceptions.

In the way it's currently written it is hard to tell apart the two code paths for IPv4 vs IPv6 addresses.