From d6fdde6161224ef14dff02a458c149f92c0a9a9d Mon Sep 17 00:00:00 2001 From: Jonathan Barrow Date: Mon, 8 Apr 2024 16:23:06 -0400 Subject: [PATCH] chore: add guest account --- globals/account_details_by_pid.go | 4 ++++ globals/account_details_by_username.go | 4 ++++ globals/globals.go | 1 + nex/secure.go | 2 ++ 4 files changed, 11 insertions(+) diff --git a/globals/account_details_by_pid.go b/globals/account_details_by_pid.go index 1efecad..3741225 100644 --- a/globals/account_details_by_pid.go +++ b/globals/account_details_by_pid.go @@ -19,6 +19,10 @@ func AccountDetailsByPID(pid *types.PID) (*nex.Account, *nex.Error) { return SecureEndpoint.ServerAccount, nil } + if pid.Equals(GuestAccount.PID) { + return GuestAccount, nil + } + ctx := metadata.NewOutgoingContext(context.Background(), GRPCAccountCommonMetadata) response, err := GRPCAccountClient.GetNEXPassword(ctx, &pb.GetNEXPasswordRequest{Pid: pid.LegacyValue()}) diff --git a/globals/account_details_by_username.go b/globals/account_details_by_username.go index d439134..f8a19dd 100644 --- a/globals/account_details_by_username.go +++ b/globals/account_details_by_username.go @@ -20,6 +20,10 @@ func AccountDetailsByUsername(username string) (*nex.Account, *nex.Error) { return SecureEndpoint.ServerAccount, nil } + if username == GuestAccount.Username { + return GuestAccount, nil + } + // TODO - This is fine for our needs, but not for servers which use non-PID usernames? pid, err := strconv.Atoi(username) if err != nil { diff --git a/globals/globals.go b/globals/globals.go index 382810e..abbfc3d 100644 --- a/globals/globals.go +++ b/globals/globals.go @@ -10,6 +10,7 @@ import ( ) var Logger *plogger.Logger +var GuestAccount *nex.Account var KerberosPassword = "password" // * Default password var AuthenticationServer *nex.PRUDPServer var AuthenticationEndpoint *nex.PRUDPEndPoint diff --git a/nex/secure.go b/nex/secure.go index 27905c6..547fd52 100644 --- a/nex/secure.go +++ b/nex/secure.go @@ -26,6 +26,8 @@ func StartSecureServer() { 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()