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!

Second Server

gator1989

Sorceror
Second Server

Right now i have 2 servers on 2 computers... You can see both servers when you login to the game... The main server you can login just fine but the second computers server no one can login to. The admins have to make the accounts by hand for everyone... here is the servers serverlist.cs file for both servers (the PVPServerList.cs no one can login to) Can anyone help me out on how to make other players be able to login to the server? i have two different ports already but the same ip.. Sorry if this is a little confusing.
 

Attachments

  • PVPServerList.cs
    18.6 KB · Views: 46
  • RPGServerList.cs
    18.6 KB · Views: 41

corbingene01

Wanderer
are you saying that people can log into the pvp server after admins create the account for them?
if that is the case then I would look at the accounthandler.cs and make sure that "private static bool AutoAccountCreation = true;"

now if they cannot connect at all to the pvp server regardless if they have accounts or not, I'd look into your port forwarding and make sure it's setup to forward both servers. I used to run 2 servers myself, being one was a test server, but I overlooked the simple port forward in my router.
 
corbingene01;826011 said:
are you saying that people can log into the pvp server after admins create the account for them?
if that is the case then I would look at the accounthandler.cs and make sure that "private static bool AutoAccountCreation = true;"

now if they cannot connect at all to the pvp server regardless if they have accounts or not, I'd look into your port forwarding and make sure it's setup to forward both servers. I used to run 2 servers myself, being one was a test server, but I overlooked the simple port forward in my router.


I have both servers working. They can both be signed into using the correct IP address and the correct port. One 2593 one 2594.

What I cannot do is get two on one screen using two machines. In the Shardlist. Unless I host both shards on one machine. In which case I did find the documentation in search on how to do that.
 

FingersMcSteal

Sorceror
This sort of things been asked for a million times here.

Simple solution would be to advertise each shard seperatly.

The account system currently built into RunUO handles accounts for that server, if there were a system to store account info in some kind of database (MySQL etc) then that would be a help.

One shard would need to be setup as the primary account holding server (your version of a login server if you will) and the second server would need to access the first servers account files in order to login on the second server, but your second server (RunUO exe) handles it's own accounts too, which is why so many people have problems doing this.

The client when it logs in connects to 'A' server to grab account and serverlist data, then disconnects and reconnects to 'Another' server which details are given by the login server... or server 'A'.

I've had this working myself in the past but if your 1st server (your primary account holding server) goes offline you can't get to the server list to go into the 2nd, 3rd servers etc etc. That in english means you give an IP and Port for players to login but you don't give IP and Port information for the other servers becuse you want a serverlist in the 1st servers window when it's offline the other servers are inaccessable.
 
so in theory can be done but hinges on one machine not crapping out at any given time.

Easier instead to stack IP addresses on the same web pages and forums advertising the expansion blah blah. Okay thanks.
 

FingersMcSteal

Sorceror
I've had it working myself and helped a couple of other out getting it to work so in theory yes it works.

The problems with the avaliable server list CS files here on the forums are...

Because server A has to be hard coded with the details of the other servers B, C and D etc etc those other servers are always on the server list that your players connect to (server A), so if the other servers go offline they don't go off the server list server A provides. Thats problem 1.

Next...

Server B, C and D etc need to access / share the account XML server A makes. Because each RunUO.exe (each server) handles it's own account information.

This is one of the main problems with trying to do this, the accounts are in the Server A account file... The only work around i've found that worked was making sure server B, C and D had the same account XML as server A, otherwise login to B, C or D always fails because the accounts are created on server A (technically your 1st login server)... Server A is kind of the login server your players have the details for... IP & Port.

Next...

If server A goes offline, your only giving players 1 IP & Port number to connect to in order to access B, C and D etc... so your players loose ways to access the other servers anyway.

*** EDIT ***
I've spent some time looking at ways to make this kind of thing work and you could add code to this that could (in therory) handle which server is online or offline, with that make sure your server list displays only the online shards / servers.

