good to all colleagues.


I need your help I try to set the public server using NO-IP, I can not do it since I modify the ServerList and there is no way to achieve it.


using System;
using System.Net;
using System.Net.Sockets;
using Server;
using Server.Network;


namespace Server.Misc
{
public class ServerList
{
/* Address:
*
* The default setting, a value of 'null', will attempt to detect your IP address automatically:
* private const string Address = null;
*
* This detection, however, does not work for servers behind routers. If you're running behind a router, put in your IP:
* private const string Address = "68.93.xxx.xxx";
*
* If you need to resolve a DNS host name, you can do that too:
* private const string Address = "127.0.0.1";
*/

private const string Address = "uotninternacional.servegame.com";

public static readonly string ServerName = "Terra Nova";

public static readonly bool AutoDetect = true;

public static void Initialize()
{
Listener.Port = 2593;
if ( Address == null )

EventSink.ServerList += new ServerListEventHandler( EventSink_ServerList );
}

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 = false;
}
catch
{
e.Rejected = false;
}
}

public static bool Resolve( string addr, out IPAddress outValue )
{

if ( IPAddress.TryParse( addr, out outValue ) )
return true;

try
{
IPHostEntry iphe = Dns.GetHostEntry( addr );

if ( iphe.AddressList.Length > 0 )
{
outValue = iphe.AddressList[iphe.AddressList.Length - 1];
return true;
}
}
catch
{
}

outValue = IPAddress.None;
return true;
}

private static bool IsLocalMachine( NetState state )
{
Socket sock = state.Socket;

IPAddress theirAddress = ((IPEndPoint)sock.RemoteEndPoint).Address;

if ( IPAddress.IsLoopback( theirAddress ) )
return true;

bool contains = false;

IPHostEntry iphe = Dns.GetHostEntry( Dns.GetHostName() );

for ( int i = 0; !contains && i < iphe.AddressList.Length; ++i )
contains = theirAddress.Equals( iphe.AddressList );

return contains;
}
}
}
 
C#:
using System;
using System.Net;
using System.Net.Sockets;
using Server;
using Server.Network;

namespace Server.Misc
{
    public class ServerList
    {
        /* Address:
        *
        * The default setting, a value of 'null', will attempt to detect your IP address automatically:
        * private const string Address = null;
        *
        * This detection, however, does not work for servers behind routers. If you're running behind a router, put in your IP:
        * private const string Address = "68.93.xxx.xxx";
        *
        * If you need to resolve a DNS host name, you can do that too:
        * private const string Address = "127.0.0.1";
        */

        private const string Address = "uotninternacional.servegame.com";
        public static readonly string ServerName = "Terra Nova";
        public static readonly bool AutoDetect = true;

        public static void Initialize()
        {
            Listener.Port = 2593;

            if ( Address == null )
            EventSink.ServerList += new ServerListEventHandler( EventSink_ServerList );
        }

        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 = false;
            }
            catch
            {
                e.Rejected = false;
            }
        }

        public static bool Resolve( string addr, out IPAddress outValue )
        {
            if ( IPAddress.TryParse( addr, out outValue ) )
                return true;
            try
            {
                IPHostEntry iphe = Dns.GetHostEntry( addr );
                if ( iphe.AddressList.Length > 0 )
                {
                    outValue = iphe.AddressList[iphe.AddressList.Length - 1];
                    return true;
                }
            }
            catch
            {
            }

            outValue = IPAddress.None;
        
            return true;
        }

        private static bool IsLocalMachine( NetState state )
        {
            Socket sock = state.Socket;
            IPAddress theirAddress = ((IPEndPoint)sock.RemoteEndPoint).Address;
        
            if ( IPAddress.IsLoopback( theirAddress ) )
                return true;

            bool contains = false;
            IPHostEntry iphe = Dns.GetHostEntry( Dns.GetHostName() );

            for ( int i = 0; !contains && i < iphe.AddressList.Length; ++i )
                contains = theirAddress.Equals( iphe.AddressList );

            return contains;
        }
    }
}
You don't set the public IP address in ServerList.cs
You should be able to just use the config file. " Server.cfg "
Speaking of which, if you did modify the ServerList.cs and not the Server.cfg config
than the config file may override what's stated in the c# file

There's probably legitimately no way to do that. I don't even understand what's NO-IP.
According to their description:
"The No-IP Free Dynamic DNS service takes your dynamic IP address and makes it act as though it is static by pointing a static hostname to it and checking every 5 minutes for changes to your IP address. If your IP address changes, our Dynamic Update Client updates your hostname with the current IP address."

So in the event your IP changes, your NO-IP static hostname re-associates to your now different IP address.
How does NO-IP do that though under the hood, maybe what's displayed to the consumer isn't what's occurring behind closed doors,
and the ServerList.cs isn't getting updated with whatever NO-IP is actually doing.
And because the ServerList is assigning values according to your IP/DNS and not the services provided by NO-IP, ie: the static hostname --
 
Last edited:
Back