예제 #1
0
        /// <summary>
        /// Sends a buffer to the locally connected client
        /// </summary>
        /// <param name="buffer"></param>
        /// <returns></returns>
        public int SendTo(ETelnetProxySession eClientType, string str)
        {
            byte[] buffer = ASCIIEncoding.ASCII.GetBytes(str);
            int    size   = -1;

            switch (eClientType)
            {
            case ETelnetProxySession.Client:
                size = SendTo(this.ClientSession, buffer);
                break;

            case ETelnetProxySession.Remote:
                size = SendTo(this.RemoteSession, buffer);
                break;

            case ETelnetProxySession.Tap:
                size = SendTo(this.TapSession, buffer);
                break;

            default:
                throw new Exception("TPS - SendTo, ETelnetProxySession out of range");
            }

            if (size == buffer.Length)
            {
                return(size);
            }

            Debug.WriteLine("Failed to write a buffer to the " + eClientType.ToString() + " client", this);
            return(size);
        }
예제 #2
0
        /// <summary>
        /// remove the remote or tap session from the proxy session
        /// </summary>
        /// <param name="eTelnetProxySession"></param>
        /// <param name="session"></param>
        /// <returns></returns>
        public void RemoveSession(ETelnetProxySession eTelnetProxySession)
        {
            switch (eTelnetProxySession)
            {
            case ETelnetProxySession.Client:
                if (this.client == null)
                {
                    return;
                }
                DisconnectSession(eTelnetProxySession);
                this.client = null;
                break;

            case ETelnetProxySession.Remote:
                if (this.remote == null)
                {
                    return;
                }
                DisconnectSession(eTelnetProxySession);
                this.remote = null;
                break;

            case ETelnetProxySession.Tap:
                if (this.tap == null)
                {
                    return;
                }
                DisconnectSession(eTelnetProxySession);
                this.tap = null;
                break;
            }
        }
예제 #3
0
        public void DisconnectSession(ETelnetProxySession eClientType)
        {
            switch (eClientType)
            {
            case ETelnetProxySession.Client:
                this.ClientSession.Receive_Event    -= RcvFromClientSession_EventHandler;
                this.ClientSession.Disconnect_Event -= ClientSessionDisconnect_EventHandler;
                Disconnect(this.ClientSession);
                break;

            case ETelnetProxySession.Remote:
                this.ClientSession.Receive_Event    -= RcvFromRemoteSession_EventHandler;
                this.ClientSession.Disconnect_Event -= RemoteSessionDisconnect_EventHandler;
                Disconnect(this.RemoteSession);
                break;

            case ETelnetProxySession.Tap:
                this.ClientSession.Receive_Event    -= RcvFromTapSession_EventHandler;
                this.ClientSession.Disconnect_Event -= TapSessionDisconnect_EventHandler;
                Disconnect(this.TapSession);
                break;

            default:
                throw new Exception("TPS - SendTo, ETelnetProxySession out of range");
            }
        }
예제 #4
0
        /// <summary>
        /// Adds the remote or tap session to the proxy session
        /// </summary>
        /// <param name="eTelnetProxySession"></param>
        /// <param name="session"></param>
        /// <returns></returns>
        public void AddSession(ETelnetProxySession eTelnetProxySession, ITelnetSessionControl session)
        {
            switch (eTelnetProxySession)
            {
            case ETelnetProxySession.Remote:
                this.remote = session;
                this.RemoteSession.BeginRead();
                this.RemoteSession.Receive_Event    += RcvFromRemoteSession_EventHandler;
                this.RemoteSession.Disconnect_Event += RemoteSessionDisconnect_EventHandler;
                break;

            case ETelnetProxySession.Tap:
                this.tap = session;
                this.TapSession.BeginRead();
                this.TapSession.Receive_Event    += RcvFromTapSession_EventHandler;
                this.TapSession.Disconnect_Event += TapSessionDisconnect_EventHandler;
                break;
            }
        }
        private Match BlockUntilAnswered(ITelnetProxySessionControl newProxySession, ETelnetProxySession eTelnetProxySession,
                                         string p1, string csvRegex_new, int p2, int p3)
        {
            switch (eTelnetProxySession)
            {
            case ETelnetProxySession.Client:
                return(BlockUntilAnswered(newProxySession.ClientSession, p1, csvRegex_new, p2, p3));

            case ETelnetProxySession.Remote:
                return(BlockUntilAnswered(newProxySession.RemoteSession, p1, csvRegex_new, p2, p3));

            case ETelnetProxySession.Tap:
                return(BlockUntilAnswered(newProxySession.TapSession, p1, csvRegex_new, p2, p3));

            default:
                Debug.WriteLine("Bad switch Block Until Answered");
                break;
            }
            return(Match.Empty);
        }