LibUv Networking (#65)
This commit is contained in:
parent
ec6629fbe9
commit
5e2be2d7b6
69 changed files with 5612 additions and 586 deletions
|
|
@ -16,7 +16,7 @@ namespace Server
|
|||
{
|
||||
try
|
||||
{
|
||||
IPAddress ip = ((IPEndPoint)e.Socket.RemoteEndPoint).Address;
|
||||
IPAddress ip = ((IPEndPoint)e.Context.RemoteEndPoint).Address;
|
||||
|
||||
if (Firewall.IsBlocked(ip))
|
||||
{
|
||||
|
|
@ -43,4 +43,4 @@ namespace Server
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ namespace Server.Misc
|
|||
|
||||
Timer.DelayCall(KickDelay, delegate
|
||||
{
|
||||
if (state.Socket != null)
|
||||
if (state.Connection != null)
|
||||
{
|
||||
Console.WriteLine("Client: {0}: Disconnecting, bad version", state);
|
||||
state.Dispose();
|
||||
|
|
@ -173,4 +173,4 @@ namespace Server.Misc
|
|||
Kick
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,24 +3,25 @@ using System.IO;
|
|||
using System.Net;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Net.Sockets;
|
||||
using Microsoft.AspNetCore.Connections;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Misc
|
||||
{
|
||||
public class ServerList
|
||||
{
|
||||
/*
|
||||
/*
|
||||
* The default setting for Address, a value of 'null', will use your local IP address. If all of your local IP addresses
|
||||
* are private network addresses and AutoDetect is 'true' then RunUO will attempt to discover your public IP address
|
||||
* for you automatically.
|
||||
*
|
||||
* If you do not plan on allowing clients outside of your LAN to connect, you can set AutoDetect to 'false' and leave
|
||||
* Address set to 'null'.
|
||||
*
|
||||
*
|
||||
* If your public IP address cannot be determined, you must change the value of Address to your public IP address
|
||||
* manually to allow clients outside of your LAN to connect to your server. Address can be either an IP address or
|
||||
* a hostname that will be resolved when RunUO starts.
|
||||
*
|
||||
*
|
||||
* If you want players outside your LAN to be able to connect to your server and you are behind a router, you must also
|
||||
* forward TCP port 2593 to your private IP address. The procedure for doing this varies by manufacturer but generally
|
||||
* involves configuration of the router through your web browser.
|
||||
|
|
@ -32,7 +33,7 @@ namespace Server.Misc
|
|||
* properly and fully supports listening on multiple ports. If a client with a public IP address is connecting to a
|
||||
* locally private address, the server will direct the client to either the AutoDetected IP address or the manually entered
|
||||
* IP address or hostname, whichever is applicable. Loopback clients will be directed to loopback.
|
||||
*
|
||||
*
|
||||
* If you would like to listen on additional ports (i.e. 22, 23, 80, for clients behind highly restrictive egress
|
||||
* firewalls) or specific IP adddresses you can do so by modifying the file SocketOptions.cs found in this directory.
|
||||
*/
|
||||
|
|
@ -64,7 +65,7 @@ namespace Server.Misc
|
|||
try
|
||||
{
|
||||
NetState ns = e.State;
|
||||
Socket s = ns.Socket;
|
||||
ConnectionContext s = ns.Connection;
|
||||
|
||||
IPEndPoint ipep = (IPEndPoint)s.LocalEndPoint;
|
||||
|
||||
|
|
|
|||
|
|
@ -5,8 +5,6 @@ namespace Server
|
|||
{
|
||||
public class SocketOptions
|
||||
{
|
||||
private const bool NagleEnabled = false; // Should the Nagle algorithm be enabled? This may reduce performance
|
||||
|
||||
private static IPEndPoint[] m_ListenerEndPoints =
|
||||
{
|
||||
new IPEndPoint(IPAddress.Any, 2593) // Default: Listen on port 2593 on all IP addresses
|
||||
|
|
@ -16,24 +14,10 @@ namespace Server
|
|||
// new IPEndPoint( IPAddress.Parse( "1.2.3.4" ), 2593 ), // Listen on port 2593 on IP address 1.2.3.4
|
||||
};
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
EventSink.SocketConnect += EventSink_SocketConnect;
|
||||
}
|
||||
|
||||
public static void RegisterListeners()
|
||||
{
|
||||
for (int i = 0; i < m_ListenerEndPoints.Length; i++)
|
||||
Core.MessagePump.AddListener(m_ListenerEndPoints[i]);
|
||||
}
|
||||
|
||||
private static void EventSink_SocketConnect(SocketConnectEventArgs e)
|
||||
{
|
||||
if (!e.AllowConnection)
|
||||
return;
|
||||
|
||||
if (!NagleEnabled)
|
||||
e.Socket.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.NoDelay, 1); // RunUO uses its own algorithm
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,4 +35,7 @@
|
|||
<IncludeInPackage>false</IncludeInPackage>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Connections.Abstractions" Version="3.0.0" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ namespace Server.Misc
|
|||
}
|
||||
}
|
||||
|
||||
private static bool HasDisconnected(Mobile m) => m.NetState?.Socket == null;
|
||||
private static bool HasDisconnected(Mobile m) => m.NetState?.Connection == null;
|
||||
|
||||
private static LocationInfo GetRandomDestination() => m_Destinations[Utility.Random(m_Destinations.Length)];
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue