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(); }
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); }
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(); } }
public void UpdateLatency(Saba server, TimeSpan latency) { }
public void UpdateOutboundCounter(Saba server, long n) { }
public TCPRelay(Saba server) { this.server = server; Handlers = new HashSet <TCPHandler>(); _lastSweepTime = DateTime.Now; }
public UDPRelay(Saba server) { this._cache = new LRUCache <IPEndPoint, UDPHandler>(512); // todo: choose a smart number this._server = server; }