Go Back   RunUO - Ultima Online Emulation > RunUO > Server Support on Windows

Server Support on Windows Get (and give) support on general questions related to the RunUO server itself.

Closed Thread
 
Thread Tools Display Modes
Old 05-17-2004, 12:49 AM   #1 (permalink)
Hello?
 
Join Date: Aug 2003
Posts: 288
Send a message via ICQ to kage1234
Default Two shards/one server listing

I was wondering if anyone can explain to me how this works, I would like to merge to shards togather and have the OSI shard listing list the shards instead of UOG.
Code:
                      Shard A: Connect and play
                    /
UOG-Name
                   \
                     Shard B: Connect and play
How does this work/how would I do this? Does this enable the host computer to host two shards?
__________________
Java House Gamers!

Online gamers community
Hosting our unique UO servers (down for hardware and shard construction)
Proud sponsors of Personal Computer Builders
Check us out!
kage1234 is offline  
Old 05-17-2004, 03:34 PM   #2 (permalink)
Account Terminated
 
Join Date: May 2004
Posts: 1,161
Default

You need to add two listings.

The code for one is there, just duplicate it.
Jason is offline  
Old 05-17-2004, 03:58 PM   #3 (permalink)
Forum Novice
 
Join Date: Nov 2003
Location: USA, a small hick city in Missouri
Posts: 174
Default

Jason, he means how do you get two shards into the connection screen, like

Daemon's World
Test Center
Local Server

like that.. and have the TC and DW different servers with the same account..
err, you probably know what he means anyway..
KingSmidgens is offline  
Old 05-18-2004, 10:53 AM   #4 (permalink)
Hello?
 
Join Date: Aug 2003
Posts: 288
Send a message via ICQ to kage1234
Default

Yes, thats exactly what I mean. Any thoughts on how?
__________________
Java House Gamers!

Online gamers community
Hosting our unique UO servers (down for hardware and shard construction)
Proud sponsors of Personal Computer Builders
Check us out!
kage1234 is offline  
Old 05-18-2004, 11:45 AM   #5 (permalink)
 
Join Date: Dec 2003
Posts: 67
Default

Unfortunately I only have access to the B36 script right now (not going to try and install RC1 on my work computer), but I don;t think the file changed any.

Original script code:
PHP Code:
public static void EventSink_ServerListServerListEventArgs e )
{
    try
    {
        
IPAddress ipAddr;

        if ( 
ResolveAddress != null && !IsLocalMachinee.State ) ? Address Dns.GetHostName(), out ipAddr ) )
            
e.AddServerServerName, new IPEndPointipAddrListener.Port ) );
        else
            
e.Rejected true;
    }
    catch
    {
        
e.Rejected true;
    }

Ok the part in there that makes an entry in the UO servers list is this:
PHP Code:
        if ( ResolveAddress != null && !IsLocalMachinee.State ) ? Address Dns.GetHostName(), out ipAddr ) )
            
e.AddServerServerName, new IPEndPointipAddrListener.Port ) ); 
Therefore, all you really need to do is copy that and past it back in so that you have it twice (and change the "if" to "else if" so that the rest of the code will still work properly).

You should have this now:
PHP Code:
public static void EventSink_ServerListServerListEventArgs e )
{
    try
    {
        
IPAddress ipAddr;

        if ( 
ResolveAddress != null && !IsLocalMachinee.State ) ? Address Dns.GetHostName(), out ipAddr ) )
            
e.AddServerServerName, new IPEndPointipAddrListener.Port ) );
        else if ( 
ResolveAddress != null && !IsLocalMachinee.State ) ? Address Dns.GetHostName(), out ipAddr ) )
            
e.AddServerServerName, new IPEndPointipAddrListener.Port ) );
        else
            
e.Rejected true;
    }
    catch
    {
        
e.Rejected true;
    }

Now, you just have to change the "Address", "ServerName" variables in the second entry with ones that are for the 2nd server. Also, if you are behind a router and both servers will have the same address, then you will have to give them two different port numbers.
SDragon is offline  
Old 05-24-2004, 08:34 PM   #6 (permalink)
Forum Expert
 
Join Date: Oct 2003
Location: Calhoun, Ga
Age: 44
Posts: 1,008
Send a message via AIM to roadmaster
Default

How exactly does this work? If i want to have a Server that uses the normal 4 facets and also i want a Server that uses a Custom Map, How would i do this?

Quote:
Now, you just have to change the "Address", "ServerName" variables in the second entry with ones that are for the 2nd server.
Perhaps i have misunderstood, How do you add a second Address and ServerName? Do you have two entries for Address and two entries for ServerName, on one Serverlist.cs? if you do that wont you receive a error "already contains a definition for"? Or are you saying that you have a Serverlist.cs for each Server with its own Address and ServerName thats different from the other? If you do have two separate Server Directories with different settings in the Serverlist.cs how does the Client know to check for the second server?

