Esempio n. 1
0
        private void connectTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            if (connected)
            {
                return;
            }
            Saba server = ((ServerTimer)sender).Server;

            Logging.Info($"{server.server} timed out");
            remote.Close();
            RetryConnect();
        }
Esempio n. 2
0
            public UDPHandler(Socket local, Saba server, IPEndPoint localEndPoint)
            {
                _local         = local;
                _server        = server;
                _localEndPoint = localEndPoint;

                // TODO async resolving
                IPAddress ipAddress;
                bool      parsed = IPAddress.TryParse(server.server, out ipAddress);

                if (!parsed)
                {
                    IPHostEntry ipHostInfo = Dns.GetHostEntry(server.server);
                    ipAddress = ipHostInfo.AddressList[0];
                }
                _remoteEndPoint = new IPEndPoint(ipAddress, server.server_port);
                _remote         = new Socket(_remoteEndPoint.AddressFamily, SocketType.Dgram, ProtocolType.Udp);
            }
Esempio n. 3
0
        private void ConnectCallback(IAsyncResult ar)
        {
            Saba server = null;

            if (closed)
            {
                return;
            }
            try
            {
                ServerTimer timer = (ServerTimer)ar.AsyncState;
                server         = timer.Server;
                timer.Elapsed -= connectTimer_Elapsed;
                timer.Enabled  = false;
                timer.Dispose();

                // Complete the connection.
                remote.EndConnect(ar);

                connected = true;

                Logging.Debug($"Socket connected to {remote.RemoteEndPoint}");

                var latency = DateTime.Now - _startConnectTime;
                tcprelay.UpdateLatency(server, latency);
                StartPipe();
            }
            catch (ArgumentException)
            {
            }
            catch (Exception e)
            {
                Logging.LogUsefulException(e);
                RetryConnect();
            }
        }
Esempio n. 4
0
 public void UpdateLatency(Saba server, TimeSpan latency)
 {
 }
Esempio n. 5
0
 public void UpdateOutboundCounter(Saba server, long n)
 {
 }
Esempio n. 6
0
 public TCPRelay(Saba server)
 {
     this.server    = server;
     Handlers       = new HashSet <TCPHandler>();
     _lastSweepTime = DateTime.Now;
 }
Esempio n. 7
0
 public UDPRelay(Saba server)
 {
     this._cache  = new LRUCache <IPEndPoint, UDPHandler>(512); // todo: choose a smart number
     this._server = server;
 }