notnoop / java-apns

Java Apple Push Notification Service Provider
notnoop.github.com/java-apns
BSD 3-Clause "New" or "Revised" License
1.8k stars 658 forks source link

Add a more robust way to look up TlsTunnel proxy host name #347

Closed petarov closed 4 years ago

petarov commented 6 years ago

This fixes and issue where InetAddress.toString() may return a result in the form of "<empty>/ip-address". It is not guaranteed that a host name will always be resolved here, therefore this may eventually lead to incorrect proxy address (an empty string basically) being used when constructing the TlsTunnel.

See [InetAddress.html#toString](http://download.java.net/jdk7/archive/b123/docs/api/java/net/InetAddress.html#toString())

In my test case, due to failing DNS lookup, the InetAddress.toString() was always returning "/10.1.1.5" which led to proxy connection failure. This must not be the case. The TlsTunnel should use the ip address if a host name lookup had failed.

This probably also addresses #285.