RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Two shards/one server listing

Status
Not open for further replies.

Jason

Wanderer
HellRazor said:
Don't let Jason bother you, flames like that are typical of him. I'm surprised the mods haven't banned the guy already.

:lol:

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 = 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 = "123.123.123.123";

 public const string LocalServerAddress = "123.123.123.123";

 public const string ServerName = "Shard Name";

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

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

 public static void EventSink_ServerList( ServerListEventArgs e )
 {
  try
  {
   IPAddress ipAddr;
   IPAddress LocalAddress = IPAddress.Parse( LocalServerAddress );
   

   if ( Resolve( Address != null && !IsLocalMachine( e.State ) ? Address : Dns.GetHostName(), out ipAddr ) )
   {
e.AddServer( ServerName, new IPEndPoint( ipAddr, Listener.Port ) );
e.AddServer( "Local Server", new IPEndPoint( LocalAddress, ( Listener.Port + 1 ) ) );
   }
   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;
 }
}
}

Works just fine for me.

1) I have not flamed anyone
2) I have said buggy code is unwanted.
3) Please show me a reason one reason why I should be banned and I will leave.
4) Please post where you have given help intead of telling the people who help.

I don't think I have done anything wrong, If I have I am sure the moderators would have told me.

This code assumes your using the same computer just running two instances of runuo as two seperate shards.

Krrios has not said its possible to login to two different servers ( two different ips ) form the same ServerList.cs if it was then I am sure UO Gamers would have done it when they had their small Faction Test a few months ago.

I am not perfect, I don't think its right for somebody who never helps anyone to want somebody who does to be banned for being open about how he feels about people posting buggy code.

I am polite, I tell people exactly what I need to help them, and sometimes people are difficult about doing that.

I tell people when they break the rules, so they don't waste their time replying to themselfs over and over.

Plus I see other people doing exact samething so you going to ban those people too? I see people giving bad advice, I think people like GoldDraco who is very rude to me, who has been proven ( recently ) regarding a override to e method TO BE WRONG should be banned for BEING WRONG.

But that won't happen and there is really no reason to ban me because I am right now is there?

( right) when giving advice and support.

I am human, I am not always right, However draco has been wrong several times, and is known to post code he didn't write from scratch, which is another thing I will tell people not to do. If I work hard on a script, and other people work hard on a script, who gives draco the right to change it, update it, and repost and not giving credit to the original author for his idea.

I am not a credit whore, I believe in giving credit for the work people do, thats all I would do. Credit is = posting on this forum, having your name attached to the post with the script. Thats where credit ends for me, I hate copyright lines and I would never use them, and you won't ever see me using them.

Before anyone says I don't submit scripts, your right I don't because I see how people are about scripts people I know have written and how they basicly have gone crazy because of the complete stupity of some people.

So I am not going to post pointless scripts, unless I think of a good project, I am not going to post anything. If you think thats wrong, well I know what I can, you would be shocked in my real skill.
 

Thraxus

Sorceror
Jason said:
Works just fine for me.
With all due respect, while that code you posted DOES display both shards on the server list as desired, it DOES NOT enable you to be able to successfully log into the second shard. The second shard still responds with the "Invalid client detected: Disconnecting" error.

While the code will_man posted might be "crap", (that's not my opinion, but I do not believe myself qualified to either support or refute your claim of its quality) it does accomplish exactly what everyone here has been asking for, which is a way to allow two RunUO shards, both running on the same server, to be accessed from one server list generated by the 'primary' shard.

I'm not questioning your intentions or motives regarding your replies in this thread, nor your level of C# knowledge, which is certainly far more extensive than my own. The reason some people dislike you is solely because of the way you present yourself. Almost everything you post is written in a way that seems to imply that you believe everyone else here should know as much about scripting as you do.

For example, instead of just denouncing will_man's script as "crap", why not elaborate on what's wrong with it and why its not a good idea to use it? What was constructive about that comment? You left a group of people who are admittedly amateurs at C# and RunUO wondering what exactly was wrong with it, especially since it gave them exactly the functionality they were asking for in the first place. Not only that, but you came across as arrogant and condescending, which just contributes to the reputation you seem to be developing.

I personally don't have a problem with you, and I hope you don't have one with me after reading this. I think someone of your apparent level of skill is a valuable resource to this community, however the means with which you present yourself at times is nothing short of disheartening to those who are just getting started and trying to learn.

With that said, I don't agree with the comment that you should be banned. That wouldn't accomplish anything positive, and anyone that feels that way would likely be better served just to ignore your posts instead of lobbying for your removal from the forums.
 

will_man

Sorceror
Jason said:
:lol:


This code assumes your using the same computer just running two instances of runuo as two seperate shards.

Krrios has not said its possible to login to two different servers ( two different ips ) form the same ServerList.cs if it was then I am sure UO Gamers would have done it when they had their small Faction Test a few months ago.

i know i edited your reply, but this ( and the code ) is the only valid bit, mabye my former posts did not quite communicate what i found. Using that script will enable to connect to different IPs, and using RUNUO RC1.0 even on the same IP you will get a error, that is what the script i posted is for, if you are running RC1.0 and NOT getting this error, i would love to know how you did it! That is all i wanted to tell people, and for some reason you thought of it as:


Jason said:
:
will don't post crap code like that.

sorry i dont see whats so wrong with it? It works on the latest version of RunUO and stops people getting errors?!?!

And as for your other comments, yeah everyone gets things wrong, and gives bad advise at some point, but when people are trying to help, there is no need to make comments like that.

Anyway, the question to the post is answered, yes it is possible using Jasons Serverlist changes for MOST versions of RunUO and using that script i posted you can get it to work with the versions that Jasons Mods arnt enough for, etc etc. ( You will still need both Jasons serverlist mods, and the script i posted to do it ).

Think thats the end of Topic ( other than making it autoaccount :), but that shouldnt be too difficult ).
 

