将 FTP 代理与 apache commons-net 一起使用

发布于 2024-07-26 01:57:15 字数 444 浏览 2 评论 0原文

我想使用代理服务器与 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

娇纵 2024-08-02 01:57:15

在 Java 中使用代理有多种方法,特别是从 1.5 版本开始。

  1. 使用系统属性:快速& 强大但灵活性有限
    • 您可以对所有 TCP 连接使用 SOCKS 代理。
    • 您还可以为每个协议设置代理,适用于 HTTP、FTP 和 HTTPS
    • 对于这两种方法,您都可以指定不使用代理的主机列表
  2. 使用 java.net.Proxy 类 (Java 1.5 +) 设置(或不设置)每个 ConnectionProxy
  3. 实现 java.net.ProxySelector (同上)将为每个确定一个 Proxy根据您的标准连接

请参阅有关网络和网络的详细 Sun 技术说明 代理

You have several ways of using proxies in Java, especially from version 1.5.

  1. Using System Properties: quick & powerfull but limited flexibility
    • You can use use a SOCKS proxy for all TCP connections.
    • You can also set a proxy per protocol, doable for HTTP, FTP and 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
  3. Impleting a java.net.ProxySelector (idem) which will determine a Proxy for each Connection according to your criteria

See the detailled Sun technote on networking & proxies.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文