public RemotePortForwardingReply OnRemotePortForwardingRequest(RemotePortForwardingRequest request, ISSHChannel channel) { // exception is not handled here. // caller should handle exception appropriately. return(_coreHandler.OnRemotePortForwardingRequest(request, channel)); }
public RemotePortForwardingReply OnRemotePortForwardingRequest(RemotePortForwardingRequest request, ISSHChannel channel) { // exception is not handled here. // caller should handle exception appropriately. return _coreHandler.OnRemotePortForwardingRequest(request, channel); }
public RemotePortForwardingReply OnRemotePortForwardingRequest(RemotePortForwardingRequest request, ISSHChannel channel) { try { if (!_profile.AllowsForeignConnection && !IsLoopbackAddress(request.OriginatorIp)) { return RemotePortForwardingReply.Reject( RemotePortForwardingReply.Reason.AdministrativelyProhibited, "rejected"); } Socket local = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); local.Connect(new IPEndPoint(Util.ResolveHost(_profile.DestinationHost), _profile.DestinationPort)); var newChannel = new Channel( _profile.SSHHost, _profile.DestinationHost, (int)channel.LocalChannel, channel, local); newChannel.StartAsyncReceive(); return RemotePortForwardingReply.Accept(newChannel); } catch (Exception ex) { Debug.WriteLine(ex.StackTrace); Util.InterThreadWarning(ex.Message); return RemotePortForwardingReply.Reject( RemotePortForwardingReply.Reason.AdministrativelyProhibited, "rejected"); } }