-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 12873ea
Showing
15 changed files
with
1,235 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
|
||
# Test binary, build with `go test -c` | ||
*.test | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
# custom | ||
.env | ||
|
||
# built server | ||
build | ||
|
||
# logs | ||
log/* |
Large diffs are not rendered by default.
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,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 := ironfall-invasion | ||
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/ironfall-invasion |
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,58 @@ | ||
# IRONFALL Invasion (3DS) replacement server | ||
Includes both the authentication and secure servers | ||
|
||
## 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/ironfall-invasion | ||
$ cd ironfall-invasion | ||
``` | ||
|
||
### 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/ironfall-invasion | ||
``` | ||
|
||
The server is now built to `build/ironfall-invasion` | ||
|
||
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/ironfall-invasion` | ||
|
||
## Configuration | ||
All configuration options are handled via environment variables | ||
|
||
`.env` files are supported | ||
|
||
| Name | Description | Required | | ||
|------------------------------------------|--------------------------------------------------------------------------------------------------------------------|-----------------------------------------------| | ||
| `PN_IRONFALL_KERBEROS_PASSWORD` | Password used as part of the internal server data in Kerberos tickets | No (Default password `password` will be used) | | ||
| `PN_IRONFALL_AUTHENTICATION_SERVER_PORT` | Port for the authentication server | Yes | | ||
| `PN_IRONFALL_SECURE_SERVER_HOST` | Host name for the secure server (should point to the same address as the authentication server) | Yes | | ||
| `PN_IRONFALL_SECURE_SERVER_PORT` | Port for the secure server | Yes | | ||
| `PN_IRONFALL_ACCOUNT_GRPC_HOST` | Host name for your account server gRPC service | Yes | | ||
| `PN_IRONFALL_ACCOUNT_GRPC_PORT` | Port for your account server gRPC service | Yes | | ||
| `PN_IRONFALL_ACCOUNT_GRPC_API_KEY` | API key for your account server gRPC service | No (Assumed to be an open gRPC API) | | ||
| `PN_IRONFALL_FRIENDS_GRPC_HOST` | Host name for your friends server gRPC service | Yes | | ||
| `PN_IRONFALL_FRIENDS_GRPC_PORT` | Port for your friends server gRPC service | Yes | | ||
| `PN_IRONFALL_FRIENDS_GRPC_API_KEY` | API key for your friends server gRPC service | No (Assumed to be an open gRPC API) | |
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,21 @@ | ||
package globals | ||
|
||
import ( | ||
"context" | ||
|
||
pb_friends "github.com/PretendoNetwork/grpc-go/friends" | ||
"github.com/PretendoNetwork/nex-protocols-go/globals" | ||
"google.golang.org/grpc/metadata" | ||
) | ||
|
||
func GetUserFriendPIDs(pid uint32) []uint32 { | ||
ctx := metadata.NewOutgoingContext(context.Background(), GRPCFriendsCommonMetadata) | ||
|
||
response, err := GRPCFriendsClient.GetUserFriendPIDs(ctx, &pb_friends.GetUserFriendPIDsRequest{Pid: pid}) | ||
if err != nil { | ||
globals.Logger.Error(err.Error()) | ||
return make([]uint32, 0) | ||
} | ||
|
||
return response.Pids | ||
} |
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,21 @@ | ||
package globals | ||
|
||
import ( | ||
pb_account "github.com/PretendoNetwork/grpc-go/account" | ||
pb_friends "github.com/PretendoNetwork/grpc-go/friends" | ||
"github.com/PretendoNetwork/nex-go" | ||
"github.com/PretendoNetwork/plogger-go" | ||
"google.golang.org/grpc" | ||
"google.golang.org/grpc/metadata" | ||
) | ||
|
||
var Logger = plogger.NewLogger() | ||
var KerberosPassword = "password" // * Default password | ||
var AuthenticationServer *nex.Server | ||
var SecureServer *nex.Server | ||
var GRPCAccountClientConnection *grpc.ClientConn | ||
var GRPCAccountClient pb_account.AccountClient | ||
var GRPCAccountCommonMetadata metadata.MD | ||
var GRPCFriendsClientConnection *grpc.ClientConn | ||
var GRPCFriendsClient pb_friends.FriendsClient | ||
var GRPCFriendsCommonMetadata metadata.MD |
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,28 @@ | ||
package globals | ||
|
||
import ( | ||
"context" | ||
|
||
pb_account "github.com/PretendoNetwork/grpc-go/account" | ||
"github.com/PretendoNetwork/nex-go" | ||
"github.com/PretendoNetwork/nex-protocols-go/globals" | ||
"google.golang.org/grpc/metadata" | ||
) | ||
|
||
func PasswordFromPID(pid uint32) (string, uint32) { | ||
ctx := metadata.NewOutgoingContext(context.Background(), GRPCAccountCommonMetadata) | ||
|
||
response, err := GRPCAccountClient.GetNEXData(ctx, &pb_account.GetNEXDataRequest{Pid: pid}) | ||
if err != nil { | ||
globals.Logger.Error(err.Error()) | ||
return "", nex.Errors.RendezVous.InvalidUsername | ||
} | ||
|
||
// * We only allow tester accounts for now | ||
if response.AccessLevel < 1 { | ||
globals.Logger.Errorf("PID %d is not a tester!", response.Pid) | ||
return "", nex.Errors.RendezVous.AccountDisabled | ||
} | ||
|
||
return response.Password, 0 | ||
} |
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,30 @@ | ||
module github.com/PretendoNetwork/ironfall-invasion | ||
|
||
go 1.19 | ||
|
||
require ( | ||
github.com/PretendoNetwork/grpc-go v1.0.2 | ||
github.com/PretendoNetwork/nex-go v1.0.41 | ||
github.com/PretendoNetwork/nex-protocols-common-go v1.0.29 | ||
github.com/PretendoNetwork/nex-protocols-go v1.0.55 | ||
github.com/PretendoNetwork/plogger-go v1.0.4 | ||
github.com/joho/godotenv v1.5.1 | ||
google.golang.org/grpc v1.59.0 | ||
) | ||
|
||
require ( | ||
github.com/fatih/color v1.15.0 // indirect | ||
github.com/golang/protobuf v1.5.3 // indirect | ||
github.com/jwalton/go-supportscolor v1.2.0 // indirect | ||
github.com/mattn/go-colorable v0.1.13 // indirect | ||
github.com/mattn/go-isatty v0.0.20 // indirect | ||
github.com/superwhiskers/crunch/v3 v3.5.7 // indirect | ||
golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect | ||
golang.org/x/mod v0.13.0 // indirect | ||
golang.org/x/net v0.17.0 // indirect | ||
golang.org/x/sys v0.13.0 // indirect | ||
golang.org/x/term v0.13.0 // indirect | ||
golang.org/x/text v0.13.0 // indirect | ||
google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b // indirect | ||
google.golang.org/protobuf v1.31.0 // indirect | ||
) |
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,54 @@ | ||
github.com/PretendoNetwork/grpc-go v1.0.2 h1:9TvKmX7dCOANyoHEra1MMYqS1N/RGav66TRG4SHInvo= | ||
github.com/PretendoNetwork/grpc-go v1.0.2/go.mod h1:XZjEsij9lL7HJBNkH6JPbBIkUSq/1rjflvjGdv+DAj0= | ||
github.com/PretendoNetwork/nex-go v1.0.41 h1:TcBb1Bpe2KAB+AXaGX1K9NVQBRtZJIoy4yCvRde2xbI= | ||
github.com/PretendoNetwork/nex-go v1.0.41/go.mod h1:QwHEa165DeVd0xIuthrgc3j6NWXT8lyPSG6t5kC/Shk= | ||
github.com/PretendoNetwork/nex-protocols-common-go v1.0.29 h1:ZvZNsAbdgWIGggZhn6EePuyYqI34FuV4C+fMkmmwWSA= | ||
github.com/PretendoNetwork/nex-protocols-common-go v1.0.29/go.mod h1:4jYhLg+Cb2qhJHyyA+f2OwCrmc98zuTO3JPWK22mIKw= | ||
github.com/PretendoNetwork/nex-protocols-go v1.0.55 h1:8QMeCNO2eZO4m7CRT/nv2WWm+gDh/REKR5jKTYQaaCs= | ||
github.com/PretendoNetwork/nex-protocols-go v1.0.55/go.mod h1:136762CMIcAsTZDrt4W7gDE4ppiBuc9zN2QFOHESjS8= | ||
github.com/PretendoNetwork/plogger-go v1.0.4 h1:PF7xHw9eDRHH+RsAP9tmAE7fG0N0p6H4iPwHKnsoXwc= | ||
github.com/PretendoNetwork/plogger-go v1.0.4/go.mod h1:7kD6M4vPq1JL4LTuPg6kuB1OvUBOwQOtAvTaUwMbwvU= | ||
github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= | ||
github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= | ||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= | ||
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= | ||
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= | ||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= | ||
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= | ||
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= | ||
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= | ||
github.com/jwalton/go-supportscolor v1.2.0 h1:g6Ha4u7Vm3LIsQ5wmeBpS4gazu0UP1DRDE8y6bre4H8= | ||
github.com/jwalton/go-supportscolor v1.2.0/go.mod h1:hFVUAZV2cWg+WFFC4v8pT2X/S2qUUBYMioBD9AINXGs= | ||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= | ||
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= | ||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= | ||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= | ||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= | ||
github.com/superwhiskers/crunch/v3 v3.5.7 h1:N9RLxaR65C36i26BUIpzPXGy2f6pQ7wisu2bawbKNqg= | ||
github.com/superwhiskers/crunch/v3 v3.5.7/go.mod h1:4ub2EKgF1MAhTjoOCTU4b9uLMsAweHEa89aRrfAypXA= | ||
golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI= | ||
golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo= | ||
golang.org/x/mod v0.13.0 h1:I/DsJXRlw/8l/0c24sM9yb0T4z9liZTduXvdAWYiysY= | ||
golang.org/x/mod v0.13.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= | ||
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= | ||
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= | ||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= | ||
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= | ||
golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek= | ||
golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= | ||
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= | ||
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= | ||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | ||
google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b h1:ZlWIi1wSK56/8hn4QcBp/j9M7Gt3U/3hZw3mC7vDICo= | ||
google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b/go.mod h1:swOH3j0KzcDDgGUWr+SNpyTen5YrXjS3eyPzFYKc6lc= | ||
google.golang.org/grpc v1.59.0 h1:Z5Iec2pjwb+LEOqzpB2MR12/eKFhDPhuqW91O+4bwUk= | ||
google.golang.org/grpc v1.59.0/go.mod h1:aUPDwccQo6OTjy7Hct4AfBPD1GptF4fyUjIkQ9YtF98= | ||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= | ||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= | ||
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= | ||
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= |
Oops, something went wrong.