Create WIP Super Mario Maker server configuration

This commit is contained in:
Matthew Lopez
2024-02-22 15:27:30 -05:00
parent c1de30f04f
commit 41bfc9cd3f
11 changed files with 131 additions and 33 deletions

View File

@@ -375,6 +375,30 @@ services:
- ./environment/wiiu-chat.env
- ./environment/wiiu-chat.local.env
# WIP: Does not work yet
super-mario-maker:
build: ./repos/super-mario-maker
depends_on:
- account
- minio
- postgres
restart: unless-stopped
ports:
# Authentication server
- 6004:6004/udp
# Secure server
- 6005:6005/udp
volumes:
- type: bind
source: ./logs/super-mario-maker/
target: /app/log/
networks:
internal:
dns: 172.20.0.200
env_file:
- ./environment/super-mario-maker.env
- ./environment/super-mario-maker.local.env
volumes:
mitmproxy-pretendo-data:
mongodb-database:

View File

@@ -0,0 +1,7 @@
PN_SMM_AUTHENTICATION_SERVER_PORT=6004
PN_SMM_SECURE_SERVER_PORT=6005
PN_SMM_CONFIG_S3_ENDPOINT=minio:9000
PN_SMM_CONFIG_S3_ACCESS_KEY=minio_pretendo
PN_SMM_CONFIG_S3_BUCKET=super-mario-maker
PN_SMM_ACCOUNT_GRPC_HOST=account
PN_SMM_ACCOUNT_GRPC_PORT=5000

View File

View File

