本文整理了Java中com.jcraft.jsch.Session.setPortForwardingL()
方法的一些代码示例,展示了Session.setPortForwardingL()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Session.setPortForwardingL()
方法的具体详情如下:
包路径:com.jcraft.jsch.Session
类名称:Session
方法名:setPortForwardingL
[英]Registers the local port forwarding for loop-back interface. If lport
is 0
, the tcp port will be allocated.
[中]
代码示例来源:origin: looly/hutool
/**
* 绑定端口到本地。 一个会话可绑定多个端口
*
* @param session 需要绑定端口的SSH会话
* @param remoteHost 远程主机
* @param remotePort 远程端口
* @param localPort 本地端口
* @return 成功与否
* @throws JschRuntimeException 端口绑定失败异常
*/
public static boolean bindPort(Session session, String remoteHost, int remotePort, int localPort) throws JschRuntimeException {
if (session != null && session.isConnected()) {
try {
session.setPortForwardingL(localPort, remoteHost, remotePort);
} catch (JSchException e) {
throw new JschRuntimeException(e, "From [{}] mapping to [{}] error!", remoteHost, localPort);
}
return true;
}
return false;
}
代码示例来源:origin: looly/hutool
/**
* 绑定端口到本地。 一个会话可绑定多个端口
*
* @param session 需要绑定端口的SSH会话
* @param remoteHost 远程主机
* @param remotePort 远程端口
* @param localPort 本地端口
* @return 成功与否
* @throws JschRuntimeException 端口绑定失败异常
*/
public static boolean bindPort(Session session, String remoteHost, int remotePort, int localPort) throws JschRuntimeException {
if (session != null && session.isConnected()) {
try {
session.setPortForwardingL(localPort, remoteHost, remotePort);
} catch (JSchException e) {
throw new JschRuntimeException(e, "From [{}] mapping to [{}] error!", remoteHost, localPort);
}
return true;
}
return false;
}
代码示例来源:origin: dboissier/mongo4idea
session.setPortForwardingL(localPort, remoteMongoHost, remoteMongoPort);
代码示例来源:origin: ePaul/jsch-documentation
/**
* Registers the local port forwarding for loop-back interface.
* If <code>lport</code> is <code>0</code>, the tcp port will be allocated.
* @param lport local port for local port forwarding
* @param host host address for local port forwarding
* @param rport remote port number for local port forwarding
* @return an allocated local TCP port number
* @see #setPortForwardingL(String bind_address, int lport, String host, int rport, ServerSocketFactory ssf, int connectTimeout)
*/
public int setPortForwardingL(int lport, String host, int rport) throws JSchException{
return setPortForwardingL("127.0.0.1", lport, host, rport);
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.jsch
/**
* Registers the local port forwarding for loop-back interface.
* If <code>lport</code> is <code>0</code>, the tcp port will be allocated.
* @param lport local port for local port forwarding
* @param host host address for local port forwarding
* @param rport remote port number for local port forwarding
* @return an allocated local TCP port number
* @see #setPortForwardingL(String bind_address, int lport, String host, int rport, ServerSocketFactory ssf, int connectTimeout)
*/
public int setPortForwardingL(int lport, String host, int rport) throws JSchException{
return setPortForwardingL("127.0.0.1", lport, host, rport);
}
代码示例来源:origin: org.mule.jsch/jsch
/**
* Registers the local port forwarding for loop-back interface.
* If <code>lport</code> is <code>0</code>, the tcp port will be allocated.
* @param lport local port for local port forwarding
* @param host host address for local port forwarding
* @param rport remote port number for local port forwarding
* @return an allocated local TCP port number
* @see #setPortForwardingL(String bind_address, int lport, String host, int rport, ServerSocketFactory ssf, int connectTimeout)
*/
public int setPortForwardingL(int lport, String host, int rport) throws JSchException{
return setPortForwardingL("127.0.0.1", lport, host, rport);
}
代码示例来源:origin: com.jcraft.jsch/com.springsource.com.jcraft.jsch
public int setPortForwardingL(int lport, String host, int rport) throws JSchException{
return setPortForwardingL("127.0.0.1", lport, host, rport);
}
public int setPortForwardingL(String boundaddress, int lport, String host, int rport) throws JSchException{
代码示例来源:origin: org.xbib/jsch-core
/**
* Registers the local port forwarding for loop-back interface.
* If <code>lport</code> is <code>0</code>, the tcp port will be allocated.
*
* @param lport local port for local port forwarding
* @param host host address for local port forwarding
* @param rport remote port number for local port forwarding
* @return an allocated local TCP port number
* @see #setPortForwardingL(String bind_address, int lport, String host, int rport, ServerSocketFactory ssf, int connectTimeout)
*/
public int setPortForwardingL(int lport, String host, int rport) throws JSchException {
return setPortForwardingL("127.0.0.1", lport, host, rport);
}
代码示例来源:origin: com.jcraft.jsch/com.springsource.com.jcraft.jsch
public int setPortForwardingL(String boundaddress, int lport, String host, int rport) throws JSchException{
return setPortForwardingL(boundaddress, lport, host, rport, null);
}
public int setPortForwardingL(String boundaddress, int lport, String host, int rport, ServerSocketFactory ssf) throws JSchException{
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.jsch
/**
* Registers the local port forwarding. If <code>bind_address</code> is an empty string
* or '*', the port should be available from all interfaces.
* If <code>bind_address</code> is <code>"localhost"</code> or
* <code>null</code>, the listening port will be bound for local use only.
* If <code>lport</code> is <code>0</code>, the tcp port will be allocated.
* @param bind_address bind address for local port forwarding
* @param lport local port for local port forwarding
* @param host host address for local port forwarding
* @param rport remote port number for local port forwarding
* @return an allocated local TCP port number
* @see #setPortForwardingL(String bind_address, int lport, String host, int rport, ServerSocketFactory ssf, int connectTimeout)
*/
public int setPortForwardingL(String bind_address, int lport, String host, int rport) throws JSchException{
return setPortForwardingL(bind_address, lport, host, rport, null);
}
代码示例来源:origin: io.cloudslang.content/score-ssh
@Override
public void createLocalTunnel(int localPort, String remoteHost, int remotePort) {
try {
session.setPortForwardingL(localPort, remoteHost, remotePort);
} catch (JSchException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: io.openscore.content/score-ssh
@Override
public void createLocalTunnel(int localPort, String remoteHost, int remotePort) {
try {
session.setPortForwardingL(localPort, remoteHost, remotePort);
} catch (JSchException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: io.cloudslang.content/cs-ssh
@Override
public void createLocalTunnel(int localPort, String remoteHost, int remotePort) {
try {
session.setPortForwardingL(localPort, remoteHost, remotePort);
} catch (JSchException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: CloudSlang/cs-actions
@Override
public void createLocalTunnel(int localPort, String remoteHost, int remotePort) {
try {
session.setPortForwardingL(localPort, remoteHost, remotePort);
} catch (JSchException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: stackoverflow.com
JSch jsch = new JSch();
Session session = jsch.getSession(user, host);
session.setPassword(password);
session.connect(timeout);
session.setPortForwardingL(listenPort, destHost, destPort);
代码示例来源:origin: net.sf.sshapi/sshapi-jsch
protected void onOpen() throws SshException {
try {
session.setPortForwardingL(localAddress, localPort, remoteHost, remotePort);
channelCount++;
} catch (JSchException e) {
throw new SshException("Failed to configure local port forward");
}
}
代码示例来源:origin: org.ujmp/ujmp-jsch
public static Session forwardLocalPort(String hostname, int port, String username, File keyFile,
final String passphrase, int localPortToForward, String remoteHostToForwardTo, int remotePortToForwardTo)
throws JSchException, IOException {
Session session = createSession(hostname, port, username, keyFile, passphrase);
session.setPortForwardingL(localPortToForward, remoteHostToForwardTo, remotePortToForwardTo);
session.connect();
return session;
}
代码示例来源:origin: ujmp/universal-java-matrix-package
public static Session forwardLocalPort(String hostname, int port, String username, File keyFile,
final String passphrase, int localPortToForward, String remoteHostToForwardTo, int remotePortToForwardTo)
throws JSchException, IOException {
Session session = createSession(hostname, port, username, keyFile, passphrase);
session.setPortForwardingL(localPortToForward, remoteHostToForwardTo, remotePortToForwardTo);
session.connect();
return session;
}
代码示例来源:origin: stackoverflow.com
JSch jsch = new JSch();
Session session = jsch.getSession(user, host);
session.setPassword(password);
session.connect(timeout);
session.setPortForwardingL(listenPort, destHost, destPort);
代码示例来源:origin: guru.nidi/build-tools
private Session startSession() {
try {
Session session = openSession();
session.setTimeout((int) maxwait);
session.setPortForwardingL(Integer.parseInt(lport), rhost, Integer.parseInt(rport));
log("SSHTunnel : Connection created successfully.", Project.MSG_INFO);
return session;
} catch (Exception e) {
log("SSHTunnel : Connect Failed", Project.MSG_ERR);
throw new BuildException("SSHTunnel Task Failed: Unable to create tunnel", e);
}
}
内容来源于网络,如有侵权,请联系作者删除!