예제 #1
0
 public override void Connecting(IServer server, ConnectingEventArgs e)
 {
     if (server.Count > ServerConfig.MaxConnections)
     {
         e.Cancel = true;
     }
 }
예제 #2
0
파일: MyIMClient.cs 프로젝트: TonyPod/MyIC
 protected static void OnConnecting(ConnectingEventArgs e)
 {
     if (Connecting != null)
     {
         Connecting(e);
     }
 }
예제 #3
0
 public virtual void Connecting(IServer server, ConnectingEventArgs e)
 {
     if (server.EnableLog(LogType.Info))
     {
         server.Log(LogType.Info, null, "connect from {0}", e.Socket.RemoteEndPoint);
     }
 }
예제 #4
0
        public override void Connecting(IServer server, ConnectingEventArgs e)
        {
            if (server.Count > Options.MaxConnections)
            {
                e.Cancel = true;
                if (EnableLog(LogType.Warring))
                {
                    Log(LogType.Warring, $"HTTP ${e.Socket.RemoteEndPoint} out of max connections!");
                }
            }
            IPEndPoint ipPoint = (IPEndPoint)e.Socket.RemoteEndPoint;

            if (!IPv4Tables.Verify(ipPoint.Address))
            {
                e.Cancel = true;
                if (EnableLog(LogType.Warring))
                {
                    Log(LogType.Warring, $"HTTP ${e.Socket.RemoteEndPoint} IPv4 tables verify no permission!");
                }
            }
            if (Options.IPRpsLimit > 0)
            {
                string ip   = ((IPEndPoint)e.Socket.RemoteEndPoint).Address.ToString();
                var    item = mIPLimit.GetItem(ip);
                if (item != null)
                {
                    if (!item.Enabled)
                    {
                        e.Cancel = true;
                    }
                }
            }
            HttpConnecting?.Invoke(this, e);
            e.Socket.NoDelay = true;
        }
예제 #5
0
 public override void Connecting(IServer server, ConnectingEventArgs e)
 {
     if (server.Count > Options.MaxConnections)
     {
         e.Cancel = true;
     }
     e.Socket.NoDelay = true;
 }
예제 #6
0
파일: XRPCServer.cs 프로젝트: lanicon/XRPC
 public override void Connecting(IServer server, ConnectingEventArgs e)
 {
     if (server.Count > ServerOptions.MaxConnections)
     {
         e.Cancel = true;
         if (EnableLog(LogType.Warring))
         {
             Log(LogType.Warring, $"XRPC Maximum online limit,{e.Socket.RemoteEndPoint} closed!");
         }
     }
 }
예제 #7
0
        private async void LobbyClient_Connecting(object sender, ConnectingEventArgs e)
        {
            try {
                OnPropertyChanged(nameof(ConnectionStatus));

                await Dispatcher.InvokeAsync(() => {
                    ProfileTab.IsEnabled = false;
                });
            } catch (Exception ex) {
                Log.Error($"{nameof(LobbyClient_Connecting)}", ex);
            }
        }
예제 #8
0
 private void OnConnecting(ConnectingEventArgs e)
 {
     try
     {
         if (Handler != null)
         {
             Handler.Connecting(this, e);
         }
     }
     catch (Exception e_)
     {
         Error(e_, null, "Server session connecting process error!");
     }
 }
예제 #9
0
        /// <inheritdoc cref="API.Network.OnConnecting(object, ConnectingEventArgs)"/>
        public void OnConnecting(object _, ConnectingEventArgs ev)
        {
            if (!IPAddress.TryParse(Instance.Config?.Bot?.IPAddress, out IPAddress ipAddress))
            {
                Log.Error($"[NET] {string.Format(Language.InvalidIPAddress, Instance.Config?.Bot?.IPAddress)}");
                return;
            }

            ev.IPAddress            = ipAddress;
            ev.Port                 = Instance.Config.Bot.Port;
            ev.ReconnectionInterval = TimeSpan.FromSeconds(Instance.Config.Bot.ReconnectionInterval);

            Log.Warn($"[NET] {string.Format(Language.ConnectingTo, ev.IPAddress, ev.Port)}");
        }
