wrapping up for a public release

This commit is contained in:
fusion32 2025-08-15 15:09:17 -03:00
parent 326793ad5e
commit 095c9e7a5b
8 changed files with 69 additions and 23 deletions

24
LICENSE.txt Normal file
View File

@ -0,0 +1,24 @@
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <https://unlicense.org/>

11
README.md Normal file
View File

@ -0,0 +1,11 @@
# Tibia 7.7 Web Server
This is a simple web server designed to support [Tibia Game Server](https://github.com/fusion32/tibia-game). It is written in *Go* for simplicity and supports running over *HTTP* or *HTTPS*. Running over *HTTP* is not secure and should only be used for testing purposes. Running over *HTTPS* will require a valid certificate and key which may be acquired with [Let's Encrypt](https://letsencrypt.org/) free of cost, if you have a domain name.
## Compiling
The only dependency is an up to date [Go Compiler](https://go.dev/doc/install).
```
go build -o build/
```
## Running
Similar to the game server, the web server won't boot up if it's not able to connect to the [Query Manager](https://github.com/fusion32/tibia-querymanager). It is always recommended that the server is setup as a service. There is a *systemd* configuration file (`tibia-web.service`) in the repository that may be used for that purpose. The process is very similar to the one described in the [Game Server](https://github.com/fusion32/tibia-game) so I won't repeat myself here.

View File

@ -20,6 +20,4 @@ QueryManagerPassword = "a6glaf0c"
MaxCachedAccounts = 4096 MaxCachedAccounts = 4096
MaxCachedCharacters = 4096 MaxCachedCharacters = 4096
CharacterRefreshInterval = 15m CharacterRefreshInterval = 15m
WorldsRefreshInterval = 15m WorldRefreshInterval = 15m
OnlineCharactersRefreshInterval = 15m
KillStatisticsRefreshInterval = 30m

2
go.mod
View File

@ -1,3 +1,3 @@
module tibia-web module tibia-web
go 1.24.5 go 1.24

18
main.go
View File

@ -60,12 +60,10 @@ var (
g_QueryManagerPassword string = "" g_QueryManagerPassword string = ""
// Query Manager Cache Config // Query Manager Cache Config
g_MaxCachedAccounts = 4096 g_MaxCachedAccounts = 4096
g_MaxCachedCharacters = 4096 g_MaxCachedCharacters = 4096
g_CharacterRefreshInterval = 15 * time.Minute g_CharacterRefreshInterval = 15 * time.Minute
g_WorldsRefreshInterval = 15 * time.Minute g_WorldRefreshInterval = 15 * time.Minute
g_OnlineCharactersRefreshInterval = 15 * time.Minute
g_KillStatisticsRefreshInterval = 30 * time.Minute
// Loggers // Loggers
g_Log = log.New(os.Stderr, "INFO ", log.Ldate|log.Ltime|log.Lmsgprefix) g_Log = log.New(os.Stderr, "INFO ", log.Ldate|log.Ltime|log.Lmsgprefix)
@ -104,12 +102,8 @@ func WebKVCallback(Key string, Value string) {
g_MaxCachedCharacters = ParseInteger(Value) g_MaxCachedCharacters = ParseInteger(Value)
} else if strings.EqualFold(Key, "CharacterRefreshInterval") { } else if strings.EqualFold(Key, "CharacterRefreshInterval") {
g_CharacterRefreshInterval = ParseDuration(Value) g_CharacterRefreshInterval = ParseDuration(Value)
} else if strings.EqualFold(Key, "WorldsRefreshInterval") { } else if strings.EqualFold(Key, "WorldRefreshInterval") {
g_WorldsRefreshInterval = ParseDuration(Value) g_WorldRefreshInterval = ParseDuration(Value)
} else if strings.EqualFold(Key, "OnlineCharactersRefreshInterval") {
g_OnlineCharactersRefreshInterval = ParseDuration(Value)
} else if strings.EqualFold(Key, "KillStatisticsRefreshInterval") {
g_KillStatisticsRefreshInterval = ParseDuration(Value)
} else { } else {
g_LogWarn.Printf("Unknown config \"%v\"", Key) g_LogWarn.Printf("Unknown config \"%v\"", Key)
} }

View File

@ -500,9 +500,7 @@ func InitQuery() bool {
g_Log.Printf("MaxCachedAccounts: %v", g_MaxCachedAccounts) g_Log.Printf("MaxCachedAccounts: %v", g_MaxCachedAccounts)
g_Log.Printf("MaxCachedCharacters: %v", g_MaxCachedCharacters) g_Log.Printf("MaxCachedCharacters: %v", g_MaxCachedCharacters)
g_Log.Printf("CharacterRefreshInterval: %v", g_CharacterRefreshInterval) g_Log.Printf("CharacterRefreshInterval: %v", g_CharacterRefreshInterval)
g_Log.Printf("WorldsRefreshInterval: %v", g_WorldsRefreshInterval) g_Log.Printf("WorldRefreshInterval: %v", g_WorldRefreshInterval)
g_Log.Printf("OnlineCharactersRefreshInterval: %v", g_OnlineCharactersRefreshInterval)
g_Log.Printf("KillStatisticsRefreshInterval: %v", g_KillStatisticsRefreshInterval)
Result := g_QueryManagerConnection.Connect() Result := g_QueryManagerConnection.Connect()
if !Result { if !Result {
@ -650,7 +648,7 @@ func GetWorlds() []TWorld {
Result, Worlds := g_QueryManagerConnection.GetWorlds() Result, Worlds := g_QueryManagerConnection.GetWorlds()
if Result == 0 { if Result == 0 {
g_WorldCache = Worlds g_WorldCache = Worlds
g_WorldCacheRefreshTime = time.Now().Add(g_WorldsRefreshInterval) g_WorldCacheRefreshTime = time.Now().Add(g_WorldRefreshInterval)
} }
} }
return g_WorldCache return g_WorldCache
@ -692,7 +690,7 @@ func GetOnlineCharacters(World string) []TOnlineCharacter {
Entry = &g_OnlineCharactersCache[len(g_OnlineCharactersCache)-1] Entry = &g_OnlineCharactersCache[len(g_OnlineCharactersCache)-1]
Entry.World = World Entry.World = World
Entry.Data = Characters Entry.Data = Characters
Entry.RefreshTime = time.Now().Add(g_OnlineCharactersRefreshInterval) Entry.RefreshTime = time.Now().Add(g_WorldRefreshInterval)
} }
} }
@ -729,7 +727,7 @@ func GetKillStatistics(World string) []TKillStatistics {
Entry = &g_KillStatisticsCache[len(g_KillStatisticsCache)-1] Entry = &g_KillStatisticsCache[len(g_KillStatisticsCache)-1]
Entry.World = World Entry.World = World
Entry.Data = Stats Entry.Data = Stats
Entry.RefreshTime = time.Now().Add(g_KillStatisticsRefreshInterval) Entry.RefreshTime = time.Now().Add(g_WorldRefreshInterval)
} }
} }

View File

@ -25,7 +25,6 @@
{{end}} {{end}}
<br> <br>
<a class="button" href="/character">Characters</a> <a class="button" href="/character">Characters</a>
<a class="button" href="#">Houses</a>
<a class="button" href="/world">Worlds</a> <a class="button" href="/world">Worlds</a>
</div> </div>
{{/* HEADER END */}} {{/* HEADER END */}}

22
tibia-web.service Normal file
View File

@ -0,0 +1,22 @@
# Basic SYSTEMD service file for the Tibia Web Server
[Unit]
Description=Tibia Web Server
After=network.target
Requires=tibia-querymanager.service
[Install]
WantedBy=multi-user.target
[Service]
Type=simple
User=tibia-web
Group=tibia-web
ExecStart=/opt/tibia/web/web
WorkingDirectory=/opt/tibia/web/
Restart=always
RestartSec=10
LimitCORE=infinity
StandardOutput=journal
StandardError=journal
SyslogIdentifier=%n