Esempio n. 1
0
        private void RegistLeftStatistics()
        {
            Server     server   = KCPTunnelController.Server;
            IPEndPoint localEP  = Utils.ToEndPoint(server.localaddr);
            IPEndPoint remoteEP = new IPEndPoint(
                IPAddress.Loopback,
                Utils.GetFreePort(ProtocolType.Tcp, localEP.Port + 1));

            KCPTunnelController.localaddr = remoteEP.ToString();
            Logging.Debug($"Left: localEP={localEP.ToString()}, remoteEP={remoteEP.ToString()}");
            _tcpRelay           = new TCPRelay(this, localEP, remoteEP);
            _tcpRelay.Inbound  += _tcpRelay_Inbound;
            _tcpRelay.Outbound += _tcpRelay_Outbound;
            _tcpRelay.Start();
        }
Esempio n. 2
0
 private void RelaySSUDPData(Server server)
 {
     try
     {
         string[]   localaddr_compns = server.localaddr.Split(':');
         IPEndPoint localEP          = new IPEndPoint(IPAddress.Loopback, Convert.ToInt32(localaddr_compns[1]));
         IPEndPoint remoteEP         = Utils.ToEndPoint(server.ss_server);
         _ssudpRelay = new UDPRelay(this, localEP, remoteEP);
         _ssudpRelay.Start();
     }
     catch (Exception e)
     {
         Logging.LogUsefulException(e);
     }
 }
Esempio n. 3
0
 private void RelaySSUDPData(Server server)
 {
     try
     {
         IPEndPoint localEP = Utils.ToEndPoint(server.localaddr);
         localEP = new IPEndPoint(IPAddress.Loopback, localEP.Port);
         IPEndPoint remoteEP = Utils.ToEndPoint(server.ss_server);
         _ssudpRelay = new UDPRelay(this, localEP, remoteEP);
         _ssudpRelay.Start();
     }
     catch (Exception e)
     {
         Logging.LogUsefulException(e);
     }
 }
Esempio n. 4
0
        private void RegistRightStatistics()
        {
            Server server = KCPTunnelController.Server;

            string[]   localaddr_compns = server.localaddr.Split(':');
            IPEndPoint localEP          = new IPEndPoint(
                IPAddress.Loopback,
                Utils.GetFreePort(ProtocolType.Udp, Convert.ToInt32(localaddr_compns[1]) + 1)); // Do not use same TCP port, since shadowsocks maybe send data to this port.
            IPEndPoint remoteEP = Utils.ToEndPoint(server.remoteaddr);

            KCPTunnelController.remoteaddr = localEP.ToString();
            Logging.Debug($"right: localEP={localEP.ToString()}, remoteEP={remoteEP.ToString()}");
            _udpRelay           = new UDPRelay(this, localEP, remoteEP);
            _udpRelay.Inbound  += _udpRelay_Inbound;
            _udpRelay.Outbound += _udpRelay_Outbound;
            _udpRelay.Start();
        }
        private void Start(string leftAddr, string rightAddr, bool udp)
        {
            EndPoint left  = ParseEndPoint(leftAddr);
            EndPoint right = ParseEndPoint(rightAddr);

            relay           = udp ? (IRelay) new UDPRelay(left, right) : (IRelay) new TCPRelay(left, right);
            relay.Inbound  += Relay_Inbound;
            relay.Outbound += Relay_Outbound;
            relay.Error    += Relay_Error;
            relay.Start();

            TypeComboBox.Enabled        = false;
            LeftAddressTextBox.ReadOnly = true;
            RightTextBox.ReadOnly       = true;
            StartButton.Enabled         = false;
            StopButton.Enabled          = true;

            AppendLog($"Start [{(udp ? "UDP" : "TCP")}] local: {left}, remote: {right}\n");
        }
        private void RegistLeftStatistics()
        {
            Server server = KCPTunnelController.Server;

            string[]   localaddr_compns = server.localaddr.Split(':');
            IPEndPoint localEP          = new IPEndPoint(
                string.IsNullOrEmpty(localaddr_compns[0]) ? IPAddress.Any : IPAddress.Parse(localaddr_compns[0]),
                Convert.ToInt32(localaddr_compns[1]));
            IPEndPoint remoteEP = new IPEndPoint(
                IPAddress.Loopback,
                Utils.GetFreePort(ProtocolType.Tcp, localEP.Port + 1));

            KCPTunnelController.localaddr = remoteEP.ToString();
            Logging.Debug($"Left: localEP={localEP.ToString()}, remoteEP={remoteEP.ToString()}");
            _tcpRelay           = new TCPRelay(this, localEP, remoteEP);
            _tcpRelay.Inbound  += _tcpRelay_Inbound;
            _tcpRelay.Outbound += _tcpRelay_Outbound;
            _tcpRelay.Start();
        }
        private void RegistRightStatistics()
        {
            Server server = KCPTunnelController.Server;

            string[]   localaddr_compns  = server.localaddr.Split(':');
            string[]   remoteaddr_compns = server.remoteaddr.Split(':');
            IPEndPoint localEP           = new IPEndPoint(
                IPAddress.Loopback,
                Utils.GetFreePort(ProtocolType.Udp, Convert.ToInt32(localaddr_compns[1])));
            IPEndPoint remoteEP = new IPEndPoint(
                IPAddress.Parse(remoteaddr_compns[0]),
                Convert.ToInt32(remoteaddr_compns[1]));

            KCPTunnelController.remoteaddr = localEP.ToString();
            Logging.Debug($"right: localEP={localEP.ToString()}, remoteEP={remoteEP.ToString()}");
            _udpRelay           = new UDPRelay(this, localEP, remoteEP);
            _udpRelay.Inbound  += _udpRelay_Inbound;
            _udpRelay.Outbound += _udpRelay_Outbound;
            _udpRelay.Start();
        }
        private void Start(string leftAddr, string rightAddr, bool udp, string socks5Addr, bool useProxy)
        {
            EndPoint left   = ParseEndPoint(leftAddr);
            EndPoint right  = ParseEndPoint(rightAddr);
            EndPoint socks5 = ParseEndPoint(socks5Addr);

            relay = udp ?
                    (IRelay) new UDPRelay(left, right, socks5, useProxy) :
                    (IRelay) new TCPRelay(left, right, socks5, useProxy);
            relay.Relay    += Relay_Relay;
            relay.Error    += Relay_Error;
            relay.WriteLog += Relay_WriteLog;

            relay.Start();

            TypeComboBox.Enabled        = false;
            LeftAddressTextBox.ReadOnly = true;
            RightTextBox.ReadOnly       = true;
            StartButton.Enabled         = false;
            StopButton.Enabled          = true;

            AppendLog($"Start [{(udp ? "UDP" : "TCP")}] local: {left}, remote: {right}\r\n");
        }