Also you need some way to get access to the account XML from all servers if you intend to do it, again some code could be added to each server to ensure when a player logs in the most up to date copy of the XML is in the correct location / folder for each server... This is where something like MySQL would be so much better to hold account details and then each server could just be triggered to read account details from a main database like that. Personally i wouldn't want to re-write the entire account handeling section of RunUO just to work on SQL so i could add 1 or 2 extra servers to a list but in theory yes it's doable.
 

FingersMcSteal

Sorceror


Old trials i did, the last 2 servers were a friends in USA, mine are UK based shards so in theory yes.
 
very interesting.

And with non edited login files how are player counts per machine handled? I have seen a shard with 3 before and of course you log into any of the shards it claims 500 online ect blah blah, but in the case of 5 shards sharing a central login as it were how would this effect the ability of sites such as ConnectUo and UOGateway to correctly count online players?

Enquiring minds like to disect things.
 

FingersMcSteal

Sorceror
Online counts are something thats handeled seperatly, usually with the built in UOG packet which returns the current number of connected clients, although there are ways to send incorrect data back when this packet is send to the servers.
 

graverobbing

Sorceror
Awesome.

Ok I've changed the old serverlist.cs to this one, it compiles but i cant log in into the server, it says the client servers are currently down please try again in a few momets" and my server says "Client: 127.0.0.1: Connected. [1 Online] Login: 127.0.0.1: Valid credentials for 'sprungmo' Client: 127.0.0.1: Disconnected. [0 Online] [sprungmo]"

SCRIPT

Code:
// ==================================================================================================================
// ServerList.cs Ver.2.0                                                              Mr.Fixit Version Releases
// ==================================================================================================================
//      1.0 	RunUO Beta 36	Initial version
//      1.1 	Mr Fixit	Now automaticly detects if you are connecting localy and uses the
//				servers local ip in the client serverlist.
//      1.2	Mr Fixit	Internet IP autodetection using www.whatismyip.com.
//      1.3	Mr Fixit	If script fails to find the internet ip, keep the old one and try again in # minutes.				
//      1.4	Mr Fixit	You can now add AutoIP mirrors. Added whatismyip.com and myip.com.
//      1.5	Mr Fixit	Adjusted the AutoIP mirror engine so it supports more mirrors.
//				Added findmyip.com and ipaddy.com.
//      1.6	Mr Fixit	IP is now trimmed (Just in case). Added simflex.com, edpsciences.com,
//				ipid.shat.net and checkip.dyndns.org.
//      1.7  Mr Fixit        Removed www.whatismyip.com is it seems to be out of buisness.
//      1.8  Mr Fixit        Added a message to the console with ServerList.cs version when server loads.
//				Now detects the internet ip when the server starts.
//				Now checks if the ip has changed every 60 minutes instead of 30 minutes.
//      1.9  Mr Fixit        Removed noip.com mirror as it isnt working anymore.
//      2.0  Mr Fixit        Now only renews the ip every 24 hours (1440 minutes).
//===================================================================================================================
// ServerList.cs Ver.2.2                                                     Developer Landry Version Releases
//===================================================================================================================
//      2.1  Developer Landry        Its easyer to add multiple servers.
//                                                             The Home Server is where you enter the ip/port of the server this script is running on a.k.a the scripts home server.
//                                                             Servers/Ports A, B and C are the different values you can enter your multiple servers into.
//                                                             All servers that are listed must be running the same corresponding ServerList.cs for the list to work.
//                                                             NOTE: BY DEFAULT A. B AND C ARE COMMENTED OUT BY /*EXAMPLE*/ THE OUTSIDE COMMENTS.
//                                                             NOTE: ALL SERVERS MUST BE HOSTED BY THE SAME IP ADDRESS
//                                                             NOTE: ALL SERVERS MUST BE HOSTED BY DIFFERENT PORTS
//      2.2  Developer Landry        Added Account Packet Handler (APH).
//                                                             Enables the client to connect to multiple servers.
//                                                             Disables client checks allowing the client to login into multiple servers.
//                                                             The Disabling also allows the client to login into the same account twice.
// ===================================================================================================================

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