ie... if i run the primary server and it compiles fine then i run the second server and if also compiles fine, but when i run the client program it only detects the primary server. How does the client know that there is more than one server to choose from?

this is the primary server 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 Address = null;
		public const string Address = "127.0.0.1";

		public const string ServerName = "Roadmaster's Abyss";

		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 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;
		}
	}
}
and this is the Secondary 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 Address = null;
		public const string Address = "127.0.0.1";

		public const string ServerName = "Roadie's Test Center";

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

			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 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;
		}
	}
}
Doing it like this my client will not acknowledge that there is a second server.


roadmaster
roadmaster is offline  
Old 05-25-2004, 12:21 AM   #7 (permalink)
 
Join Date: Dec 2003
Posts: 67
Default

The problem you are having is that each server list is trying to add itself twice. You have to have the IP/Port/Name information for each server in your serverlist.cs file.


In this file, I have changes the Address and ServerName variables to Address1 & ServerName1, as well as added a Port1. I have also made another copy of those varables but changed the 1 to a 2 (Address2, ServerName2, Port2). Then I modified the two if statments to each make a server entry (see code).

PHP 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 = null;
        
public const string Address1 "127.0.0.1";
        public const 
string ServerName1 "Roadmaster's Abyss";
        public const 
int Port1 2593;

        public const 
string Address2 "127.0.0.1";
        public const 
string ServerName2 "Roadie's Test Center";
        public const 
int Port2 2592;

        public static 
void Initialize()
        {
            
Listener.Port Port1;

            
EventSink.ServerList += new ServerListEventHandlerEventSink_ServerList );
        }

        public static 
void EventSink_ServerListServerListEventArgs e )
        {
            try
            {
                
IPAddress ipAddr;

                if ( 
ResolveAddress1 != null && !IsLocalMachinee.State ) ? Address Dns.GetHostName(), out ipAddr ) )
                    
e.AddServerServerName1, new IPEndPointipAddrPort1 ) );
                else if ( 
ResolveAddress2 != null && !IsLocalMachinee.State ) ? Address Dns.GetHostName(), out ipAddr ) )
                    
e.AddServerServerName2, new IPEndPointipAddrPort2 ) );
                else
                    
e.Rejected true;
            }
            catch
            {
                
e.Rejected true;
            }
        }

        public static 
bool Resolvestring addrout IPAddress outValue )
        {
            try
            {
                
outValue IPAddress.Parseaddr );
                return 
true;
            }
            catch
            {
                try
                {
                    
IPHostEntry iphe Dns.Resolveaddr );

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

            
outValue IPAddress.None;
            return 
false;
        }

        private static 
bool IsLocalMachineNetState state )
        {
            
Socket sock state.Socket;

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

            if ( 
IPAddress.IsLoopbacktheirAddress ) )
                return 
true;

            
bool contains false;
            
IPHostEntry iphe Dns.ResolveDns.GetHostName() );

            for ( 
int i 0; !contains && iphe.AddressList.Length; ++)
                
contains theirAddress.Equalsiphe.AddressList[i] );

            return 
contains;
        }
    }

