splatoon/nex/secure.go
Ash b9d3bd3482
Some checks failed
Build and Publish Docker Image / build-publish (push) Has been cancelled
Updates to underlying libraries (#16)
* chore: update grpc bits and add local auth mode

* chore: library updates and token validation

* fix: small things

* feat: use secret unreleased protocols

* chore: update go modules

* chore: bump golang version
2025-10-20 00:31:02 +11:00

49 lines
1.6 KiB
Go

package nex
import (
"fmt"
common_globals "github.com/PretendoNetwork/nex-protocols-common-go/v2/globals"
"os"
"strconv"
"github.com/PretendoNetwork/nex-go/v2"
"github.com/PretendoNetwork/splatoon/globals"
)
func StartSecureServer() {
globals.SecureServer = nex.NewPRUDPServer()
globals.SecureServer.ByteStreamSettings.UseStructureHeader = true
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.LibraryVersions.SetDefault(nex.NewLibraryVersion(3, 8, 15))
globals.SecureServer.AccessKey = "6f599f81"
globals.SecureEndpoint.OnData(func(packet nex.PacketInterface) {
request := packet.RMCMessage()
fmt.Println("==Splatoon - Secure==")
fmt.Printf("Protocol ID: %d\n", request.ProtocolID)
fmt.Printf("Method ID: %d\n", request.MethodID)
fmt.Println("===============")
})
globals.SecureEndpoint.OnError(func(err *nex.Error) {
globals.Logger.Errorf("Secure: %v", err)
})
globals.MatchmakingManager = common_globals.NewMatchmakingManager(globals.SecureEndpoint, globals.Postgres)
globals.MatchmakingManager.GetUserFriendPIDs = globals.GetUserFriendPIDs
registerCommonSecureServerProtocols()
port, _ := strconv.Atoi(os.Getenv("PN_SPLATOON_SECURE_SERVER_PORT"))
globals.SecureServer.Listen(port)
}