namespace Server.Misc
{
	public class ServerList
	{
		// ==================================================================================
		// YOUR SERVERS NAME
		// ==================================================================================
        public const string ServerName = "[COLOR="Red"]name1[/COLOR]"; //Home Server's Name
                                //Server A
		public const string ServerNameA = "[COLOR="Red"]name2[/COLOR]"; //Server A's Name
                                /*//Server B
		public const string ServerNameB = "Server 3"; //Server B's Name*/
                                /*//Server C
		public const string ServerNameC = "Server 4"; //Server C's Name*/
		// ==================================================================================
		// YOUR INTERNET IP OR DNS NAME
		// Here you can select to autodetect your internet ip, or manualy specify
		// Examples:
		// public static string Address = "12.34.56.78";
		// public static string Address = "shard.host.com";
		// ==================================================================================
		public const bool InternetIPAutodetect = false;
		public const int MinutesBetweenIPAutodetect = 1440;
		public static string Address = "[COLOR="Red"]the other server ip[/COLOR]";  //Home Server's IP
                                //Server A
		public static string AddressA = null;  //Server A's IP
		public const int PortA = 2592;  //Server A's Port
                                /*//Server B
		public static string AddressB = null; //Server B's IP
		public const int PortB = 2592;  //Server B's Port*/
                                /*//Server C
		public static string AddressB = null; //Server C's IP
		public const int PortB = 2594;  //Server C's Port*/
		// ==================================================================================
		// Here are some values stored
		// ==================================================================================
		private static LocalLanIPRange[] LocalLanIPRanges = new LocalLanIPRange[10];		
		private static UInt32 LocalLanIPRangesCount;
		private static AutoIPMirror[] AutoIPMirrors = new AutoIPMirror[10];	
		private static UInt32 AutoIPMirrorsCount;
		private static DateTime InternetIPAutodetectLast;
		

		// ==================================================================================
		// Initialization
		// ==================================================================================
		public static void Initialize()
		{
			// ----------------------------------------------------
			// Select what home port to use
			// ----------------------------------------------------
//			Listener.Port = 2593;  //Home Server's Port

			// ----------------------------------------------------
			// Load the local LAN ip ranges
			// ----------------------------------------------------
			AddLocalLANIPRange("10.0.0.0", "10.255.255.255");
			AddLocalLANIPRange("192.168.0.0", "192.168.255.255");
			AddLocalLANIPRange("172.16.0.0", "172.32.255.255");
			AddLocalLANIPRange("169.254.0.0", "169.254.255.255");

			// ----------------------------------------------------
			// Load the Auto IP mirros
			// ----------------------------------------------------
			AddAutoIPMirror("http://www.findmyip.com/", "Your IP address is:<br>", "</FONT>");
			AddAutoIPMirror("http://www.ipaddy.com/", "Your IP address is: ", "<br>");
			AddAutoIPMirror("http://checkip.dyndns.org/", "Current IP Address: ", "</body>");
			AddAutoIPMirror("http://ipid.shat.net/iponly/", "<title>", "</title>");
			AddAutoIPMirror("http://www.edpsciences.com/htbin/ipaddress", "Your IP address is  <B> ", " </B>");
			AddAutoIPMirror("http://www2.simflex.com/ip.shtml", "Your IP address is <BR>", "<BR>");
			
			// ----------------------------------------------------
			// Create the event
			// ----------------------------------------------------
//			EventSink.ServerList += new ServerListEventHandler( EventSink_ServerList );
			
			// ----------------------------------------------------
			// Show info in console
			// ----------------------------------------------------
			Console.WriteLine("ServerList 2.2");
			Console.WriteLine("Welcome to Server 2");

			// ----------------------------------------------------
			// Lets find internet ip
			// ----------------------------------------------------
			DetectInternetIP();
			
			
		}
		

