Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-5490

SOCKS proxy domain name validation too restrictive

    • Fully Compatible
    • Java Drivers
    • Needed
    • Hide

      Let's communicate in what's new that we fixed a bug in how domain names are validated when proxy functionality (SocketSettings.Builder.applyToProxySettings) is used. Previously the validation refused to accept valid domain names with more than 6 characters in the top-level domain (TLD).

      Show
      Let's communicate in what's new that we fixed a bug in how domain names are validated when proxy functionality ( SocketSettings.Builder.applyToProxySettings ) is used. Previously the validation refused to accept valid domain names with more than 6 characters in the top-level domain (TLD).

      Summary

      Affects any MongoDB driver version from 4.11.x onwards (when SOCKS proxy support was introduced).

       

      Unable to connect: Timed out after 30000 ms while waiting for a server that matches ReadPreferenceServerSelector{readPreference=primary}. Client view of cluster state is {type=REPLICA_SET, servers=[{address=ip-10-10-10-10.ec2.internal:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.SocketException: ip-10-10-10-10.ec2.internal is not an IP string literal}}
      

      On connect, the Socks Socket determines if the remote address is either a domain name or IPvN address but fails with the above exception when dealing with names such as EC2 guest OS hostnames explained here

      The problem seems to be the regex used for validating if the address is domain name is too restrictive.

      A more inclusive pattern could be:

      ^(?!:\/\/)(?=[a-zA-Z0-9\-\.]{1,255}$)((.{1,63}\.){1,127}(?![0-9]*$)[a-z0-9\-]+\.?|localhost)$ 

            Assignee:
            slav.babanin@mongodb.com Slav Babanin
            Reporter:
            jonathon@streamkap.com Jonathon Ogden
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: