Skip to content

Commit 3276d1e

Browse files
committed
Update with new nex-go
1 parent 8287789 commit 3276d1e

30 files changed

+417
-700
lines changed

.DS_Store

-6 KB
Binary file not shown.

LICENSE

100755100644
File mode changed.

Makefile

100755100644
File mode changed.

README.md

100755100644
+16-17
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
# Luigi's Mansion: Dark Moon (Luigi's Mansion 2) replacement server
22
Includes both the authentication and secure servers
33

4-
## Status
5-
This does not work well at all. Sometimes, a room can be started, but on attempting to fetch the room list, the game crashes.
6-
74
## Compiling
85

96
### Setup
@@ -29,8 +26,8 @@ Create a `.env` file with all of the necessary environment variables set. The va
2926

3027
Example:
3128
```
32-
PN_LUIGISMANSION2_POSTGRES_URI=postgres://username:password@localhost/luigismansion2?sslmode=disable
33-
PN_LUIGISMANSION2_AUTHENTICATION_SERVER_PORT=61001
29+
PN_LM2_KERBEROS_PASSWORD=yourpassword
30+
PN_LM2_AUTHENTICATION_SERVER_PORT=61001
3431
...
3532
```
3633

@@ -47,10 +44,10 @@ To compile using Go, `go get` the required modules and then `go build` to your d
4744
```bash
4845
$ go get -u
4946
$ go mod tidy
50-
$ go build -o build/luigismansion2
47+
$ go build -o build/luigis-mansion-2
5148
```
5249

53-
The server is now built to `build/luigismansion2`
50+
The server is now built to `build/luigis-mansion-2`
5451

5552
When compiling with only Go, the authentication servers build string is not automatically set. This should not cause any issues with gameplay, but it means that the server build will not be visible in any packet dumps or logs a title may produce
5653

@@ -72,13 +69,15 @@ All configuration options are handled via environment variables
7269

7370
`.env` files are supported
7471

75-
| Name | Description | Required |
76-
|-----------------------------------------|------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------|
77-
| `PN_LUIGISMANSION2_POSTGRES_URI` | Fully qualified URI to your Postgres server (Example `postgres://username:password@localhost/luigismansion2?sslmode=disable`) | Yes |
78-
| `PN_LUIGISMANSION2_KERBEROS_PASSWORD` | Password used as part of the internal server data in Kerberos tickets | No (Default password `password` will be used) |
79-
| `PN_LUIGISMANSION2_AUTHENTICATION_SERVER_PORT` | Port for the authentication server | Yes |
80-
| `PN_LUIGISMANSION2_SECURE_SERVER_HOST` | Host name for the secure server (should point to the same address as the authentication server) | Yes |
81-
| `PN_LUIGISMANSION2_SECURE_SERVER_PORT` | Port for the secure server | Yes |
82-
| `PN_LUIGISMANSION2_ACCOUNT_GRPC_HOST` | Host name for your account server gRPC service | Yes |
83-
| `PN_LUIGISMANSION2_ACCOUNT_GRPC_PORT` | Port for your account server gRPC service | Yes |
84-
| `PN_LUIGISMANSION2_ACCOUNT_GRPC_API_KEY` | API key for your account server gRPC service | No (Assumed to be an open gRPC API) |
72+
| Name | Description | Required |
73+
|-------------------------------------|------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------|
74+
| `PN_LM2_KERBEROS_PASSWORD` | Password used as part of the internal server data in Kerberos tickets | No (Default password `password` will be used) |
75+
| `PN_LM2_AUTHENTICATION_SERVER_PORT` | Port for the authentication server | Yes |
76+
| `PN_LM2_SECURE_SERVER_HOST` | Host name for the secure server (should point to the same address as the authentication server) | Yes |
77+
| `PN_LM2_SECURE_SERVER_PORT` | Port for the secure server | Yes |
78+
| `PN_LM2_ACCOUNT_GRPC_HOST` | Host name for your account server gRPC service | Yes |
79+
| `PN_LM2_ACCOUNT_GRPC_PORT` | Port for your account server gRPC service | Yes |
80+
| `PN_LM2_ACCOUNT_GRPC_API_KEY` | API key for your account server gRPC service | No (Assumed to be an open gRPC API) |
81+
| `PN_LM2_FRIENDS_GRPC_HOST` | Host name for your friends server gRPC service | Yes |
82+
| `PN_LM2_FRIENDS_GRPC_PORT` | Port for your friends server gRPC service | Yes |
83+
| `PN_LM2_FRIENDS_GRPC_API_KEY` | API key for your friends server gRPC service | No (Assumed to be an open gRPC API) |

