将 FTP 代理与 apache commons-net 一起使用
我想使用代理服务器与 Apache 的 commons-net 建立 FTP 连接。
但是看看这个 Does FTPClient support 通过 FTP 代理服务器进行 FTP 连接? 有我担心。
我必须干预系统属性,Sun 文档指出“如果指定了socksProxyHost,那么所有 TCP 套接字都将使用 SOCKS 代理服务器来建立连接或接受连接。”
啥? 所有 TCP 套接字? 我的数据库连接怎么样? 或者我可能想在不使用代理的情况下同时打开其他 FTP 连接? 他们都会受到影响吗?
有没有其他方法可以做到这一点,并且不会干扰我的应用程序的其余部分?
I want to set up an FTP connection using a proxy server with Apache's commons-net.
But looking at this Does FTPClient support FTP connections through an FTP proxy server? 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."
WTH? All TCP sockets? What about my database connections? Or other FTP connections i might want to open at the same time not using a proxy? Will they all be affected?
Is there some other way to do it that doesn't mess with the rest of my application?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 Java 中使用代理有多种方法,特别是从 1.5 版本开始。
java.net.Proxy
类 (Java 1.5 +) 设置(或不设置)每个Connection
的Proxy
java.net.ProxySelector
(同上)将为每个确定一个Proxy
根据您的标准连接
请参阅有关网络和网络的详细 Sun 技术说明 代理。
You have several ways of using proxies in Java, especially from version 1.5.
java.net.Proxy
class (Java 1.5+) to set (or not) aProxy
perConnection
java.net.ProxySelector
(idem) which will determine aProxy
for eachConnection
according to your criteriaSee the detailled Sun technote on networking & proxies.