Compare commits

...

8 Commits

Author SHA1 Message Date
maru
36f353b8a6
Clean up db.go 2024-05-11 02:30:20 -04:00
maru
5656fb96d1
Use log.Fatal isntead of panic 2024-05-11 02:24:20 -04:00
Up
dd013a1626
Merge pull request #8 from cgnetsec/master 2024-05-11 05:44:57 +02:00
ser3n1ty
8c209163db
Update README.md 2024-05-10 20:38:28 -07:00
ser3n1ty
1cec1d313d
Update README.md 2024-05-10 20:36:03 -07:00
ser3n1ty
e01364e1a6
Update README.md 2024-05-09 01:44:04 -07:00
ser3n1ty
d5e7b438f3
Update README.md
added updated information for the docker compose container that is being implemented
2024-05-09 00:57:07 -07:00
ser3n1ty
b00321f501
Update README.md 2024-05-09 00:51:44 -07:00
2 changed files with 89 additions and 10 deletions

View File

@ -1 +1,83 @@
# rogueserver
# rogueserver
# Hosting in Docker
It is advised that you host this in a docker container as it will be much easier to manage.
There is a sample docker-compose file for setting up a docker container to setup this server.
# Self Hosting outside of Docker:
## Required Tools:
- Golang
- Node: **18.3.0**
- npm: [how to install](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm)
## Installation:
The docker compose file should automatically implement a container with mariadb with an empty database and the default user and password combo of pokerogue:pokerogue
### src/utils.ts:224-225 (in pokerogue)
Replace both URLs (one on each line) with the local API server address from rogueserver.go (0.0.0.0:8001) (or whatever port you picked)
# If you are on Windows
Now that all of the files are configured: start up powershell as administrator:
```
cd C:\api\server\location\
go build .
.\rogueserver.exe --debug --dbuser yourusername --dbpass yourpassword
```
The other available flags are located in rogueserver.go:34-43.
Then in another run this the first time then run `npm run start` from the rogueserver location from then on:
```
powershell -ep bypass
cd C:\server\location\
npm install
npm run start
```
You will need to allow the port youre running the API (8001) on and port 8000 to accept inbound connections through the [Windows Advanced Firewall](https://www.youtube.com/watch?v=9llH5_CON-Y).
# If you are on Linux
In whatever shell you prefer, run the following:
```
cd /api/server/location/
go build .
./rogueserver --debug --dbuser yourusername --dbpass yourpassword &
cd /server/location/
npm run start
```
If you have a firewall running such as ufw on your linux machine, make sure to allow inbound connections on the ports youre running the API and the pokerogue server (8000,8001).
An example to allow incoming connections using UFW:
```
sudo ufw allow 8000,8001/tcp
```
This should allow you to reach the game from other computers on the same network.
## Tying to a Domain
If you want to tie it to a domain like I did and make it publicly accessible, there is some extra work to be done.
I setup caddy and would recommend using it as a reverse proxy.
[caddy installation](https://caddyserver.com/docs/install)
once its installed setup a config file for caddy:
```
pokerogue.exampledomain.com {
reverse_proxy localhost:8000
}
pokeapi.exampledomain.com {
reverse_proxy localhost:8001
}
```
Preferably set up caddy as a service from [here.](https://caddyserver.com/docs/running)
Once this is good to go, take your API url (https://pokeapi.exampledomain.com) and paste it on
### src/utils.ts:224-225
in place of the previous 0.0.0.0:8001 address
Make sure that both 8000 and 8001 are portforwarded on your router.
Test that the server's game and game authentication works from other machines both in and outside of the network. Once this is complete, enjoy!

View File

@ -50,7 +50,7 @@ func Init(username, password, protocol, address, database string) error {
tx, err := handle.Begin()
if err != nil {
panic(err)
log.Fatal(err)
}
// accounts
@ -83,24 +83,22 @@ func Init(username, password, protocol, address, database string) error {
err = tx.Commit()
if err != nil {
panic(err)
log.Fatal(err)
}
// TODO temp code
_, err = os.Stat("userdata")
if err != nil {
if os.IsNotExist(err) { // not found, do not migrate
return nil
} else {
if !os.IsNotExist(err) { // not found, do not migrate
log.Fatalf("failed to stat userdata directory: %s", err)
return err
}
return nil
}
entries, err := os.ReadDir("userdata")
if err != nil {
log.Fatalln(err)
return nil
log.Fatal(err)
}
for _, entry := range entries {
@ -131,7 +129,6 @@ func Init(username, password, protocol, address, database string) error {
err = StoreSystemSaveData(uuid, systemData)
if err != nil {
log.Fatalf("failed to store system save data for %v: %s\n", uuidString, err)
continue
}
// delete old system data