database/create_room.go

-29
This file was deleted.

database/database.go

-24
This file was deleted.

database/destory_room.go

-13
This file was deleted.

database/get_room_by_gid.go

-37
This file was deleted.

database/get_rooms.go

-41
This file was deleted.

database/init_sqlite.go

-26
This file was deleted.

database/join_room.go

-42
This file was deleted.

database/leave_room.go

-40
This file was deleted.

globals/accounts.go

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package globals
2+
3+
import (
4+
"strconv"
5+
6+
"github.com/PretendoNetwork/nex-go"
7+
"github.com/PretendoNetwork/nex-go/types"
8+
)
9+
10+
var AuthenticationServerAccount *nex.Account
11+
var SecureServerAccount *nex.Account
12+
13+
func AccountDetailsByPID(pid *types.PID) (*nex.Account, *nex.Error) {
14+
if pid.Equals(AuthenticationServerAccount.PID) {
15+
return AuthenticationServerAccount, nil
16+
}
17+
18+
if pid.Equals(SecureServerAccount.PID) {
19+
return SecureServerAccount, nil
20+
}
21+
22+
password, errorCode := PasswordFromPID(pid)
23+
if errorCode != 0 {
24+
return nil, nex.NewError(errorCode, "Failed to get password from PID")
25+
}
26+
27+
account := nex.NewAccount(pid, strconv.Itoa(int(pid.LegacyValue())), password)
28+
29+
return account, nil
30+
}
31+
32+
func AccountDetailsByUsername(username string) (*nex.Account, *nex.Error) {
33+
if username == AuthenticationServerAccount.Username {
34+
return AuthenticationServerAccount, nil
35+
}
36+
37+
if username == SecureServerAccount.Username {
38+
return SecureServerAccount, nil
39+
}
40+
41+
pidInt, err := strconv.Atoi(username)
42+
if err != nil {
43+
return nil, nex.NewError(nex.ResultCodes.RendezVous.InvalidUsername, "Invalid username")
44+
}
45+
46+
pid := types.NewPID(uint64(pidInt))
47+
48+
password, errorCode := PasswordFromPID(pid)
49+
if errorCode != 0 {
50+
return nil, nex.NewError(errorCode, "Failed to get password from PID")
51+
}
52+
53+
account := nex.NewAccount(pid, username, password)
54+
55+
return account, nil
56+
}

globals/get_user_friend_pids.go

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package globals
2+
3+
import (
4+
"context"
5+
6+
pb_friends "github.com/PretendoNetwork/grpc-go/friends"
7+
"github.com/PretendoNetwork/nex-protocols-go/globals"
8+
"google.golang.org/grpc/metadata"
9+
)
10+
11+
func GetUserFriendPIDs(pid uint32) []uint32 {
12+
ctx := metadata.NewOutgoingContext(context.Background(), GRPCFriendsCommonMetadata)
13+
14+
response, err := GRPCFriendsClient.GetUserFriendPIDs(ctx, &pb_friends.GetUserFriendPIDsRequest{Pid: pid})
15+
if err != nil {
16+
globals.Logger.Error(err.Error())
17+
return make([]uint32, 0)
18+
}
19+
20+
return response.Pids
21+
}

0 commit comments

Comments
 (0)