简体   繁体   English

使用FTP代理与apache commons-net

[英]Using FTP Proxy with apache commons-net

I want to set up an FTP connection using a proxy server with Apache's commons-net. 我想使用Apache的commons-net使用代理服务器建立FTP连接。

But looking at this Does FTPClient support FTP connections through an FTP proxy server? 但是看看这个FTPClient是否支持通过FTP代理服务器的FTP连接? has me worried. 让我担心

I have to meddle with the system properties and the Sun docs state that "If socksProxyHost is specified then all TCP sockets will use the SOCKS proxy server to establish a connection or accept one." 我必须干涉系统属性,Sun文档声明“如果指定了socksProxyHost ,那么所有TCP套接字都将使用SOCKS代理服务器建立连接或接受连接。”
WTH? WTH? All TCP sockets? 所有TCP套接字? What about my database connections? 我的数据库连接怎么样? Or other FTP connections i might want to open at the same time not using a proxy? 或者其他FTP连接我可能想要在不使用代理的情况下同时打开? Will they all be affected? 他们都会受到影响吗?

Is there some other way to do it that doesn't mess with the rest of my application? 有没有其他方法可以做到这一点不会弄乱我的应用程序的其余部分?

You have several ways of using proxies in Java, especially from version 1.5. 您有几种在Java中使用代理的方法,尤其是1.5版本。

  1. Using System Properties: quick & powerfull but limited flexibility 使用系统属性:快速而强大但灵活性有限
    • You can use use a SOCKS proxy for all TCP connections. 您可以使用SOCKS代理进行所有TCP连接。
    • You can also set a proxy per protocol, doable for HTTP, FTP and HTTPS 您还可以为每个协议设置代理,可以为HTTP,FTP和HTTPS设置代理
    • For both methods, you can specify a list of hosts that will not use proxy 对于这两种方法,您可以指定不使用代理的主机列表
  2. Using the java.net.Proxy class (Java 1.5+) to set (or not) a Proxy per Connection 使用java.net.Proxy类(Java 1.5+)为每个Connection设置(或不设置) Proxy
  3. Impleting a java.net.ProxySelector (idem) which will determine a Proxy for each Connection according to your criteria 实现java.net.ProxySelector (idem),它将根据您的条件为每个Connection确定Proxy

See the detailled Sun technote on networking & proxies . 请参阅有关网络和代理详细Sun技术说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM