super-mario-maker/nex/authentication.go
2025-02-22 16:59:17 -05:00

44 lines
1.4 KiB
Go

package nex
import (
"fmt"
"os"
"strconv"
nex "github.com/PretendoNetwork/nex-go/v2"
"github.com/PretendoNetwork/super-mario-maker/globals"
)
var serverBuildString string
func StartAuthenticationServer() {
serverBuildString = "branch:origin/project/nfs build:3_10_26_2006_0"
globals.AuthenticationServer = nex.NewPRUDPServer()
globals.AuthenticationEndpoint = nex.NewPRUDPEndPoint(1)
globals.AuthenticationEndpoint.ServerAccount = globals.AuthenticationServerAccount
globals.AuthenticationEndpoint.AccountDetailsByPID = globals.AccountDetailsByPID
globals.AuthenticationEndpoint.AccountDetailsByUsername = globals.AccountDetailsByUsername
globals.AuthenticationServer.BindPRUDPEndPoint(globals.AuthenticationEndpoint)
globals.AuthenticationServer.ByteStreamSettings.UseStructureHeader = true
globals.AuthenticationServer.LibraryVersions.SetDefault(nex.NewLibraryVersion(3, 8, 3))
globals.AuthenticationServer.AccessKey = "9f2b4678"
globals.AuthenticationEndpoint.OnData(func(packet nex.PacketInterface) {
request := packet.RMCMessage()
fmt.Println("=== SMM1 - Auth ===")
fmt.Printf("Protocol ID: %d\n", request.ProtocolID)
fmt.Printf("Method ID: %d\n", request.MethodID)
fmt.Println("==================")
})
registerCommonAuthenticationServerProtocols()
port, _ := strconv.Atoi(os.Getenv("PN_SMM_AUTHENTICATION_SERVER_PORT"))
globals.AuthenticationServer.Listen(port)
}