Jason

Wanderer
There should be no reason that shouldn't have worked.

Perhaps I miss understood what UO Gamers did during their Faction Shard test months ago.
 

Thraxus

Sorceror
Jason said:
There should be no reason that shouldn't have worked.
I agree with you, but for some reason it does not. Using both the ServerList.cs you posted in combination with the script will_man posted (whether its crap or not) accomplishes exactly the result this thread was about. I'm not sure exactly what possible issues could arise from using will_man's script, but if you'd like to elaborate on the concerns you have with it, I'd certainly appreciate your time in doing so.

Jason said:
Perhaps I miss understood what UO Gamers did during their Faction Shard test months ago.
Its a shame that most of your critics will never remember you saying this when they're busy flaming you. You can't possibly be as bad as people make you out to be, and I think you'd be surprised how much your rep would improve if people saw more of this kind of statement from you.

We're all wrong sometimes, and there's nothing wrong with that. The problem is that some people don't believe you're capable of admitting it. ;)
 

will_man

Sorceror
Well as you saw in there there is a Security ID, i *think* when you are passed from one server to another you have a different Security ID, so it throws you off ( hence the error ) i dunno, cos i got most of this script from another thread, if i were you i would put account validation ( and the anti hacking thing ) in here as well to stop people using there OWN serverlist configured to your shard to brute force into your shard. That is what i was talking about, it removes the protection that stops cross sharding, and without access to Core data i dont think anyone could fix it so u have the Security ID being used AND have access :/.

And i would really like to know why that script is thought of as crap :p
 

Thraxus

Sorceror
Ah well.. I pity the individual who has nothing better to do with their life than try to gain access to my shard.. especially one only being used as a test center. :rolleyes:
 

will_man

Sorceror
Thraxus said:
Ah well.. I pity the individual who has nothing better to do with their life than try to gain access to my shard.. especially one only being used as a test center. :rolleyes:

lol yeah, its not like ppl would have two PUBLISHED shards :)
 

valarnin

Wanderer
Attempt

Okay this is my first script submission ever, so flame me if need be.
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 = 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 = "**.**.**.**";  //Server's IP address

		public const string ServerName = "*******";  //Server 1's Name

		public const string ServerName2 = "*******";  //Server 2's Name

		public static void Initialize()
		{
			Listener.Port = 2593;  //Server 1's Port

			Listener.Port2 = 2592;  //Server 2's Port

			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 ) );
					e.AddServer( ServerName2, new IPEndPoint( ipAddr, Listener.Port2 ) );
				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;
		}
	}
}
 

roadmaster

Sorceror
Thank you for your help Jason, once you posted your script and i compared it to mine i was able to see why my ServerList was not working right.

without the example that your script gave i doubt i would have figured it out. At least not for some time, after all i only started teaching myself to script/program about 6 months ago and i am still learning as i go.

so again thank you for putting forth an effort and posting your ServerList.cs Script.

on a side note even though i never got the error "Invalid Client Detected" that some got, i still need the LetMeInPacketHandler.cs to login to the Secondary Server. Thank you Will_man

roadmaster :)
 

will_man

Sorceror
valarnin said:
Okay this is my first script submission ever, so flame me if need be.
|code|

No one should be flamed for submitting code as long as it does what they claim it does :). Your code looks good, but one thing i will say is:
Code:
				if ( Resolve( Address != null && !IsLocalMachine( e.State ) ? Address : Dns.GetHostName(), out ipAddr ) )
					e.AddServer( ServerName, new IPEndPoint( ipAddr, Listener.Port ) );
					e.AddServer( ServerName2, new IPEndPoint( ipAddr, Listener.Port2 ) );

should that not be:
Code:
				if ( Resolve( Address != null && !IsLocalMachine( e.State ) ? Address : Dns.GetHostName(), out ipAddr ) )
				{
					e.AddServer( ServerName, new IPEndPoint( ipAddr, Listener.Port ) );
					e.AddServer( ServerName2, new IPEndPoint( ipAddr, Listener.Port2 ) );
				}