		// ==================================================================================
		// Add a range of local lan ips
		// ==================================================================================
		private static void AddLocalLANIPRange(string RangeFrom, string	RangeTo)
		{
			LocalLanIPRanges[LocalLanIPRangesCount] = new LocalLanIPRange();
			LocalLanIPRanges[LocalLanIPRangesCount].RangeFrom = StringIPToUInt32IP(RangeFrom);
			LocalLanIPRanges[LocalLanIPRangesCount].RangeTo = StringIPToUInt32IP(RangeTo);
			LocalLanIPRangesCount = LocalLanIPRangesCount + 1;
		}
		
		
		// ==================================================================================
		// Convert a ip string to a binary unsigned int
		// ==================================================================================
		private static UInt32 StringIPToUInt32IP(string addr)
		{
			byte[] byteArray1 = IPAddress.Parse(addr).GetAddressBytes();
			byte[] byteArray2 = IPAddress.Parse(addr).GetAddressBytes();
			byteArray1[0] = byteArray2[3];
			byteArray1[1] = byteArray2[2];
			byteArray1[2] = byteArray2[1];
			byteArray1[3] = byteArray2[0];
			return  BitConverter.ToUInt32( byteArray1, 0);
		}
		

		// ==================================================================================
		// Used to store the local lan ip ranges
		// ==================================================================================
		private class LocalLanIPRange
		{
			public UInt32			RangeFrom;
			public UInt32			RangeTo;
		}	


		// ==================================================================================
		// Add a AutoIP mirror
		// ==================================================================================
		private static void AddAutoIPMirror(string sURL, string	sStart, string sEnd)
		{
			AutoIPMirrors[AutoIPMirrorsCount] = new AutoIPMirror();
			AutoIPMirrors[AutoIPMirrorsCount].sURL = sURL;
			AutoIPMirrors[AutoIPMirrorsCount].sStart = sStart;
			AutoIPMirrors[AutoIPMirrorsCount].sEnd = sEnd;
			AutoIPMirrorsCount = AutoIPMirrorsCount + 1;
		}


		// ==================================================================================
		// Used to store the Auto IP mirrors
		// ==================================================================================
		private class AutoIPMirror
		{
			public string			sURL;
			public string			sStart;
			public string			sEnd;
			public UInt32			iFailures;
		}	


		// ==================================================================================
		// Detect ip
		// ==================================================================================
		public static void DetectInternetIP()
		{

			// ----------------------------------------------------
			// Autodetect the Internet IP
			// ----------------------------------------------------
			if (InternetIPAutodetect) {
				DateTime UpdateTime = InternetIPAutodetectLast;
				UpdateTime = UpdateTime.AddMinutes(MinutesBetweenIPAutodetect);
				if (UpdateTime<DateTime.Now) {
					string NewAddress = null;
					NewAddress = FindInternetIP();
					InternetIPAutodetectLast = DateTime.Now;
					if (NewAddress!=null) 
					{
						Address = NewAddress;
					}
				}
			}
			
		}

