-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from DaniElectra/rebase
Use common matchmaking protocols
- Loading branch information
Showing
67 changed files
with
651 additions
and
1,800 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# TODO - Assumes a UNIX-like OS | ||
|
||
RED := $(shell tput setaf 1) | ||
BLUE := $(shell tput setaf 4) | ||
CYAN := $(shell tput setaf 14) | ||
ORANGE := $(shell tput setaf 202) | ||
YELLOW := $(shell tput setaf 214) | ||
RESET := $(shell tput sgr0) | ||
|
||
ifeq ($(shell which go),) | ||
# TODO - Read contents from .git folder instead? | ||
$(error "$(RED)go command not found. Install go to continue $(BLUE)https://go.dev/doc/install$(RESET)") | ||
endif | ||
|
||
ifneq ($(wildcard .git),) | ||
# * .git folder exists, build server build string from repo info | ||
ifeq ($(shell which git),) | ||
# TODO - Read contents from .git folder instead? | ||
$(error "$(RED)git command not found. Install git to continue $(ORANGE)https://git-scm.com/downloads$(RESET)") | ||
endif | ||
$(info "$(CYAN)Building server build string from repository info$(RESET)") | ||
# * Build server build string from repo info | ||
BRANCH := $(shell git rev-parse --abbrev-ref HEAD) | ||
REMOTE_ORIGIN := $(shell git config --get remote.origin.url) | ||
|
||
# * Handle multiple origin URL formats | ||
HTTPS_PREFIX_CHECK := $(shell echo $(REMOTE_ORIGIN) | head -c 8) | ||
HTTP_PREFIX_CHECK := $(shell echo $(REMOTE_ORIGIN) | head -c 7) | ||
GIT@_PREFIX_CHECK := $(shell echo $(REMOTE_ORIGIN) | head -c 4) | ||
|
||
ifeq ($(HTTPS_PREFIX_CHECK), https://) | ||
REMOTE_PATH := $(shell echo $(REMOTE_ORIGIN) | cut -d/ -f4-) | ||
else ifeq ($(HTTP_PREFIX_CHECK), http://) | ||
REMOTE_PATH := $(shell echo $(REMOTE_ORIGIN) | cut -d/ -f4-) | ||
else ifeq ($(GIT@_PREFIX_CHECK), git@) | ||
REMOTE_PATH := $(shell echo $(REMOTE_ORIGIN) | cut -d: -f2-) | ||
else | ||
REMOTE_PATH := $(shell echo $(REMOTE_ORIGIN) | cut -d/ -f2-) | ||
endif | ||
|
||
HASH := $(shell git rev-parse --short HEAD) | ||
SERVER_BUILD := $(BRANCH):$(REMOTE_PATH)@$(HASH) | ||
|
||
else | ||
# * .git folder not present, assume downloaded from zip file and just use folder name | ||
$(info "$(CYAN)git repository not found. Building server build string from folder name$(RESET)") | ||
SERVER_BUILD := mario-kart-7 | ||
endif | ||
|
||
# * Final build string | ||
DATE_TIME := $(shell date --iso=seconds) | ||
BUILD_STRING := $(SERVER_BUILD), $(DATE_TIME) | ||
|
||
default: | ||
ifeq ($(wildcard .env),) | ||
$(warning "$(YELLOW).env file not found, environment variables may not be populated correctly$(RESET)") | ||
endif | ||
go get -u | ||
go mod tidy | ||
go build -ldflags "-X 'main.serverBuildString=$(BUILD_STRING)'" -o ./build/mario-kart-7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,56 @@ | ||
# Mario Kart 7 - Secure | ||
### Pretendo Mario Kart 7 secure server | ||
# Mario Kart 7 (3DS) replacement server | ||
Includes both the authentication and secure servers | ||
|
||
## About | ||
This server handles all of MK7's online functionality (incomplete). | ||
## Compiling | ||
|
||
### Setup | ||
Install [Go](https://go.dev/doc/install) and [git](https://git-scm.com/downloads), then clone and enter the repository | ||
|
||
```bash | ||
$ git clone https://github.com/PretendoNetwork/mario-kart-7 | ||
$ cd mario-kart-7 | ||
``` | ||
|
||
### Compiling using `go` | ||
To compile using Go, `go get` the required modules and then `go build` to your desired location. You may also want to tidy the go modules, though this is optional | ||
|
||
```bash | ||
$ go get -u | ||
$ go mod tidy | ||
$ go build -o build/mario-kart-7 | ||
``` | ||
|
||
The server is now built to `build/mario-kart-7` | ||
|
||
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 | ||
|
||
To compile the servers with the authentication server build string, add `-ldflags "-X 'main.serverBuildString=BUILD_STRING_HERE'"` to the build command, or use `make` to compile the server | ||
|
||
### Compiling using `make` | ||
Compiling using `make` will read the local `.git` directory to create a dynamic authentication server build string, based on your repositories remote origin and current commit | ||
|
||
Install `make` either through your systems package manager or the [official download](https://www.gnu.org/software/make/). We provide a `default` rule which compiles [using `go`](#compiling-using-go) | ||
|
||
To build using `go` | ||
|
||
```bash | ||
$ make | ||
``` | ||
|
||
The server is now built to `build/mario-kart-7` | ||
|
||
## Configuration | ||
All configuration options are handled via environment variables | ||
|
||
`.env` files are supported | ||
|
||
| Name | Description | Required | | ||
|-------------------------------------|------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------| | ||
| `PN_MK7_POSTGRES_URI` | Fully qualified URI to your Postgres server (Example `postgres://username:password@localhost/mk7?sslmode=disable`) | Yes | | ||
| `PN_MK7_KERBEROS_PASSWORD` | Password used as part of the internal server data in Kerberos tickets | No (Default password `password` will be used) | | ||
| `PN_MK7_AUTHENTICATION_SERVER_PORT` | Port for the authentication server | Yes | | ||
| `PN_MK7_SECURE_SERVER_HOST` | Host name for the secure server (should point to the same address as the authentication server) | Yes | | ||
| `PN_MK7_SECURE_SERVER_PORT` | Port for the secure server | Yes | | ||
| `PN_MK7_ACCOUNT_GRPC_HOST` | Host name for your account server gRPC service | Yes | | ||
| `PN_MK7_ACCOUNT_GRPC_PORT` | Port for your account server gRPC service | Yes | | ||
| `PN_MK7_ACCOUNT_GRPC_API_KEY` | API key for your account server gRPC service | No (Assumed to be an open gRPC API) | |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package database | ||
|
||
import ( | ||
"database/sql" | ||
"os" | ||
|
||
_ "github.com/lib/pq" | ||
|
||
"github.com/PretendoNetwork/mario-kart-7/globals" | ||
) | ||
|
||
var Postgres *sql.DB | ||
|
||
func ConnectPostgres() { | ||
var err error | ||
|
||
Postgres, err = sql.Open("postgres", os.Getenv("PN_MK7_POSTGRES_URI")) | ||
if err != nil { | ||
globals.Logger.Critical(err.Error()) | ||
} | ||
|
||
globals.Logger.Success("Connected to Postgres!") | ||
|
||
initPostgres() | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.