Esempio n. 1
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) && _PublicAddress != null)
                    {
                        localAddress = _PublicAddress;
                    }
                }

                e.AddServer(ServerName, new IPEndPoint(localAddress, localPort));
            }
            catch (Exception x)
            {
                x.ToConsole();
                e.Rejected = true;
            }
        }
Esempio n. 2
0
        private static void EventSink_ServerList(ServerListEventArgs e)
        {
            try
            {
                var ns = e.State;
                var s  = ns.Socket;

                var ipep = (IPEndPoint)s.LocalEndPoint;

                var localAddress = ipep.Address;
                var localPort    = ipep.Port;

                if (IsPrivateNetwork(localAddress))
                {
                    ipep = (IPEndPoint)s.RemoteEndPoint;

                    if (!IsPrivateNetwork(ipep.Address) && _PublicAddress != null)
                    {
                        localAddress = _PublicAddress;
                    }
                }

                e.AddServer(ServerName, new IPEndPoint(localAddress, localPort));
            }
            catch
            {
                e.Rejected = true;
            }
        }
Esempio n. 3
0
        private static void EventSink_ServerList(ServerListEventArgs e)
        {
            try
            {
                var ns = e.State;

                var ipep = (IPEndPoint)ns.Connection.LocalEndPoint;

                var localAddress = ipep.Address;
                var localPort    = ipep.Port;

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

                e.AddServer(ServerName, new IPEndPoint(localAddress, localPort));
            }
            catch (Exception er)
            {
                Console.WriteLine(er);
                e.Rejected = true;
            }
        }
Esempio n. 4
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));
            }
            catch
            {
                e.Rejected = true;
            }
        }
Esempio n. 5
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;
            }
        }
Esempio n. 6
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;
            }
        }
Esempio n. 7
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;
                    }
                }
                Console.WriteLine("Players connecting to IP: {0}", localAddress);
                e.AddServer(ServerName, new IPEndPoint(localAddress, localPort));
            }
            catch
            {
                e.Rejected = true;
            }
        }
Esempio n. 8
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;
                    }
                }

                // name can only be this long:
                //          "---------------"
                e.AddServer("Angel Island", new IPEndPoint(localAddress, SocketOptions.AngelIslandPort));
                //e.AddServer("Siege Perilous", new IPEndPoint(localAddress, SocketOptions.SiegePort));
                //e.AddServer("Mortalis", new IPEndPoint(localAddress, SocketOptions.MortalisPort));				// RIP - For now!
                //e.AddServer("AI Resurrection", new IPEndPoint(localAddress, SocketOptions.AIResurrectionPort));
                //e.AddServer("AI Test Center", new IPEndPoint(localAddress, SocketOptions.TestCenterPort));
                //e.AddServer("SP Test Center", new IPEndPoint(localAddress, SocketOptions.EventShardPort));
            }
            catch
            {
                e.Rejected = true;
            }
        }
Esempio n. 9
0
        private static void EventSink_ServerList(ServerListEventArgs e)
        {
            try
            {
                var ns = e.State;

                var ipep = (IPEndPoint)ns.Connection?.LocalEndPoint;
                if (ipep == null)
                {
                    return;
                }

                var localAddress = ipep.Address;
                var localPort    = ipep.Port;

                if (IsPrivateNetwork(localAddress))
                {
                    ipep = (IPEndPoint)ns.Connection.RemoteEndPoint;
                    if (ipep == null || !IsPrivateNetwork(ipep.Address) && _publicAddress != null)
                    {
                        localAddress = _publicAddress;
                    }
                }

                e.AddServer(ServerName, new IPEndPoint(localAddress, localPort));
            }
            catch (Exception er)
            {
                logger.Warning(er, "Unhandled exception at server list");
                e.Rejected = true;
            }
        }
Esempio n. 10
0
 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;
     }
 }
Esempio n. 11
0
        public static void EventSink_ServerList( ServerListEventArgs e )
        {
            try
            {
                IPAddress ipAddr;

                if ( Resolve( Address, out ipAddr ) )
                    e.AddServer( ServerName, new IPEndPoint( ipAddr, Listener.Port ) );
                else
                    e.Rejected = true;
            }
            catch
            {
                e.Rejected = true;
            }
        }
Esempio n. 12
0
        public static void EventSink_ServerList(ServerListEventArgs e)
        {
            try
            {
                IPAddress ipAddr;

                if (Resolve(Address, 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
            {
                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;
            }
        }