Merge pull request #29 from DaniElectra/nex-accounts
Some checks failed
Build and Publish Docker Image / build-publish (push) Has been cancelled

This commit is contained in:
Jonathan Barrow 2024-11-06 12:23:39 -05:00 committed by GitHub
commit 3377ef25ea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 15 additions and 9 deletions

View File

@ -11,12 +11,12 @@ import (
)
func AccountDetailsByPID(pid *types.PID) (*nex.Account, *nex.Error) {
if pid.Equals(AuthenticationEndpoint.ServerAccount.PID) {
return AuthenticationEndpoint.ServerAccount, nil
if pid.Equals(AuthenticationServerAccount.PID) {
return AuthenticationServerAccount, nil
}
if pid.Equals(SecureEndpoint.ServerAccount.PID) {
return SecureEndpoint.ServerAccount, nil
if pid.Equals(SecureServerAccount.PID) {
return SecureServerAccount, nil
}
if pid.Equals(GuestAccount.PID) {

View File

@ -10,6 +10,8 @@ import (
)
var Logger *plogger.Logger
var AuthenticationServerAccount *nex.Account
var SecureServerAccount *nex.Account
var GuestAccount *nex.Account
var KerberosPassword = "password" // * Default password
var AuthenticationServer *nex.PRUDPServer

View File

@ -13,6 +13,7 @@ import (
"github.com/PretendoNetwork/friends/types"
pb "github.com/PretendoNetwork/grpc-go/account"
"github.com/PretendoNetwork/nex-go/v2"
nex_types "github.com/PretendoNetwork/nex-go/v2/types"
"github.com/PretendoNetwork/plogger-go"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
@ -66,11 +67,17 @@ func init() {
os.Exit(0)
}
globals.AuthenticationServerAccount = nex.NewAccount(nex_types.NewPID(1), "Quazal Authentication", authenticationServerPassword)
if strings.TrimSpace(secureServerPassword) == "" {
globals.Logger.Error("PN_FRIENDS_CONFIG_SECURE_PASSWORD environment variable not set")
os.Exit(0)
}
globals.SecureServerAccount = nex.NewAccount(nex_types.NewPID(2), "Quazal Rendez-Vous", secureServerPassword)
globals.GuestAccount = nex.NewAccount(nex_types.NewPID(100), "guest", "MMQea3n!fsik") // * Guest account password is always the same, known to all consoles
if strings.TrimSpace(aesKey) == "" {
globals.Logger.Error("PN_FRIENDS_CONFIG_AES_KEY environment variable not set")
os.Exit(0)

View File

@ -6,7 +6,6 @@ import (
"github.com/PretendoNetwork/friends/globals"
"github.com/PretendoNetwork/nex-go/v2"
"github.com/PretendoNetwork/nex-go/v2/types"
)
var serverBuildString string
@ -17,9 +16,9 @@ func StartAuthenticationServer() {
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.AuthenticationEndpoint.ServerAccount = nex.NewAccount(types.NewPID(1), "Quazal Authentication", os.Getenv("PN_FRIENDS_CONFIG_AUTHENTICATION_PASSWORD"))
registerCommonAuthenticationServerProtocols()

View File

@ -22,11 +22,9 @@ func StartSecureServer() {
globals.SecureServer = nex.NewPRUDPServer()
globals.SecureEndpoint = nex.NewPRUDPEndPoint(1)
globals.SecureEndpoint.ServerAccount = globals.SecureServerAccount
globals.SecureEndpoint.AccountDetailsByPID = globals.AccountDetailsByPID
globals.SecureEndpoint.AccountDetailsByUsername = globals.AccountDetailsByUsername
globals.SecureEndpoint.ServerAccount = nex.NewAccount(types.NewPID(2), "Quazal Rendez-Vous", os.Getenv("PN_FRIENDS_CONFIG_SECURE_PASSWORD"))
globals.GuestAccount = nex.NewAccount(types.NewPID(100), "guest", "MMQea3n!fsik") // * Guest account password is always the same, known to all consoles
globals.SecureEndpoint.OnConnectionEnded(func(connection *nex.PRUDPConnection) {
pid := connection.PID().LegacyValue()