Persistence #1 featuring quill (#508)

* Add .scalafmt.conf

* Adopt quill for database access

* Removed postgresql-async
* Refactored all instances of database access
* Creating duplicate characters of the same account is no longer possible
* Rewrote large parts of LoginSessionActor

* Implement migrations

* Move overrides into subdirectory

* Make usernames case insensitive

* Use LOWER(?) comparison instead of storing lowercased username

* import scala.util.{Success, Failure}

* Add config and joda-time dependencies

* Add sbt-scalafmt

* Use defaultWithAlign scalafmt preset

* Format all

* Add scalafix

* Remove unused imports

* Don't lowercase username when inserting

* Update readme

* Listen on worldserver.Hostname address

* Remove database test on startup

It could fail when the global thread pool is busy loading zone
maps. Migrations run on the main thread and also serve the
purpose of verifying the database configuration so it's fine to
remove the test altogether.

* Refactor chat message handlers, zones

What started as a small change to how zones are stored turned
into a pretty big effort of refactoring the chat message handler.
The !hack command was removed, the /capturebase commandwas added.

* Expose db ports in docker-compose.yml

* Silence property override log

* Rework configuration

* Unify configuration using the typesafe.config library
* Add configuration option for public address
* Configuration is now loaded from application.conf rather than worldserver.ini
* Refactor PsLogin and remove unnecessary logging
* Move pslogin into net.psforever.pslogin namespace

* Fix coverage
This commit is contained in:
Jakob Gillich 2020-07-14 05:54:05 +02:00 committed by GitHub
parent 88b194fde2
commit e0defe8240
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
850 changed files with 144487 additions and 47476 deletions

View file

@ -38,6 +38,5 @@
</root>
<!-- Logger specific overrides -->
<logger name="com.github.mauricio.async" level="OFF"/>
<logger name="oshi" level="OFF"/>
</configuration>

View file

