コード例 #1
0
 public RemotePortForwardingReply OnRemotePortForwardingRequest(RemotePortForwardingRequest request, ISSHChannel channel)
 {
     // exception is not handled here.
     // caller should handle exception appropriately.
     return(_coreHandler.OnRemotePortForwardingRequest(request, channel));
 }
コード例 #2
0
 public RemotePortForwardingReply OnRemotePortForwardingRequest(RemotePortForwardingRequest request, ISSHChannel channel)
 {
     // exception is not handled here.
     // caller should handle exception appropriately.
     return _coreHandler.OnRemotePortForwardingRequest(request, channel);
 }
コード例 #3
0
ファイル: channel.cs プロジェクト: poderosaproject/poderosa
        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");
            }
        }