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 = "12.34.56.78";
*
* If you need to resolve a DNS host name, you can do that too:
* private const string Address = "shard.host.com";
*/
public const string Address = "216.160.107.16";
public const string ServerName = "Shard's Name";
public static void Initialize()
{
Listener.Port = 2593;
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 = true;
}
catch
{
e.Rejected = true;
}
}
public static bool Resolve( string addr, out IPAddress outValue )
{
try
{
outValue = IPAddress.Parse( addr );
return true;
}
catch
{
try
{
IPHostEntry iphe = Dns.Resolve( addr );
if ( iphe.AddressList.Length > 0 )
{
outValue = iphe.AddressList[iphe.AddressList.Length - 1];
return true;
}
}
catch
{
}
}
outValue = IPAddress.None;
return false;
}
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.Resolve( Dns.GetHostName() );
for ( int i = 0; !contains && i < iphe.AddressList.Length; ++i )
contains = theirAddress.Equals( iphe.AddressList[i] );
return contains;
}
}
}
Burdaki kodu bir txt dosyasına yazdıktan sonra kaydedin ve adını serverlist.cs olarak değiştirin ve Scripts/misc klasöründe serverlist.cs dosyası ile değiştirin.. Gerekli ayarlamaları yapın (ismini ve portunu kendi istediğiniz şekilde ayarlayın.)2007-07-14 22:10
2006-08-21 15:00
2005-03-21 16:20
2004-06-24 17:01
2006-08-17 20:11
Sphere Scripting 3 gün önce
Counter-Strike 1 hafta önce
Ultima Online 2 hafta önce
Ultima Online 2 hafta önce
Escape From Tarkov 1 ay önce
2023-08-05 04:49
2023-08-04 21:01
2023-08-04 15:22
2017-06-30 17:45
2017-06-24 23:21
2017-06-22 15:11
2017-06-18 22:34
2017-06-03 04:18
Yorumlar (2)
serverlist'e bi çözüm bulsak harika olacak :( Prof. shard kurma niyetinde değilim. 3-5 arkadaş beraber takılabileceğimiz birşey olsun istedik. Lütfen serverlist.cs'e bir el atalım
Serverlist.cs hata verio :S