super-mario-maker/nex/secure.go
TraceEntertains 7fec60a222
Hotfix 3, hopefully finally fixes this (#18)
* Hotfix 2 (electric boogaloo), initialize server accounts

* The server Actually Runs™️!
2025-02-23 21:57:24 +00:00

43 lines
1.3 KiB
Go

package nex
import (
"fmt"
"os"
"strconv"
"github.com/PretendoNetwork/nex-go/v2"
"github.com/PretendoNetwork/super-mario-maker/globals"
)
func StartSecureServer() {
globals.SecureServer = nex.NewPRUDPServer()
globals.SecureEndpoint = nex.NewPRUDPEndPoint(1)
globals.SecureEndpoint.IsSecureEndPoint = true
globals.SecureEndpoint.ServerAccount = globals.SecureServerAccount
globals.SecureEndpoint.AccountDetailsByPID = globals.AccountDetailsByPID
globals.SecureEndpoint.AccountDetailsByUsername = globals.AccountDetailsByUsername
globals.SecureServer.BindPRUDPEndPoint(globals.SecureEndpoint)
globals.SecureServer.ByteStreamSettings.UseStructureHeader = true
globals.SecureServer.LibraryVersions.SetDefault(nex.NewLibraryVersion(3, 8, 3))
globals.SecureServer.AccessKey = "9f2b4678"
globals.SecureEndpoint.OnData(func(packet nex.PacketInterface) {
request := packet.RMCMessage()
fmt.Println("=== SMM1 - Secure ===")
fmt.Printf("Protocol ID: %d\n", request.ProtocolID)
fmt.Printf("Method ID: %d\n", request.MethodID)
fmt.Println("==================")
})
// * Register the common handlers first so that they can be overridden if needed
registerCommonSecureProtocols()
registerNEXProtocols()
port, _ := strconv.Atoi(os.Getenv("PN_SMM_SECURE_SERVER_PORT"))
globals.SecureServer.Listen(port)
}