:)
 

Jason

Wanderer
Thats not going to compile....

No such thing as Port2 on the Listener class.

Its a shame that most of your critics will never remember you saying this when they're busy flaming you. You can't possibly be as bad as people make you out to be, and I think you'd be surprised how much your rep would improve if people saw more of this kind of statement from you.

If people were more worried about posting correct information and less about me posting correct information, i wouldn't have to act like I do.

So worry about yourself.
 

will_man

Sorceror
ah yeah :/ missed that :p so
Code:
			Listener.Port2 = 2592;  //Server 2's Port

should be removed and above that in the class you need

Code:
public const int Port2 = 2592;

and then in that bit i gave you:

Code:
				if ( Resolve( Address != null && !IsLocalMachine( e.State ) ? Address : Dns.GetHostName(), out ipAddr ) )
				{
					e.AddServer( ServerName, new IPEndPoint( ipAddr, Listener.Port ) );
					e.AddServer( ServerName2, new IPEndPoint( ipAddr, Port2 ) );
				}

well done Jason, i missed that totally

*edit* and it seems i cant spell public :p
 

Thraxus

Sorceror
Jason said:
If people were more worried about posting correct information and less about me posting correct information, i wouldn't have to act like I do.

So worry about yourself.
Maybe I'm just misinterpreting that last comment, but I think I was just told to mind my own business. :(

Regardless, as will_man said, well done Jason. Sorry if I said something to offend you..
 

HellRazor

Knight
You don't "have" to act as you do. You choose to act as you do.

Helping is great, and you have posted a lot of helpful posts. But help is a lot better when it's not mixed with attitude. All attitude does is piss people off and make them not want to contribute any more, and that's bad for the community here. That's all I'm saying.

There are always going to be some people here who are better at C# than others, but most people are here to learn, not to be put down because someone doesn't like their code. Phantom is another good C# programmer who never quite understood that.

Jason said:
Thats not going to compile....
If people were more worried about posting correct information and less about me posting correct information, i wouldn't have to act like I do.

So worry about yourself.
 

Jason

Wanderer
HellRazor said:
You don't "have" to act as you do. You choose to act as you do.

Helping is great, and you have posted a lot of helpful posts. But help is a lot better when it's not mixed with attitude. All attitude does is piss people off and make them not want to contribute any more, and that's bad for the community here. That's all I'm saying.

There are always going to be some people here who are better at C# than others, but most people are here to learn, not to be put down because someone doesn't like their code. Phantom is another good C# programmer who never quite understood that.

The only people that have a problem with my replies are people who need to worry about themselfs.

I answer posts, if you do not answers posts daily please keep your comments to yourself.
 

bean56

Wanderer
Just so you know valarnin, when most people use a second port they us 94, not 92 as 94 and 93 are the two reccomended ports for RunUO although it doesn't really matter.
 

HellRazor

Knight
I'm more concerned about the quality of my posts than the quantity. None of my posts have ever made someone feel like they should stop contributing here.

Jason said:
The only people that have a problem with my replies are people who need to worry about themselfs.

I answer posts, if you do not answers posts daily please keep your comments to yourself.
 

valarnin

Wanderer
Attempt #2

Okay. This is my attempt at actually connecting to another shard from one, thus having 2 servers on seperate computers and being able to connect to one from the other one. Shard #1's ServerList.cs:
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 = 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 Address2 = "69.170.201.18";  //Server 2's IP address

		public const string Address = "69.170.201.18";  //Server's IP address

		public const string ServerName = "Age of Mayhem";  //Server 1's Name

		public const string ServerName2 = "AOM Test Shard";  //Server 2's Name

		public const int Port2 = 2592;  //Server 2's Port

		public static void Initialize()
		{
			Listener.Port = 2593;  //Server 1's Port

			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 ) );
					e.AddServer( ServerName2, new IPEndPoint( ipAddr, Port2 ) );
					}
				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;
		}
	}
}

And this is Server #2's Serverlist.cs
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 = 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 Address2 = "69.170.201.18";  //Server 2's IP address

		public const string Address = "69.170.201.18";  //Server's IP address

		public const string ServerName = "Age of Mayhem";  //Server 1's Name

		public const string ServerName2 = "AOM Test Shard";  //Server 2's Name

		public const int Port2 = 2593;  //Server 2's Port

		public static void Initialize()
		{
			Listener.Port = 2592;  //Server 1's Port

			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 ) );
					e.AddServer( ServerName2, new IPEndPoint( ipAddr, Port2 ) );
					}
				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;
		}
	}
}

They are both behind a router, so they use the same WAN IP. You must switch the "Server 1's Port" and the "Server 2's Port" around, or your 2nd server will be using port 2593 instead of 2592.

Tell me what, if anything, is wrong with it. I can't test it right now, but i will later tonight.
 

TurboABA

Wanderer
I tried that and it shows up on the shard list, however whenever i choose to select one it connects to the same one.
 
Status
Not open for further replies.
Top