Skip to content

Commit

Permalink
Merge pull request #29 from DaniElectra/nex-accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
jonbarrow authored Nov 6, 2024
2 parents 87db0af + 120776e commit 3377ef2
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
8 changes: 4 additions & 4 deletions globals/account_details_by_pid.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions globals/globals.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions init.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions nex/authentication.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()

Expand Down
4 changes: 1 addition & 3 deletions nex/secure.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 3377ef2

Please sign in to comment.