@ -1,259 +0,0 @@
#######################################
# PSForever Server configuration file #
#######################################
###################################################################################################
# EXAMPLE CONFIG
#
# Variable (type)
# Description: Brief description what the variable is doing.
# Important: Annotation for important things about this variable.
# Example: "Example, i.e. if the value is a string"
# Range: [0, 10] - (Disabled, Enabled)
# Default: 10 - (Enabled|Comment|Variable name in case of grouped config options)
# 0 - (Disabled|Comment|Variable name in case of grouped config options)
#
# Note to developers:
# - Copy this example to keep the formatting.
# - Line breaks should be at column 100.
###################################################################################################
###################################################################################################
# DATABASE SETTINGS
###################################################################################################
[database]
# Hostname (string)
# Description: The hostname of the PostgreSQL server.
# Important: Make sure your database isn't accessible outside of localhost without a
# strong username and password!
# Default: "localhost"
Hostname = "localhost"
# Port (int)
# Description: The TCP port to connect to the database with.
# Range: [1, 65535] - (TCP port 1, TCP port 65535)
# Default: 5432 - (Connect to TCP port 5432 -- the default for PostgreSQL)
Port = 5432
# SSL (enum)
# Description: The SSL configuration of the database connection.
# Values: Disable - (Do not use SSL -- not recommended for public servers)
# Prefer - (Try SSL first, but fallback to unencrypted)
# Require - (Use SSL and fail if it is not enabled or configured correctly
# Verify - (Use SSL and verify that the certificate is authentic)
# Default: Prefer
SSL = Prefer
# Database (string)
# Description: The database name to use on the SQL server.
# Important: Make sure your username has been GRANTed ALL PRIVILEGES to the database.
# See the setup documentation for instructions on achieving this.
# Default: "psforever"
Database = "psforever"
# Username (string)
# Description: The username to connect to the SQL server with.
# Default: "psforever"
Username = "psforever"
# Password (string)
# Description: The password to connect to the SQL server with.
# Important: CHANGE THIS PASSWORD BEFORE RUNNING A PUBLIC SERVER.
# Default: "psforever"
Password = "psforever"
###################################################################################################
# WORLDSERVER SETTINGS
###################################################################################################
[worldserver]
# ListeningPort (int)
# Description: The UDP listening port for the worldserver.
# Important: Must be different from the loginserver.ListeningPort. Ports below 1024 are
# privileged on Linux and may require root.
# Range: [1, 65535] - (UDP port 1, UDP port 65535)
# Default: 51001 - (Listen on UDP port 51001)
ListeningPort = 51001
# Hostname (string)
# Description: The server's public hostname or IP address. Required when the server is
# behind a proxy or running in a container/virtual machine.
# Important: If left as the default, the hostname will be the same as the primary
# internet interface.
# Default: ""
Hostname = ""
# ServerName (string)
# Description: The name of the server as displayed in the server browser.
# Range: Length = [1, 31]
# Default: "PSForever"
ServerName = "PSForever"
# ServerType (enum)
# Description: How the server is displayed in the server browser.
# Values: Released, Beta, Development
# Default: Released
ServerType = Released
###################################################################################################
# LOGINSERVER SETTINGS
###################################################################################################
[loginserver]
# ListeningPort (int)
# Description: The UDP listening port for the loginserver.
# Important: Must be different from the worldserver.ListeningPort. Ports below 1024 are
# privileged on Linux and may require root.
# Range: [1, 65535] - (UDP port 1, UDP port 65535)
# Default: 51000 - (Listen on UDP port 51000)
ListeningPort = 51000
# CreateMissingAccounts (boolean)
# Description: Account usernames that don't exist yet will be automatically created in the
# database. Useful for test servers and development testing.
# Important: Not recommended for production servers as typos are easy to make on
# first registration. Use PSFPortal (https://github.com/psforever/PSFPortal)
# instead.
# Default: yes - (Enabled)
# no - (Disabled)
CreateMissingAccounts = yes
###################################################################################################
# PSADMIN SETTINGS
###################################################################################################
[psadmin]
# ListeningPort (int)
# Description: The TCP listening port for the server admin interface.
# Important: Must be different from the worldserver and loginserver ListeningPort.
# Ports below 1024 are privileged on Linux and may require root.
# NEVER EXPOSE THIS PORT TO THE INTERNET! CHECK YOUR FIREWALL CONFIG.
# Range: [1, 65535] - (TCP port 1, TCP port 65535)
# Default: 51002 - (Listen on TCP port 51002)
ListeningPort = 51002
###################################################################################################
# NETWORK SETTINGS
###################################################################################################
[network]
# Session.InboundGraceTime (time)
# Description: The maximum amount of time since the last inbound packet from a UDP session
# before it is dropped.
# Important: Lower values will cause legitimate clients to be dropped during loading
# screens, but higher values will make the server be more susceptible to
# denial of service attacks and running out of memory.
# Range: [10 seconds, 10 minutes] - (10 second grace, 10 minute grace)
# Default: 1 minute - (Clients sending a packet at least
# once a minute stay alive)
Session.InboundGraceTime = 1 minute
# Session.OutboundGraceTime (time)
# Description: The maximum amount of time since the last outbound packet for a UDP session
# before it is dropped. Can be used as a watchdog for hung server sessions.
# Important: Lower values will cause legitimate clients to be dropped during server
# lag spikes or Zone transitions.
# Range: [10 seconds, 10 minutes] - (10 second grace, 10 minute grace)
# Default: 1 minute - (Clients receiving a packet at least
# once a minute stay alive)
Session.OutboundGraceTime = 1 minute
###################################################################################################
# DEVELOPER SETTINGS
# - NETWORK SIMULATOR
###################################################################################################
[developer]
###################################################################################################
# NETWORK SIMULATOR
#
# NetSim.Active (boolean)
# Description: Enable artificial packet unreliability. Used for development testing.
# Active equally on upstream and downstream packets.
# Important: DO NOT enable on servers with a high packet rate as buffering increases
# the memory load of the server and it will (by design) affect performance.
# Default: no - (Disabled)
# yes - (Enabled)
NetSim.Active = no
# NetSim.Loss (float)
# Description: The percentage of outgoing and incoming packets that are dropped.
# Range: [0.0, 1.0] - (0% loss, 100% packet loss)
# Default: 0.02 - (2% packet loss)
NetSim.Loss = 0.02
# NetSim.Delay (time)
# Description: The time a packet is buffered before being delivered to simulate delay.
# The artificial delay is in addition to any real network latency.
# Important: Longer delays will lead to larger packet buffering, which may cause
# out-of-memory errors depending on packet rate.
# Range: [0, 2 seconds] - (No delay, 2 seconds delay)
# Default: 150 milliseconds - (Packets lag for 150 milliseconds)
NetSim.Delay = 150 milliseconds
# NetSim.ReorderChance (float)
# Description: The percentage chance that a packet will be ordered randomly in the delay
# buffer. If the NetSim.Delay is too small then packets won't be reordered.
# Range: [0.0, 1.0] - (No packet reordering, reorder every packet)
# Default: 0.005 - (0.5% chance of a packet being reordered)
NetSim.ReorderChance = 0.005
# NetSim.ReorderTime (time)
# Description: If a packet is reordered, the maximum time in the future or the past where
# it will randomly appear.
# Range: [0, 2 seconds] - (No packet reordering, randomly shift +/- 2 seconds)
# Default: 150 milliseconds - (+/- 150 milliseconds)
NetSim.ReorderTime = 150 milliseconds
#
###################################################################################################
[kamon]
# Kamon
#
# Active (boolean)
# Description: Enables reporting of metrics to Kamon.io
# Important: Ensure the API key is set in application.conf in the same
# folder as PsLogin.scala
# Default: no - (Disabled)
# yes - (Enabled)
Active = no
[antihack]
# HitPositionDiscrepancyThreshold (int)
# Description: The distance (squared) threshold that triggers if the reported hit location of a shot does not match the object being hit's location on the server
# Range: [1, 1000000]
# Default: 10000 (sqrt 10000 = ~100 ingame units)
HitPositionDiscrepancyThreshold = 10000