Inheritance: System.EventArgs
		private static void EventSink_ServerList( ServerListEventArgs e )
		{
			try
			{
				NetState ns = e.State;
				Socket s = ns.Socket;

				IPEndPoint ipep = (IPEndPoint)s.LocalEndPoint;

				IPAddress localAddress = ipep.Address;
				int localPort = ipep.Port;

				if ( IsPrivateNetwork( localAddress ) ) {
					ipep = (IPEndPoint)s.RemoteEndPoint;
					if ( !IsPrivateNetwork( ipep.Address ) && m_PublicAddress != null )
						localAddress = m_PublicAddress;
				}

				e.AddServer( ServerName, new IPEndPoint( localAddress, localPort ) );
			}
			catch
			{
				e.Rejected = true;
			}
		}
Exemple #2
0
        private static void EventSink_ServerList( ServerListEventArgs e )
        {
            try
            {
                NetState ns = e.State;
                Socket s = ns.Socket;

                IPEndPoint ipep = (IPEndPoint)s.LocalEndPoint;

                IPAddress localAddress = ipep.Address;
                int localPort = ipep.Port;

                if ( IsPrivateNetwork( localAddress ) ) {
                    ipep = (IPEndPoint)s.RemoteEndPoint;
                    if ( !IsPrivateNetwork( ipep.Address ) && m_PublicAddress != null )
                        localAddress = m_PublicAddress;
                }

                e.AddServer( ServerName, new IPEndPoint( localAddress, localPort ) );

                /*IPAddress testAddress;
                IPAddress.TryParse("127.0.0.1", out testAddress);
                e.AddServer("Test Center", new IPEndPoint(testAddress, 2594));*/
            }
            catch
            {
                e.Rejected = true;
            }
        }
 public static void InvokeServerList(ServerListEventArgs e)
 {
     if (ServerList != null)
     {
         ServerList(e);
     }
 }
Exemple #4
0
 public static void InvokeServerList(ServerListEventArgs e)
 {
     if (EventSink.ServerList != null)
     {
         EventSink.ServerList.Invoke(e);
     }
 }
        public static void EventSink_ServerList(ServerListEventArgs e)
        {
            foreach (Config.GameServer gs in Core.Config.GameServers) {
                if (gs.Query && gs.Optional &&
                    ServerQueryTimer.GetStatus(gs) == null)
                    continue;

                e.AddServer(gs.Name, gs.Address);
            }
        }
        public static void EventSink_ServerList(ServerListEventArgs e)
        {
            GameServerListConfig gsl = Core.Config.GameServerListConfig;
            if (gsl == null) {
                e.Rejected = true;
                return;
            }

            foreach (GameServerConfig gs in gsl.GameServers)
                e.AddServer(gs.Name, gs.Address);
        }
Exemple #7
0
        public static void EventSink_ServerList(ServerListEventArgs e)
        {
            foreach (Config.GameServer gs in Core.Config.GameServers)
            {
                if (gs.Query && gs.Optional &&
                    ServerQueryTimer.GetStatus(gs) == null)
                {
                    continue;
                }

                e.AddServer(gs.Name, gs.Address);
            }
        }
        public static void EventSink_ServerList(ServerListEventArgs e)
        {
            GameServerListConfig gsl = Core.Config.GameServerListConfig;

            if (gsl == null)
            {
                e.Rejected = true;
                return;
            }

            foreach (GameServerConfig gs in gsl.GameServers)
            {
                e.AddServer(gs.Name, gs.Address);
            }
        }
		public static void EventSink_ServerList( ServerListEventArgs e )
		{
			try
			{
				IPAddress ipAddr;

				if ( Resolve( Address != null && !IsLocalMachine( e.State ) ? Address : Dns.GetHostName(), out ipAddr ) )
					e.AddServer( ServerName, new IPEndPoint( ipAddr, Listener.Port ) );
				else
					e.Rejected = true;
			}
			catch
			{
				e.Rejected = true;
			}
		}
 public static void EventSink_ServerList( ServerListEventArgs e )
 {
     try
     {
         if (Core.Config.GameServers.Count == 0) {
             e.AddServer( ServerName, (IPEndPoint)e.State.Socket.LocalEndPoint );
         } else {
             foreach (Config.GameServer gs in Core.Config.GameServers)
                 e.AddServer(gs.Name, gs.Address);
         }
     }
     catch (Exception ex)
     {
         log.Fatal(ex);
         e.Rejected = true;
     }
 }
 public static void InvokeServerList( ServerListEventArgs e )
 {
     if ( ServerList != null )
         ServerList( e );
 }
 public static void InvokeServerList(ServerListEventArgs e) => ServerList?.Invoke(e);