예제 #10
0
파일: Daemon.cs 프로젝트: bhbk/fm3na7zy
        private void FsUser_Connecting(object sender, ConnectingEventArgs e)
        {
            /*
             * https://www.rebex.net/file-server/features/events.aspx#connecting
             */
            try
            {
                var callPath = $"{MethodBase.GetCurrentMethod().DeclaringType.Name}.{MethodBase.GetCurrentMethod().Name}";

                Log.Information($"'{callPath}' from {e.ClientEndPoint}");

                e.Accept = true;
            }
            catch (Exception ex)
            {
                Log.Error(ex.ToString());
            }
        }
예제 #11
0
        private async Task Update(CancellationToken cancellationToken)
        {
            while (true)
            {
                try
                {
                    ConnectingEventArgs ev = new ConnectingEventArgs(IPEndPoint.Address, (ushort)IPEndPoint.Port, ReconnectionInterval);

                    OnConnecting(this, ev);

                    IPEndPoint.Address   = ev.IPAddress;
                    IPEndPoint.Port      = ev.Port;
                    ReconnectionInterval = ev.ReconnectionInterval;

                    TcpClient = new TcpClient();

                    await TcpClient.ConnectAsync(IPEndPoint.Address, IPEndPoint.Port);

                    OnConnected(this, System.EventArgs.Empty);

                    await ReceiveAsync(cancellationToken);
                }
                catch (IOException ioException)
                {
                    OnReceivingError(this, new ReceivingErrorEventArgs(ioException));
                }
                catch (SocketException socketException) when(socketException.ErrorCode == 10061)
                {
                    OnConnectingError(this, new ConnectingErrorEventArgs(socketException));
                }
                catch (Exception exception) when(exception.GetType() != typeof(OperationCanceledException))
                {
                    OnUpdatingConnectionError(this, new UpdatingConnectionErrorEventArgs(exception));
                }

                cancellationToken.ThrowIfCancellationRequested();

                await Task.Delay(ReconnectionInterval, cancellationToken);
            }
        }
예제 #12
0
        public override void Connecting(IServer server, ConnectingEventArgs e)
        {
            if (server.Count > Options.MaxConnections)
            {
                e.Cancel = true;
                if (EnableLog(LogType.Warring))
                {
                    Log(LogType.Warring, $"HTTP ${e.Socket.RemoteEndPoint} out of max connections!");
                }
            }
            IPEndPoint ipPoint = (IPEndPoint)e.Socket.RemoteEndPoint;

            if (!IPv4Tables.Verify(ipPoint.Address))
            {
                e.Cancel = true;
                if (EnableLog(LogType.Warring))
                {
                    Log(LogType.Warring, $"HTTP ${e.Socket.RemoteEndPoint} IPv4 tables verify no permission!");
                }
            }
            e.Socket.NoDelay = true;
        }
예제 #13
0
 public override void Connecting(IServer server, ConnectingEventArgs e)
 {
     Logger.Trace(() => $"远程开始连接:{e.Socket.RemoteEndPoint}");
     base.Connecting(server, e);
 }
예제 #14
0
 /// <summary>
 /// Called before the network connects to the server.
 /// </summary>
 /// <param name="sender">The sender instance.</param>
 /// <param name="ev">The <see cref="ConnectingEventArgs"/> instance.</param>
 protected virtual void OnConnecting(object sender, ConnectingEventArgs ev) => Connecting?.Invoke(sender, ev);
예제 #15
0
 public override void Connecting(IServer server, ConnectingEventArgs e)
 {
     Console.WriteLine("Connecting");
 }
예제 #16
0
 public void Connecting(IServer server, ConnectingEventArgs e)
 {
     Loger.Process(LogType.INFO, "connect from {0}", e.Socket.RemoteEndPoint);
 }
예제 #17
0
 public override void Connecting(IServer server, ConnectingEventArgs e)
 {
 }
예제 #18
0
 private static void MServer_Connecting(object sender, ConnectingEventArgs e)
 {
     // This test server is only for local access
     e.Cancel = !IPAddress.IsLoopback((e.Client.Client.RemoteEndPoint as IPEndPoint).Address);
 }
예제 #19
0
 public void Connecting(IServer server, ConnectingEventArgs e)
 {
 }