mirror of
https://github.com/PretendoNetwork/friends.git
synced 2025-04-02 11:01:46 -04:00
Initializing the server accounts in their own thread (e.g. the authentication and secure servers) can cause a race condition where the secure account hasn't been set up yet when authentication configures `ticket-granting`, causing sometimes crashes on startup. This has happened on production causing unnecesary restarts. To fix this, initialize the accounts on the `init` function to ensure they will always be accessible when needed.
31 lines
1.1 KiB
Go
31 lines
1.1 KiB
Go
package nex
|
|
|
|
import (
|
|
"os"
|
|
"strconv"
|
|
|
|
"github.com/PretendoNetwork/friends/globals"
|
|
"github.com/PretendoNetwork/nex-go/v2"
|
|
)
|
|
|
|
var serverBuildString string
|
|
|
|
func StartAuthenticationServer() {
|
|
port, _ := strconv.Atoi(os.Getenv("PN_FRIENDS_AUTHENTICATION_SERVER_PORT"))
|
|
|
|
globals.AuthenticationServer = nex.NewPRUDPServer()
|
|
globals.AuthenticationEndpoint = nex.NewPRUDPEndPoint(1)
|
|
|
|
globals.AuthenticationEndpoint.ServerAccount = globals.AuthenticationServerAccount
|
|
globals.AuthenticationEndpoint.AccountDetailsByPID = globals.AccountDetailsByPID
|
|
globals.AuthenticationEndpoint.AccountDetailsByUsername = globals.AccountDetailsByUsername
|
|
|
|
registerCommonAuthenticationServerProtocols()
|
|
|
|
globals.AuthenticationServer.SetFragmentSize(962)
|
|
globals.AuthenticationServer.LibraryVersions.SetDefault(nex.NewLibraryVersion(1, 1, 0))
|
|
globals.AuthenticationServer.SessionKeyLength = 16
|
|
globals.AuthenticationServer.AccessKey = "ridfebb9"
|
|
globals.AuthenticationServer.BindPRUDPEndPoint(globals.AuthenticationEndpoint)
|
|
globals.AuthenticationServer.Listen(port)
|
|
}
|