aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--LICENSE.txt24
-rw-r--r--README.md11
-rw-r--r--config.cfg4
-rw-r--r--go.mod2
-rw-r--r--main.go18
-rw-r--r--query.go10
-rw-r--r--templates/_header.tmpl1
-rw-r--r--tibia-web.service22
8 files changed, 69 insertions, 23 deletions
diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644
index 0000000..c32dd18
--- /dev/null
+++ b/LICENSE.txt
@@ -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/> \ No newline at end of file
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..9161285
--- /dev/null
+++ b/README.md
@@ -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.
diff --git a/config.cfg b/config.cfg
index 627088a..4670757 100644
--- a/config.cfg
+++ b/config.cfg
@@ -20,6 +20,4 @@ QueryManagerPassword = "a6glaf0c"
MaxCachedAccounts = 4096
MaxCachedCharacters = 4096
CharacterRefreshInterval = 15m
-WorldsRefreshInterval = 15m
-OnlineCharactersRefreshInterval = 15m
-KillStatisticsRefreshInterval = 30m
+WorldRefreshInterval = 15m
diff --git a/go.mod b/go.mod
index 93afbe6..bd1a268 100644
--- a/go.mod
+++ b/go.mod
@@ -1,3 +1,3 @@
module tibia-web
-go 1.24.5
+go 1.24
diff --git a/main.go b/main.go
index 3a9d014..679096f 100644
--- a/main.go
+++ b/main.go
@@ -60,12 +60,10 @@ var (
g_QueryManagerPassword string = ""
// Query Manager Cache Config
- g_MaxCachedAccounts = 4096
- g_MaxCachedCharacters = 4096
- g_CharacterRefreshInterval = 15 * time.Minute
- g_WorldsRefreshInterval = 15 * time.Minute
- g_OnlineCharactersRefreshInterval = 15 * time.Minute
- g_KillStatisticsRefreshInterval = 30 * time.Minute
+ g_MaxCachedAccounts = 4096
+ g_MaxCachedCharacters = 4096
+ g_CharacterRefreshInterval = 15 * time.Minute
+ g_WorldRefreshInterval = 15 * time.Minute
// Loggers
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)
} else if strings.EqualFold(Key, "CharacterRefreshInterval") {
g_CharacterRefreshInterval = ParseDuration(Value)
- } else if strings.EqualFold(Key, "WorldsRefreshInterval") {
- g_WorldsRefreshInterval = ParseDuration(Value)
- } else if strings.EqualFold(Key, "OnlineCharactersRefreshInterval") {
- g_OnlineCharactersRefreshInterval = ParseDuration(Value)
- } else if strings.EqualFold(Key, "KillStatisticsRefreshInterval") {
- g_KillStatisticsRefreshInterval = ParseDuration(Value)
+ } else if strings.EqualFold(Key, "WorldRefreshInterval") {
+ g_WorldRefreshInterval = ParseDuration(Value)
} else {
g_LogWarn.Printf("Unknown config \"%v\"", Key)
}
diff --git a/query.go b/query.go
index ef7d253..907e77f 100644
--- a/query.go
+++ b/query.go
@@ -500,9 +500,7 @@ func InitQuery() bool {
g_Log.Printf("MaxCachedAccounts: %v", g_MaxCachedAccounts)
g_Log.Printf("MaxCachedCharacters: %v", g_MaxCachedCharacters)
g_Log.Printf("CharacterRefreshInterval: %v", g_CharacterRefreshInterval)
- g_Log.Printf("WorldsRefreshInterval: %v", g_WorldsRefreshInterval)
- g_Log.Printf("OnlineCharactersRefreshInterval: %v", g_OnlineCharactersRefreshInterval)
- g_Log.Printf("KillStatisticsRefreshInterval: %v", g_KillStatisticsRefreshInterval)
+ g_Log.Printf("WorldRefreshInterval: %v", g_WorldRefreshInterval)
Result := g_QueryManagerConnection.Connect()
if !Result {
@@ -650,7 +648,7 @@ func GetWorlds() []TWorld {
Result, Worlds := g_QueryManagerConnection.GetWorlds()
if Result == 0 {
g_WorldCache = Worlds
- g_WorldCacheRefreshTime = time.Now().Add(g_WorldsRefreshInterval)
+ g_WorldCacheRefreshTime = time.Now().Add(g_WorldRefreshInterval)
}
}
return g_WorldCache
@@ -692,7 +690,7 @@ func GetOnlineCharacters(World string) []TOnlineCharacter {
Entry = &g_OnlineCharactersCache[len(g_OnlineCharactersCache)-1]
Entry.World = World
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.World = World
Entry.Data = Stats
- Entry.RefreshTime = time.Now().Add(g_KillStatisticsRefreshInterval)
+ Entry.RefreshTime = time.Now().Add(g_WorldRefreshInterval)
}
}
diff --git a/templates/_header.tmpl b/templates/_header.tmpl
index 062c681..1de7509 100644
--- a/templates/_header.tmpl
+++ b/templates/_header.tmpl
@@ -25,7 +25,6 @@
{{end}}
<br>
<a class="button" href="/character">Characters</a>
- <a class="button" href="#">Houses</a>
<a class="button" href="/world">Worlds</a>
</div>
{{/* HEADER END */}} \ No newline at end of file
diff --git a/tibia-web.service b/tibia-web.service
new file mode 100644
index 0000000..db46dd1
--- /dev/null
+++ b/tibia-web.service
@@ -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