Ejemplo n.º 1
0
        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"));
            }
        }
Ejemplo n.º 2
0
 public virtual RemotePortForwardingReply CheckPortForwardingRequest(string remote_host, int remote_port, string originator_ip, int originator_port)
 {
     return(RemotePortForwardingReply.Reject(RemotePortForwardingReply.Reason.AdministrativelyProhibited, "rejected"));
 }