minecraft-wiiu/nex/authentication.go
Ash Logan f326cb00b3 feat!(rewrite): Update to v2 libraries
Updated nex libraries to their new v2 counterparts, and rewrite for the new API as appropriate.

Removed a lot of dead code, notably NEX ranking, subscriptions, and the database connection for rankings - these are unused for Minecraft.
2024-06-30 19:30:46 +10:00

44 lines
1.4 KiB
Go

package nex
import (
"fmt"
"os"
"strconv"
"github.com/PretendoNetwork/minecraft-wiiu/globals"
"github.com/PretendoNetwork/nex-go/v2"
)
func StartAuthenticationServer() {
globals.AuthenticationServer = nex.NewPRUDPServer()
globals.AuthenticationServer.ByteStreamSettings.UseStructureHeader = true
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.LibraryVersions.SetDefault(nex.NewLibraryVersion(3, 10, 0))
globals.AuthenticationServer.AccessKey = "f1b61c8e"
globals.AuthenticationEndpoint.OnData(func(packet nex.PacketInterface) {
request := packet.RMCMessage()
fmt.Println("==Minecraft: Wii U Edition - Auth==")
fmt.Printf("Protocol ID: %#v\n", request.ProtocolID)
fmt.Printf("Method ID: %#v\n", request.MethodID)
fmt.Println("===============")
})
globals.AuthenticationEndpoint.OnError(func(err *nex.Error) {
globals.Logger.Errorf("Auth: %v", err)
})
registerCommonAuthenticationServerProtocols()
port, _ := strconv.Atoi(os.Getenv("PN_MINECRAFT_AUTHENTICATION_SERVER_PORT"))
globals.AuthenticationServer.Listen(port)
}