If you use this serverlist on your main server (Roadmaster's Abyss), you will see both Roadmaster's Abyss & Roadie's Test Center in your serverlist in the client. You technically don't even need to have your 2nd server display the server list if your primary server is the server that you will be connecting through (ie. that is the server you have set up in UOG). The only think you need to do with it is make sure the second server's listening port is set to the port you want it to listen to. Your secondary server wont be used to choose a server to connect to, only your primary server.

However, one thing you will need to know is that since your primary server will be handling the logins, any accounts you have on the secondary server MUST exist on the primary server.
SDragon is offline  
Old 05-26-2004, 10:07 AM   #8 (permalink)
Save the Mongbats!
 
Thraxus's Avatar
 
Join Date: Mar 2003
Location: Mongbatville
Age: 33
Posts: 1,042
Default

Have you actually proven this to work?

With the if and else if statements, the moment the first if is deemed true, it doesn't execute the else if. Therefore only the first server shows in the server list.

If you change the else if to an if, then both show up, but you can only connect successfully to the first one. If you attempt to connect to the secondary shard, it displays an error on the console that an "Invalid client detected, disconnecting".
Thraxus is offline  
Old 05-26-2004, 12:04 PM   #9 (permalink)
Forum Expert
 
Join Date: Mar 2003
Posts: 383
Send a message via ICQ to danknight21 Send a message via AIM to danknight21
Default

yah that guys right, that dosent even work :/ would be cool if sum1 got 1 that did work though
__________________
I Still Play OSI UO, Feel free to ICQ or post with any questions between RUNUO and OSI.
danknight21 is offline  
Old 05-26-2004, 12:08 PM   #10 (permalink)
Account Terminated
 
Join Date: May 2004
Posts: 1,161
Default

Its simple

You can't list another computer once your connected.

You can however use the same computer if you wanted to.
Jason is offline  
Old 05-26-2004, 12:35 PM   #11 (permalink)
Forum Expert
 
Join Date: Mar 2003
Posts: 383
Send a message via ICQ to danknight21 Send a message via AIM to danknight21
Default

i have a host....on my host i can make up to 4 shards....same computer they r on...how do i do it?i kno like changing the port an shit

i got

2593
2592
2591

i just dont know how 2 set up the serverlist.cs
__________________
I Still Play OSI UO, Feel free to ICQ or post with any questions between RUNUO and OSI.
danknight21 is offline  
Old 05-26-2004, 12:42 PM   #12 (permalink)
Forum Expert
 
Join Date: Oct 2003
Location: Calhoun, Ga
Age: 44
Posts: 1,008
Send a message via AIM to roadmaster
Default

Quote:
Its simple

You can't list another computer once your connected.

You can however use the same computer if you wanted to.
Ok now that we have established that, How ?


roadmaster
roadmaster is offline  
Old 05-26-2004, 01:41 PM   #13 (permalink)
 
Join Date: Dec 2003
Posts: 67
Default

Quote:
Originally Posted by Thraxus
Have you actually proven this to work?

With the if and else if statements, the moment the first if is deemed true, it doesn't execute the else if. Therefore only the first server shows in the server list.
*takes foot and shoves in mouth*

How embarassing that is for me. hehe. That is what I get for making a quick script from work where I can't test it. I know you CAN have two servers show up in the list as I have done that before. I will try to make that again tonight when I get home (and CAN test it).


*hides in shame*
SDragon is offline  
Old 05-26-2004, 01:51 PM   #14 (permalink)
Forum Expert
 
Join Date: Mar 2003
Posts: 383
Send a message via ICQ to danknight21 Send a message via AIM to danknight21
Default

haha
__________________
I Still Play OSI UO, Feel free to ICQ or post with any questions between RUNUO and OSI.
danknight21 is offline  
Old 05-26-2004, 06:16 PM   #15 (permalink)
Forum Expert
 
Join Date: Mar 2003
Posts: 383
Send a message via ICQ to danknight21 Send a message via AIM to danknight21
Default

this is what me and a friend got so far. And it does show them both in the shard listing but when u click on the Test Center one the test cent client shows that they r connecting but disconnects them

here is the 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 = null;

public const string ServerName = "Ultima AoS";

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( "Ultima AoS", new IPEndPoint( ipAddr, 2593 ) );
e.AddServer( "Test Center", new IPEndPoint( ipAddr, 2592 ) );
}
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;
}
}
}
__________________
I Still Play OSI UO, Feel free to ICQ or post with any questions between RUNUO and OSI.
danknight21 is offline  
Old 05-26-2004, 06:16 PM   #16 (permalink)
Forum Expert
 
Join Date: Jun 2003
Posts: 414
Send a message via ICQ to will_man
Default

Yes always seem to get "Invalide cliented detected: Disconecting" error when you try to pass it from one server to another, even if i Reset the EventSinks the error is still there which means that there must have been something changed somewhere important and im not quite clever enough to figure out where :P
will_man is offline  
Old 05-26-2004, 06:46 PM   #17 (permalink)
Save the Mongbats!
 
Thraxus's Avatar
 
Join Date: Mar 2003
Location: Mongbatville
Age: 33
Posts: 1,042
Default

Well SDragon says he's already made it work in the past, so I'm just going to sit tight until he posts the (hopefully successful) results of his scripting and testing.
Thraxus is offline  
Old 05-26-2004, 07:03 PM   #18 (permalink)
Forum Expert
 
Join Date: Mar 2003
Posts: 383
Send a message via ICQ to danknight21 Send a message via AIM to danknight21
Default

yes..he said he made on BEFORE, extra security could have been addin in since then...or he could have just been wrong....
__________________
I Still Play OSI UO, Feel free to ICQ or post with any questions between RUNUO and OSI.
danknight21 is offline  
Old 05-26-2004, 10:16 PM   #19 (permalink)
Save the Mongbats!
 
Thraxus's Avatar
 
Join Date: Mar 2003
Location: Mongbatville
Age: 33
Posts: 1,042
Default

Well all we have to do to find out is wait. He'll either succeed and post the working script, or fail and not post a working script. Can't do much else than wait unless you have a better idea?
Thraxus is offline  
Old 05-26-2004, 10:35 PM   #20 (permalink)
Forum Expert
 
Join Date: Jun 2003
Posts: 414
Send a message via ICQ to will_man
Default

I have made it work in the past as well, and without writing a new packet handler thingy i cant see a way to make it work now ( the thing that throws the error i cant find in any script so i presume its in the core ).
will_man is offline