[ 
https://issues.apache.org/jira/browse/NET-650?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16343921#comment-16343921
 ] 

Matthew McGillis commented on NET-650:
--------------------------------------

The question I had is can we add something without impacting current behavior.

Focus on the no proxy case, hostname defined or undefined locally.

If we replace existing implementation and use ISA constructor. This is what the 
source code is for it. (It has other constructors but lets assume this common 
case only)

{code}
 public More ...InetSocketAddress(String hostname, int port) {
        if (port < 0 || port > 0xFFFF) {
            throw new IllegalArgumentException("port out of range:" + port);
        }
        if (hostname == null) {
            throw new IllegalArgumentException("hostname can't be null");
        }
        try {
            addr = InetAddress.getByName(hostname);
        } catch(UnknownHostException e) {
            this.hostname = hostname;
            addr = null;
        }
        this.port = port;
    }
{code}

Does all existing behavior work.

My guess is yes.

If you have the hostname you get the local IP and we have no proxy so the local 
IP works and gets you to desired destination.

If you have no hostname then you get the expected and desired response of 
UnknownHostException this is not a problem in this case it is a informative 
response.

If all other existing regression tests pass then the above is a simple fix that 
keeps all current functionality.

However the above allows the proxy to now also work in this fashion
1. the host does not exist locally but does remotely (most common case I think)
2. the host does exist locally and works remotely (sort of unusual case I think)
3. the host does not exist locally or remotely (this you get an odd error for 
but an error is appropriate just might be nice to provide a better one)
4. the host does exist locally but does not work remotely (sort of unusual case 
I think expect you would get some sort of error that may or may not be obvious 
but an error is appropriate)
5. the host exists in both places but the local ip does not work on remote only 
the remote ip does (this case is broken in this initial implementation you 
think the remote name and ip are getting used but instead you are using a local 
ip remotely for the name you think would work)

> IMAPClient over proxy doesn't properly resolve DNS
> --------------------------------------------------
>
>                 Key: NET-650
>                 URL: https://issues.apache.org/jira/browse/NET-650
>             Project: Commons Net
>          Issue Type: Bug
>          Components: IMAP
>    Affects Versions: 3.6
>            Reporter: Matthew McGillis
>            Priority: Major
>         Attachments: imapproxy.java, imapproxy2.java, socketproxy.java
>
>
> IMAPClient when configured to use a socks proxy is not able to resolve DNS 
> names through the proxy.
> See attached sample code, if I use it with:
> {noformat}
> $ java -DsocksProxyHost=localhost -DsocksProxyPort=16003 -cp 
> .:./commons-net-3.6.jar imapproxy imap.server.test.com user1 userpass
> connect error: java.net.UnknownHostException: imap.server.test.com: unknown 
> error
> {noformat}
> vs if I use it with the appropriate IP:
> {noformat}
> $ java -DsocksProxyHost=localhost -DsocksProxyPort=16003 -cp 
> .:./commons-net-3.6.jar imapproxy 10.250.3.127 user1 userpass
> * OK IMAP4rev1 proxy server ready
> IMAP: 10.250.3.127 143
> AAAA LOGIN *******
> AAAA OK [CAPABILITY IMAP4rev1 ACL BINARY CATENATE CHILDREN CONDSTORE ENABLE 
> ESEARCH ESORT I18NLEVEL=1 ID IDLE LIST-EXTENDED LIST-STATUS LITERAL+ 
> LOGIN-REFERRALS MULTIAPPEND NAMESPACE QRESYNC QUOTA RIGHTS=ektx SASL-IR 
> SEARCHRES SORT THREAD=ORDEREDSUBJECT UIDPLUS UNSELECT WITHIN XLIST] LOGIN 
> completed
> AAAB LOGOUT
> * BYE 10.250.3.127 Zimbra IMAP4rev1 server closing connection
> AAAB OK LOGOUT completed
> {noformat}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to