English 中文(简体)
连接到SOCKS5代理以在Java中执行FTP/S
原标题:Connecting to a SOCKS5 proxy to do FTP/S in Java

我正在编写一个作业,该作业将通过我的SOCKS5代理连接到客户端的FTP/s服务器,并且我正在使用Apache Commons Net包。问题是我的SOCKS代理被配置为不需要身份验证,但我仍然得到以下异常:

java.net.SocketException: SOCKS : authentication failed
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:443)
    at java.net.Socket.connect(Socket.java:519)

我已经尝试将java.net.socks.username和password属性设置为空字符串,但我仍然得到了它。有没有办法告诉代码不要使用身份验证?深入研究底层源代码,我几乎认为它是在查询代理服务器以了解身份验证需求,但我不确定。

最佳回答

好吧,所以问题是我的SOCKS代理被设置为请求身份验证,但也接受未进行身份验证的连接。我们使用Dante,虽然像Filezilla这样的程序足够聪明,可以迭代所有可接受的身份验证方法,但java.net包似乎只偏离了提供的第一种方法。由于我在sockd.conf文件中的身份验证配置如下:

method: username none
user.notprivileged: nobody

java.net要求提供用户名和密码。我只是简单地将方法翻转为“none-username”,Filezilla和java.net都能正确地通过代理。这有点像一个It解决方案,但无论什么都能让代码发挥作用,对吧?

问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签