@@ -0,0 +1,33 @@
diff --git i/database/init_postgres.go w/database/init_postgres.go
index c211c98..3aaffcf 100644
--- i/database/init_postgres.go
+++ w/database/init_postgres.go
@@ -1,11 +1,14 @@
package database
import (
+ "context"
"os"
+ "strings"
"time"
"github.com/PretendoNetwork/super-mario-maker-secure/globals"
"github.com/lib/pq"
+ "github.com/minio/minio-go/v7"
)
func initPostgres() {
@@ -162,8 +165,11 @@ func ensureEventCourseMetaDataFileExists() {
objectSizeS3, err := globals.S3ObjectSize(bucket, key)
if err != nil {
- globals.Logger.Errorf("Failed to stat event course metadata file. Ensure your S3 credentials are correct and the 900000.bin file is uploaded to your bucket. S3 error: %s", err.Error())
- os.Exit(0)
+ _, err = globals.MinIOClient.PutObject(context.TODO(), bucket, key, strings.NewReader(""), 0, minio.PutObjectOptions{ContentType: "application/octet-stream"})
+ if err != nil {
+ globals.Logger.Errorf("Failed to stat event course metadata file. Ensure your S3 credentials are correct and the 900000.bin file is uploaded to your bucket. S3 error: %s", err.Error())
+ os.Exit(0)
+ }
}
globals.Logger.Success("Event course metadata file found. Verifying database")

View File

@@ -0,0 +1,20 @@
diff --git c/Dockerfile i/Dockerfile
new file mode 100644
index 0000000..0f18fe9
--- /dev/null
+++ i/Dockerfile
@@ -0,0 +1,14 @@
+FROM golang:alpine AS builder
+WORKDIR /build
+
+COPY go.* ./
+RUN go mod download
+
+COPY . ./
+RUN go build -v -o server
+
+FROM alpine:latest AS runner
+WORKDIR /app
+
+COPY --from=builder /build/server /app/server
+CMD ["/app/server"]

View File

@@ -0,0 +1,22 @@
diff --git i/init.go w/init.go
index 07cd1aa..9209ef6 100644
--- i/init.go
+++ w/init.go
@@ -23,7 +23,7 @@ func init() {
err = godotenv.Load()
if err != nil {
- log.Fatal("Error loading .env file")
+ log.Println("Error loading .env file")
}
s3Endpoint := os.Getenv("PN_SMM_CONFIG_S3_ENDPOINT")
@@ -118,7 +118,7 @@ func init() {
minIOClient, err := minio.New(s3Endpoint, &minio.Options{
Creds: staticCredentials,
- Secure: true,
+ Secure: false,
})
if err != nil {
panic(err)

View File

@@ -7,7 +7,7 @@ while ! mc alias set minio http://minio:9000 "$MINIO_ROOT_USER" "$MINIO_ROOT_PAS
sleep 1
done
buckets="pn-cdn pn-boss"
buckets="pn-cdn pn-boss super-mario-maker"
# Create buckets and allow public access
for bucket in $buckets; do

View File

@@ -2,7 +2,7 @@
set -eu
databases="friends"
databases="friends super_mario_maker"
for database in $databases; do
echo "Creating database: $database"

View File

@@ -62,6 +62,15 @@ async function runAsync() {
// Wii U Chat server doesn't seem to care about the AES key
"0".repeat(64)
);
await createNexServer(
"Super Mario Maker",
"1018DB00",
["000500001018DB00", "000500001018DC00", "000500001018DD00"],
process.env.SERVER_IP,
process.env.SMM_PORT,
1,
"0".repeat(64)
);
await mongoose.connection.close();
}
@@ -75,24 +84,10 @@ async function resetServers() {
await Server.deleteMany({});
}
async function createNexServer(
service_name,
game_server_id,
title_ids,
ip,
port,
device,
aes_key
) {
async function createNexServer(service_name, game_server_id, title_ids, ip, port, device, aes_key) {
for (const arg of arguments) {
if (!arg && arg !== 0 && arg !== false) {
throw new Error(
`Missing argument in new NEX server:\n${JSON.stringify(
arguments,
null,
2
)}`
);
throw new Error(`Missing argument in new NEX server:\n${JSON.stringify(arguments, null, 2)}`);
}
}
@@ -116,22 +111,10 @@ async function createNexServer(
}
}
async function createServiceServer(
service_name,
client_id,
title_ids,
device,
aes_key
) {
async function createServiceServer(service_name, client_id, title_ids, device, aes_key) {
for (const arg of arguments) {
if (!arg && arg !== 0 && arg !== false) {
throw new Error(
`Missing argument in new service server:\n${JSON.stringify(
arguments,
null,
2
)}`
);
throw new Error(`Missing argument in new service server:\n${JSON.stringify(arguments, null, 2)}`);
}
}

View File

@@ -64,6 +64,7 @@ echo "PN_FRIENDS_ACCOUNT_GRPC_API_KEY=$account_grpc_api_key" >>./friends.local.e
echo "PN_MIIVERSE_API_CONFIG_GRPC_ACCOUNT_API_KEY=$account_grpc_api_key" >>./miiverse-api.local.env
echo "JUXT_CONFIG_GRPC_ACCOUNT_API_KEY=$account_grpc_api_key" >>./juxtaposition-ui.local.env
echo "PN_BOSS_CONFIG_GRPC_ACCOUNT_SERVER_API_KEY=$account_grpc_api_key" >>./boss.local.env
echo "PN_SMM_ACCOUNT_GRPC_API_KEY=$account_grpc_api_key" >>./super-mario-maker.local.env
# Generate a secret key for MinIO
minio_secret_key=$(generate_password 32)
@@ -72,11 +73,13 @@ echo "PN_ACT_CONFIG_S3_ACCESS_SECRET=$minio_secret_key" >>./account.local.env
echo "PN_MIIVERSE_API_CONFIG_S3_ACCESS_SECRET=$minio_secret_key" >>./miiverse-api.local.env
echo "JUXT_CONFIG_AWS_SPACES_SECRET=$minio_secret_key" >>./juxtaposition-ui.local.env
echo "PN_BOSS_CONFIG_S3_ACCESS_SECRET=$minio_secret_key" >>./boss.local.env
echo "PN_SMM_CONFIG_S3_ACCESS_SECRET=$minio_secret_key" >>./super-mario-maker.local.env
# Generate a password for Postgres
postgres_password=$(generate_password 32)
echo "POSTGRES_PASSWORD=$postgres_password" >>./postgres.local.env
echo "PN_FRIENDS_CONFIG_DATABASE_URI=postgres://postgres_pretendo:$postgres_password@postgres/friends?sslmode=disable" >>./friends.local.env
echo "PN_SMM_POSTGRES_URI=postgres://postgres_pretendo:$postgres_password@postgres/super_mario_maker?sslmode=disable" >>./super-mario-maker.local.env
# Generate a Kerberos password, a gRPC API key, and an AES key for the friends
# server
@@ -94,6 +97,10 @@ echo "PN_FRIENDS_CONFIG_AES_KEY=$friends_aes_key" >>./friends.local.env
chat_kerberos_password=$(generate_password 32)
echo "PN_WIIU_CHAT_KERBEROS_PASSWORD=$chat_kerberos_password" >>./wiiu-chat.local.env
# Generate a Kerberos password for the Super Mario Maker server
smm_kerberos_password=$(generate_password 32)
echo "PN_SMM_KERBEROS_PASSWORD=$smm_kerberos_password" >>./super-mario-maker.local.env
# Generate an AES key for the Miiverse servers
miiverse_aes_key=$(generate_hex 64)
echo "PN_MIIVERSE_API_CONFIG_AES_KEY=$miiverse_aes_key" >>./miiverse-api.local.env
@@ -108,6 +115,7 @@ info "Using server IP address $server_ip."
echo "SERVER_IP=$server_ip" >>./system.local.env
echo "PN_FRIENDS_SECURE_SERVER_HOST=$server_ip" >>./friends.local.env
echo "PN_WIIU_CHAT_SECURE_SERVER_LOCATION=$server_ip" >>./wiiu-chat.local.env
echo "PN_SMM_SECURE_SERVER_HOST=$server_ip" >>./super-mario-maker.local.env
# Get the Wii U IP address
if [ -n "$wiiu_ip" ]; then

View File

@@ -12,7 +12,7 @@ if [ ! -f "$git_base/environment/system.local.env" ]; then
fi
. "$git_base/environment/system.local.env"
necessary_environment_files="friends miiverse-api wiiu-chat"
necessary_environment_files="friends miiverse-api wiiu-chat super-mario-maker"
for environment in $necessary_environment_files; do
if [ ! -f "$git_base/environment/$environment.local.env" ]; then
error "Missing environment file $environment.local.env. Did you run setup-environment.sh?"
@@ -29,4 +29,5 @@ docker compose exec -e SERVER_IP="$SERVER_IP" \
-e FRIENDS_AES_KEY="$PN_FRIENDS_CONFIG_AES_KEY" \
-e MIIVERSE_AES_KEY="$PN_MIIVERSE_API_CONFIG_AES_KEY" \
-e WIIU_CHAT_PORT="$PN_WIIU_CHAT_AUTHENTICATION_SERVER_PORT" \
-e SMM_PORT="$PN_SMM_AUTHENTICATION_SERVER_PORT" \
account node -e "$create_server_script"