		// ==================================================================================
		// 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 ( Resolve( Address != null && !IsLocalMachine( e.State ) ? Address : Dns.GetHostName(), out ipAddr ) )
				{
					e.AddServer( ServerName, new IPEndPoint( ipAddr, Listener.Port ) );
					e.AddServer( ServerNameA, new IPEndPoint( ipAddr, PortA ) );
					/*e.AddServer( ServerNameB, new IPEndPoint( ipAddr, PortB ) );*/
					/*e.AddServer( ServerNameC, new IPEndPoint( ipAddr, PortC ) );*/
				/*} else {
					e.Rejected = false;
				}
			}
			catch
			{
				e.Rejected = false;
			}
		} */
		
		
		// ==================================================================================
		// Connects to a webserver that gives you your internet ip
		// ==================================================================================
                public static string FindInternetIP( )
		{

			// ----------------------------------------------------
			// Pick a random mirror
			// ----------------------------------------------------
			Random rnd = new Random();
			int UseMirror = (int)( rnd.NextDouble() * AutoIPMirrorsCount);
			string MyIP = "";
			
			// ----------------------------------------------------
			// Catch if the mirror is down
			// ----------------------------------------------------
			try
			{
				// ----------------------------------------------------
				// Get the webpage
				// ----------------------------------------------------
        	    		WebClient client = new WebClient();
            			byte[] pageData = client.DownloadData(AutoIPMirrors[UseMirror].sURL);
            			MyIP = System.Text.Encoding.ASCII.GetString(pageData);
            		
				// ----------------------------------------------------
				// Find the string
				// ----------------------------------------------------
                        	int iStart = MyIP.LastIndexOf(AutoIPMirrors[UseMirror].sStart);   
                        	int iEnd = MyIP.IndexOf(AutoIPMirrors[UseMirror].sEnd, iStart+AutoIPMirrors[UseMirror].sStart.Length);
                        	MyIP = MyIP.Substring(iStart+AutoIPMirrors[UseMirror].sStart.Length, iEnd-iStart-AutoIPMirrors[UseMirror].sStart.Length );
                        	MyIP = MyIP.Trim();
                        	
				// ----------------------------------------------------
				// Return value
				// ----------------------------------------------------
                        	Console.WriteLine("Internet IP: {0} ({1})", MyIP, AutoIPMirrors[UseMirror].sURL);
        	                return MyIP;
			}
			catch
			{
				Console.WriteLine("Unable to autoupdate the Internet IP from {0}!", AutoIPMirrors[UseMirror].sURL);
				Console.WriteLine("----------------------------------------------------------------------");
				Console.WriteLine(MyIP);
				Console.WriteLine("----------------------------------------------------------------------");
				return null;
			}
        	}
		
		
		// ==================================================================================
		// Calculates what server IP to use
		// ==================================================================================
                public static IPAddress FindMachineIP( ServerListEventArgs e )
		{
			// ----------------------------------------------------
			// Find the IP of the connecting user
			// ----------------------------------------------------
			Socket sock = e.State.Socket;
			IPAddress theirAddress = ((IPEndPoint)sock.RemoteEndPoint).Address;				
			IPAddress serverAddress;

			// ----------------------------------------------------
			// Is it Loopback?
			// ----------------------------------------------------
			if ( IPAddress.IsLoopback( theirAddress ) )
			{
				return IPAddress.Parse( "127.0.0.1" );
			}

			// ----------------------------------------------------
			// Local
			// ----------------------------------------------------
			UInt32 uint32Address = StringIPToUInt32IP(theirAddress.ToString());
			for (UInt32 LocalLanIPRangesLoop = 0 ; LocalLanIPRangesLoop < LocalLanIPRangesCount; LocalLanIPRangesLoop++)
			{	
				if ( (LocalLanIPRanges[LocalLanIPRangesLoop].RangeFrom <= uint32Address) && (LocalLanIPRanges[LocalLanIPRangesLoop].RangeTo >= uint32Address) )
				{
					Resolve(Dns.GetHostName(), out serverAddress);
					
					Console.WriteLine("Player is reconnecting to " + serverAddress.ToString());
					return serverAddress;
				}
			}

			// ----------------------------------------------------
			// Internet addresses
			// ----------------------------------------------------
			if (Address!=null)
			{
				Resolve(Address, out serverAddress);	
			} else {
				Resolve(Dns.GetHostName(), out serverAddress);	
			}
			
			Console.WriteLine("Player is reconnecting to " + serverAddress.ToString());
			return serverAddress;
		}
		

		// ==================================================================================
		// Resolves dns names
		// ==================================================================================
		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;
		}
	}
}
namespace Server.Network
{
	public class APH
	{
		public static void Initialize()
		{
			PacketHandlers.Register( 145, 65, false, new OnPacketReceive( GameLogin ) );
		}

		public static void GameLogin(NetState state, PacketReader pvSrc)
		{
			if (state.SentFirstPacket)
			{
				state.Dispose();
				return;
			}
				state.SentFirstPacket = true;
				int SecurityID = pvSrc.ReadInt32();

			string un = pvSrc.ReadString(30);
			string pw = pvSrc.ReadString(30);
			GameLoginEventArgs loginevents = new GameLoginEventArgs(state, un, pw);
			EventSink.InvokeGameLogin( loginevents );
			if ( loginevents.Accepted )
			{
				state.CityInfo = loginevents.CityInfo;
				state.CompressionEnabled = true;
				//if ( Core.AOS )
				//{
				//	state.Send( SupportedFeatures.Instantiate() );
				//}
				state.Send( new CharacterList( state.Account, state.CityInfo ) );
				return;
			}
			state.Dispose();
		}
	}
}
 

FingersMcSteal

Sorceror
Don't have them anymore, sorry.

*** EDIT ***

Besides this works but it doesn't if you read the posts regarding the accounts file.
 
Top