View Full Version: router+rézo

RunUO.FR Support > Tutorial en Français > router+rézo


Title: router+rézo


yakata - August 26, 2004 09:38 PM (GMT)
lut je n' arrive pas a me connect a mon shard en rézo ni depuis le net g un router.
mon ip externe est: 84.97.96.65
mon ip réso: 192.168.1.112
plz help ! voici ce ke g fait
CODE
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 =;
  *
  * 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 = "192.168.1.112";
  *
  * 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 = "84.97.96.65";

 public const string ServerName = "the new world";

 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;
 }
}
}


slade15 - August 26, 2004 10:15 PM (GMT)
chercher un peut sur le forum il y a plusieur topic traitant ce sujet

Nezumi - August 26, 2004 10:41 PM (GMT)
de plus le post est mal placé ^_^




Hosted for free by InvisionFree