splatoon/nex/register_common_authentication_server_protocols.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

43 lines
1.8 KiB
Go

package nex
import (
"github.com/PretendoNetwork/nex-go/v2"
"github.com/PretendoNetwork/nex-go/v2/constants"
"github.com/PretendoNetwork/nex-go/v2/types"
commonticketgranting "github.com/PretendoNetwork/nex-protocols-common-go/v2/ticket-granting"
ticketgranting "github.com/PretendoNetwork/nex-protocols-go/v2/ticket-granting"
"github.com/PretendoNetwork/splatoon/globals"
"os"
"strconv"
)
func registerCommonAuthenticationServerProtocols() {
ticketGrantingProtocol := ticketgranting.NewProtocol()
globals.AuthenticationEndpoint.RegisterServiceProtocol(ticketGrantingProtocol)
commonTicketGrantingProtocol := commonticketgranting.NewCommonProtocol(ticketGrantingProtocol)
port, _ := strconv.Atoi(os.Getenv("PN_SPLATOON_SECURE_SERVER_PORT"))
secureStationURL := types.NewStationURL("")
secureStationURL.SetURLType(constants.StationURLPRUDPS)
secureStationURL.SetAddress(os.Getenv("PN_SPLATOON_SECURE_SERVER_HOST"))
secureStationURL.SetPortNumber(uint16(port))
secureStationURL.SetConnectionID(1)
secureStationURL.SetPrincipalID(types.NewPID(2))
secureStationURL.SetStreamID(1)
secureStationURL.SetStreamType(constants.StreamTypeRVSecure)
secureStationURL.SetType(uint8(constants.StationURLFlagPublic))
commonTicketGrantingProtocol.SecureStationURL = secureStationURL
commonTicketGrantingProtocol.BuildName = types.NewString("branch:origin/project/wup-agmj build:3_8_15_2004_0")
commonTicketGrantingProtocol.SecureServerAccount = globals.SecureServerAccount
if globals.LocalAuthMode {
commonTicketGrantingProtocol.ValidateLoginData = func(pid types.PID, loginData types.DataHolder) *nex.Error {
// my friends always told me i was valid no matter what. surely my login data is the same
return nil
}
} else {
commonTicketGrantingProtocol.SetPretendoValidation(globals.TokenAESKey)
}
}