mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "向秦贤" <fya...@gmail.com>
Subject Re: Does mina suppot SOCKS proxy connections?
Date Sun, 15 Jul 2007 02:16:21 GMT
hi, stupidbea:)
maybe you can try com.jcraft.jsch.Proxy, I wanna to do with it, but not try
it.:)

follow code from eclipse cvs
org.eclipse.team.internal.ccvs.core.connection.PServerConnection.
/**
     * @see Connection#doOpen()
     */
    public void open(IProgressMonitor monitor) throws IOException,
CVSAuthenticationException {

        monitor.subTask(CVSMessages.PServerConnection_authenticating);
        monitor.worked(1);

        InputStream is = null;
        OutputStream os = null;

        Proxy proxy = getProxy();
        if (proxy!=null) {
          String host = cvsroot.getHost();
          int port = cvsroot.getPort();
          if (port == ICVSRepositoryLocation.USE_DEFAULT_PORT) {
            port = DEFAULT_PORT;
          }
          try {
            int timeout = CVSProviderPlugin.getPlugin().getTimeout() * 1000;
            IJSchService service = CVSProviderPlugin.getPlugin
().getJSchService();
            service.connect(proxy, host, port, timeout, monitor);
          } catch( Exception ex) {
            ex.printStackTrace();
            throw new IOException(ex.getMessage());
          }
          is = proxy.getInputStream();
          os = proxy.getOutputStream();

        } else {
          fSocket = createSocket(monitor);
          is = fSocket.getInputStream();
          os = fSocket.getOutputStream();
        }

        boolean connected = false;
        try {
            this.inputStream = new BufferedInputStream(new
PollingInputStream(is,
                cvsroot.getTimeout(), monitor));
            this.outputStream = new PollingOutputStream(new
TimeoutOutputStream(
                os, 8192 /*bufferSize*/, 1000 /*writeTimeout*/, 1000
/*closeTimeout*/),
                cvsroot.getTimeout(), monitor);
            authenticate();
            connected = true;
        } finally {
            if (! connected) cleanUpAfterFailedConnection();
        }
    }

    private Proxy getProxy() {
        IJSchService service = CVSProviderPlugin.getPlugin
().getJSchService();
        if (service == null)
            return null;
        Proxy proxy = service.getProxyForHost(cvsroot.getHost(),
IProxyData.SOCKS_PROXY_TYPE);
        if (proxy == null)
            proxy = service.getProxyForHost(cvsroot.getHost(),
IProxyData.HTTPS_PROXY_TYPE);
        return proxy;
    }


2007/7/14, bea <stupidbea@yahoo.com>:
>
>
> Does anyone have any pointers on how to add support for this?
> Unfortunately,
> SOCKS is critical for my project. If I am not able to use the Proxy
> functionality provided by the jdk using Mina, Mina is going to have to go
> :(.
>
> Thanks for any suggestions.
>
>
>
>
>
> mheath wrote:
> >
> > On 7/13/07, bea <stupidbea@yahoo.com> wrote:
> >>
> >> Will it work if I set the socksProxyHost system property? Or is there
> >> some
> >> connector available that uses proxies? Thank you for your help.
> >
> > No.  Java NIO does not support using a Proxy.  There has been talk
> > about adding support to MINA for communicating with a SOCKS or HTTP
> > proxy.
> >
> > This issue https://issues.apache.org/jira/browse/DIRMINA-223 is
> > tracking the request for proxy support.
> >
> > -Mike
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Does-mina-suppot-SOCKS-proxy-connections--tf4076194.html#a11589402
> Sent from the mina dev mailing list archive at Nabble.com.
>
>


-- 
向秦贤
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message