Class ServerAddressProvider
- Namespace
- FishMMO.Server.Implementation
- Assembly
- FishMMO.Server.dll
Provides various IP address formats by interacting with the FishNet transport layer and server overrides.
public class ServerAddressProvider : IServerAddressProvider
- Inheritance
-
ServerAddressProvider
- Implements
- Inherited Members
Constructors
ServerAddressProvider(Transport, string, ushort, string, string)
Initializes a new instance of the ServerAddressProvider class.
public ServerAddressProvider(Transport transport, string addressOverride, ushort portOverride, string coreServerAddress, string coreServerRemoteAddress)
Parameters
transportTransportThe FishNet transport instance.
addressOverridestringAn optional address override.
portOverrideushortAn optional port override.
coreServerAddressstringThe core server's address.
coreServerRemoteAddressstringThe core server's remote address.
Methods
TryGetServerIPAddress(out ServerAddress)
Attempts to get the server's IP address (either IPv4 or IPv6), using overrides if provided. When the core server address is a loopback address (127.0.0.1, ::1, localhost, etc.), falls back to the core server's remote address. This enables local-only deployments to function while allowing production servers to register their public-facing address. Loopback detection delegates to IsLoopbackAddress(string), which uses IsLoopback(IPAddress) and covers all RFC 5735 loopback variants — not just the magic strings 127.0.0.1 and localhost.
public bool TryGetServerIPAddress(out ServerAddress address)
Parameters
addressServerAddress
Returns
TryGetServerIPv4AddressFromTransport(out ServerAddress)
Attempts to get the server's IPv4 address from the transport layer.
public bool TryGetServerIPv4AddressFromTransport(out ServerAddress address)
Parameters
addressServerAddressWhen this method returns, contains the IPv4 server address if found; otherwise, the default value.
Returns
- bool
trueif the IPv4 address was found; otherwise,false.
TryGetServerIPv6AddressFromTransport(out ServerAddress)
Attempts to get the server's IPv6 address from the transport layer.
public bool TryGetServerIPv6AddressFromTransport(out ServerAddress address)
Parameters
addressServerAddressWhen this method returns, contains the IPv6 server address if found; otherwise, the default value.
Returns
- bool
trueif the IPv6 address was found; otherwise,false.