mirror of
https://github.com/psforever/PSF-LoginServer.git
synced 2026-05-11 00:06:18 +00:00
Better detection of loopback and local addresses
This commit is contained in:
parent
8a786fb7b3
commit
bb2acae949
1 changed files with 9 additions and 4 deletions
|
|
@ -91,10 +91,15 @@ object LoginActor {
|
|||
* @return the appropriate host address
|
||||
*/
|
||||
private def selectHostAddress(ipAddress: String): InetSocketAddress = {
|
||||
ipAddress.substring(0, ipAddress.indexOf(".")) match {
|
||||
case "127" => localHostAddress
|
||||
case "10" | "169" | "172" | "192" => gameTestServerAddressLocal
|
||||
case _ => gameTestServerAddressPublic
|
||||
val address = InetAddress.getByName(ipAddress)
|
||||
if (address.isLoopbackAddress()) {
|
||||
localHostAddress
|
||||
}
|
||||
else if (address.isSiteLocalAddress()) {
|
||||
gameTestServerAddressLocal
|
||||
}
|
||||
else {
|
||||
gameTestServerAddressPublic
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue