本文整理汇总了Java中com.jcraft.jsch.ProxySOCKS5类的典型用法代码示例。如果您正苦于以下问题:Java ProxySOCKS5类的具体用法?Java ProxySOCKS5怎么用?Java ProxySOCKS5使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProxySOCKS5类属于com.jcraft.jsch包,在下文中一共展示了ProxySOCKS5类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: connect
import com.jcraft.jsch.ProxySOCKS5; //导入依赖的package包/类
private void connect(String ip, int port, String user, String key, String passphrase, Proxy proxy) throws JSchException {
jsch = new JSch();
jsch.addIdentity(key);
session = jsch.getSession(user, ip, port);
if (proxy != null)
{
if ("HTTP".equalsIgnoreCase(proxy.getType()))
{
session.setProxy(new ProxyHTTP(proxy.getProxyIp(), proxy.getProxyPort()));
}
else if ("SOCKS5".equalsIgnoreCase(proxy.getType()))
{
session.setProxy(new ProxySOCKS5(proxy.getProxyIp(), proxy.getProxyPort()));
}
else if ("SOCKS4".equalsIgnoreCase(proxy.getType()))
{
session.setProxy(new ProxySOCKS4(proxy.getProxyIp(), proxy.getProxyPort()));
}
}
session.setUserInfo(new MyUserInfo(null, passphrase));
Properties conf = new Properties();
conf.put("StrictHostKeyChecking", "no");
session.setConfig(conf);
synchronized (JSch.class) {
session.connect(timeout);
}
}
开发者ID:fastj,项目名称:fit-ext-default,代码行数:30,代码来源:JSchImpl.java
示例2: setProxySOCKS5
import com.jcraft.jsch.ProxySOCKS5; //导入依赖的package包/类
public void setProxySOCKS5(String proxy_host, int proxy_port, String proxy_user, String proxy_password){
proxySOCKS5 = new ProxySOCKS5(proxy_host, proxy_port);
if (proxy_user!=null)
proxySOCKS5.setUserPasswd(proxy_user, proxy_password);
proxyType=SOCKS5;
if (myLogger!=null)
myLogger.log(com.jcraft.jsch.Logger.DEBUG, "PROXY_SOCKS5 host="+proxy_host+"; port="+proxy_port+"; user="+proxy_user);
}
开发者ID:vagfed,项目名称:hmcScanner,代码行数:9,代码来源:SSHManager2.java
示例3: connect
import com.jcraft.jsch.ProxySOCKS5; //导入依赖的package包/类
public Response<String> connect(String ip,int port,String user,String passwd, Proxy proxy){
Response<String> resp = new Response<String>();
try {
jsch = new JSch();
session = jsch.getSession(user, ip, port);
if (proxy != null)
{
if ("HTTP".equalsIgnoreCase(proxy.getType()))
{
session.setProxy(new ProxyHTTP(proxy.getProxyIp(), proxy.getProxyPort()));
}
else if ("SOCKS5".equalsIgnoreCase(proxy.getType()))
{
session.setProxy(new ProxySOCKS5(proxy.getProxyIp(), proxy.getProxyPort()));
}
else if ("SOCKS4".equalsIgnoreCase(proxy.getType()))
{
session.setProxy(new ProxySOCKS4(proxy.getProxyIp(), proxy.getProxyPort()));
}
}
session.setPassword(passwd);
Properties conf = new Properties();
conf.put("StrictHostKeyChecking", "no");
session.setConfig(conf);
session.connect();
ftps = (ChannelSftp) session.openChannel("sftp");
ftps.connect();
resp.setCode(Response.OK);
connected = true;
} catch (JSchException e) {
resp.setCode(Response.IO_EXCEPTION);
resp.setPhrase("SftpException: " + e.getMessage());
}
return resp;
}
开发者ID:fastj,项目名称:fit-ext-default,代码行数:40,代码来源:SftpJSchImpl.java
示例4: connect
import com.jcraft.jsch.ProxySOCKS5; //导入依赖的package包/类
/**
* Connects the connection.
* @throws IOException if the unfortunate happens.
*/
@Override
public synchronized void connect() throws IOException {
logger.debug("connecting...");
Authentication auth = authentication;
if (updater != null) {
Authentication updatedAuth = updater.updateAuthentication(authentication);
if (updatedAuth != null && auth != updatedAuth) {
auth = updatedAuth;
}
}
try {
client = new JSch();
if (auth.getPrivateKeyPhrase() == null) {
client.addIdentity(auth.getPrivateKeyFile().getAbsolutePath(),
auth.getPrivateKeyFilePassword());
} else {
client.addIdentity(auth.getUsername(), auth.getPrivateKeyPhrase(), null,
auth.getPrivateKeyFilePassword().getBytes("UTF-8"));
}
client.setHostKeyRepository(new BlindHostKeyRepository());
connectSession = client.getSession(auth.getUsername(), host, port);
connectSession.setConfig("PreferredAuthentications", "publickey");
if (proxy != null && !proxy.isEmpty()) {
String[] splitted = proxy.split(":");
if (splitted.length > 2 && splitted[1].length() >= PROTO_HOST_DELIM_LENGTH) {
String pproto = splitted[0];
String phost = splitted[1].substring(2);
int pport = Integer.parseInt(splitted[2]);
if (pproto.equals("socks5") || pproto.equals("http")) {
if (pproto.equals("socks5")) {
connectSession.setProxy(new ProxySOCKS5(phost, pport));
} else {
connectSession.setProxy(new ProxyHTTP(phost, pport));
}
} else {
throw new MalformedURLException("Only http and socks5 protocols are supported");
}
} else {
throw new MalformedURLException(proxy);
}
}
connectSession.connect(this.connectionTimeout);
logger.debug("Connected: {}", connectSession.isConnected());
connectSession.setServerAliveInterval(ALIVE_INTERVAL);
} catch (JSchException ex) {
throw new SshException(ex);
}
}
开发者ID:sonyxperiadev,项目名称:gerrit-events,代码行数:53,代码来源:SshConnectionImpl.java
示例5: createProxy
import com.jcraft.jsch.ProxySOCKS5; //导入依赖的package包/类
private com.jcraft.jsch.Proxy createProxy (String proxyHost, int proxyPort) {
return USE_PROXY_TUNNELING
? new ProxyHTTP(proxyHost, proxyPort)
: new ProxySOCKS5(proxyHost, proxyPort);
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:6,代码来源:JGitSshSessionFactory.java
注:本文中的com.jcraft.jsch.ProxySOCKS5类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论