Exemple #13
0
        // ==================================================================================
        // Calculates what server IP to use
        // ==================================================================================
        public static IPAddress FindMachineIP( ServerListEventArgs e )
        {
            // ----------------------------------------------------
            // Find the IP of the connecting user
            // ----------------------------------------------------
            Socket sock = e.State.Socket;
            IPAddress theirAddress = ((IPEndPoint)sock.RemoteEndPoint).Address;
            IPAddress serverAddress;

            // ----------------------------------------------------
            // Is it Loopback?
            // ----------------------------------------------------
            if ( IPAddress.IsLoopback( theirAddress ) )
            {
                return IPAddress.Parse( "127.0.0.1" );
            }

            // ----------------------------------------------------
            // Local
            // ----------------------------------------------------
            UInt32 uint32Address = StringIPToUInt32IP(theirAddress.ToString());
            for (UInt32 LocalLanIPRangesLoop = 0 ; LocalLanIPRangesLoop < LocalLanIPRangesCount; LocalLanIPRangesLoop++)
            {
                if ( (LocalLanIPRanges[LocalLanIPRangesLoop].RangeFrom <= uint32Address) && (LocalLanIPRanges[LocalLanIPRangesLoop].RangeTo >= uint32Address) )
                {
                    Resolve(Dns.GetHostName(), out serverAddress);

                    Console.WriteLine("Player is reconnecting to " + serverAddress.ToString());
                    return serverAddress;
                }
            }

            // ----------------------------------------------------
            // Internet addresses
            // ----------------------------------------------------
            if (Address!=null)
            {
                Resolve(Address, out serverAddress);
            } else {
                Resolve(Dns.GetHostName(), out serverAddress);
            }

            Console.WriteLine("Player is reconnecting to " + serverAddress.ToString());
            return serverAddress;
        }
Exemple #14
0
        // ==================================================================================
        // The serverlist event
        // ==================================================================================
        public static void EventSink_ServerList( ServerListEventArgs e )
        {
            try
            {

                // ----------------------------------------------------
                // Lets find internet ip
                // ----------------------------------------------------
                DetectInternetIP();

                // ----------------------------------------------------
                // Find the server ip to use for this user
                // ----------------------------------------------------
                IPAddress ipAddr = FindMachineIP(e);

                // ----------------------------------------------------
                // Send serverlist
                // ----------------------------------------------------
                if (ipAddr != null)
                {
                    e.AddServer(ServerName, new IPEndPoint(ipAddr, 2593 ));//  Place the port that you are using here.
                } else {
                    e.Rejected = true;
                }
            }
            catch
            {
                e.Rejected = true;
            }
        }
Exemple #15
0
		public static void InvokeServerList(ServerListEventArgs e)
		{
			if (ServerList != null)
			{
				foreach (ServerListEventHandler currentDelegate in ServerList.GetInvocationList())
				{
					try
					{
						currentDelegate.Invoke(e);
					}
					catch (Exception ex)
					{
						// Log an exception
						EventSink.InvokeLogException(new LogExceptionEventArgs(ex));
					}
				}
			}
		}