forwardRemote method
Future<SSHRemoteForward?>
forwardRemote({
- String? host,
- int? port,
- SSHRemoteConnectionFilter? filter,
Request connections to a port on the other side be forwarded to the local
side.
Set host
to null to listen on all interfaces, "0.0.0.0"
to
listen on all IPv4 interfaces, "::"
to listen on all IPv6 interfaces,
and "localhost"
to listen on the loopback interface on all protocols.
Set port
to null to listen on a random port.
Implementation
Future<SSHRemoteForward?> forwardRemote({
String? host,
int? port,
SSHRemoteConnectionFilter? filter,
}) async {
await _authenticated.future;
// Lisning on all interfaces if not specified.
host ??= '';
// Lisning on a random port if not specified.
port ??= 0;
_sendMessage(SSH_Message_Global_Request.tcpipForward(host, port));
final reply = await _globalRequestReplyQueue.next;
if (reply is SSH_Message_Request_Failure) return null;
if (reply is! SSH_Message_Request_Success) {
throw SSHStateError('Unexpected reply to tcpip-forward request: $reply');
}
final reader = SSHMessageReader(reply.requestData);
final assignedPort = port != 0 ? port : reader.readUint32();
final remoteForward = SSHRemoteForward(this, host, assignedPort, filter);
_remoteForwards.add(remoteForward);
return remoteForward;
}