4
0
Mike 2 жил өмнө
parent
commit
98f023ea53

+ 10 - 1
.goreleaser.yaml

@@ -30,7 +30,16 @@ builds:
         {{- if eq .Os "windows" }}CC=x86_64-w64-mingw32-gcc{{- end }}
 
 archives:
-  - format: binary
+  - format: tar.gz
+    format_overrides:
+      - goos: windows
+        format: zip
+    files:
+      - LICENSE
+      - src: files/package/settings.env
+        strip_parent: true
+      - src: files/package/run.{{- if eq .Os "windows" }}bat{{ else }}sh{{ end }}
+        strip_parent: true
     name_template: >-
       {{ .ProjectName }}.{{ .Version }}.
       {{- if eq .Os "darwin"}}mac

+ 27 - 0
files/package/run.bat

@@ -0,0 +1,27 @@
+@echo off
+REM This script launches Retro AIM Server. By default, it assumes that the
+REM executable and configuration file are located in the same directory as this
+REM script.
+
+setlocal enabledelayedexpansion
+
+REM Get the directory of the script
+for %%I in (%0) do set "SCRIPT_DIR=%%~dpI"
+set "ENV_FILE=!SCRIPT_DIR!\settings.env"
+set "EXEC_FILE=!SCRIPT_DIR!\retro-aim-server.exe"
+
+REM Load the settings file
+if exist !ENV_FILE! (
+    call "!ENV_FILE!"
+) else (
+    echo error: environment file '!ENV_FILE!' not found.
+    exit /b 1
+)
+
+REM Start Retro AIM Server
+if exist !EXEC_FILE! (
+    call "!EXEC_FILE!"
+) else (
+    echo error: executable '!EXEC_FILE!' not found.
+    exit /b 1
+)

+ 25 - 0
files/package/run.sh

@@ -0,0 +1,25 @@
+#!/bin/sh
+# This script launches Retro AIM Server. By default, it assumes that the
+# executable and configuration file are located in the same directory as this
+# script.
+set -e
+
+SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
+ENV_FILE="$SCRIPT_DIR/settings.env"
+EXEC_FILE="$SCRIPT_DIR/retro-aim-server"
+
+# Load the settings file.
+if [ -f "$ENV_FILE" ]; then
+    . "$ENV_FILE"
+else
+    echo "error: environment file '$ENV_FILE' not found."
+    exit 1
+fi
+
+# Start Retro AIM Server.
+if [ -f "$EXEC_FILE" ]; then
+    "$EXEC_FILE"
+else
+    echo "error: executable '$EXEC_FILE' not found."
+    exit 1
+fi

+ 28 - 0
files/package/settings.env

@@ -0,0 +1,28 @@
+# The port that the BOS service binds to.
+export BOS_PORT=5191
+# The port that the chat service binds to.
+export CHAT_PORT=5192
+# The path to the SQLite database file. The file and DB schema are auto-created
+# if they doesn't exist.
+export DB_PATH=oscar.sqlite
+# Disable password check and auto-create new users at login time. Useful for
+# quickly creating new accounts during development without having to register
+# new users via the management API.
+export DISABLE_AUTH=true
+# Crash the server in case it encounters a client message type it doesn't
+# recognize. This makes failures obvious for debugging purposes.
+export FAIL_FAST=true
+# Set logging granularity. Possible values: `trace`, `debug`, `info`, `warn`,
+# `error`.
+export LOG_LEVEL=trace
+# The hostname that AIM clients connect to in order to reach OSCAR services
+# (BOS, BUCP, chat, etc). Make sure the hostname is reachable by all clients.
+#  - For local development, the default loopback address should work provided
+#    the server and AIM client(s) are running on the same machine.
+#  - For LAN-only clients, a private IP address (e.g. 192.168..) or hostname
+#    should suffice.
+#  - For clients connecting over the Internet, specify your public IP address
+#    and ensure that TCP ports 5190-5192 are open on your firewall.
+export OSCAR_HOST=127.0.0.1
+# The port that the auth service binds to.
+export BUCP_PORT=5190

+ 1 - 1
server/bucp.go

@@ -32,7 +32,7 @@ type BUCPAuthService struct {
 // validates users credentials and, upon success, provides an auth cookie and
 // hostname information for connecting to the BOS service.
 func (rt BUCPAuthService) Start() {
-	addr := Address("", rt.Config.OSCARPort)
+	addr := Address("", rt.Config.BUCPPort)
 	listener, err := net.Listen("tcp", addr)
 	if err != nil {
 		rt.Logger.Error("unable to bind OSCAR server address", "err", err.Error())

+ 2 - 2
server/config.go

@@ -4,13 +4,13 @@ import "fmt"
 
 type Config struct {
 	BOSPort     int    `envconfig:"BOS_PORT" default:"5191"`
+	BUCPPort    int    `envconfig:"BUCP_PORT" default:"5190"`
 	ChatPort    int    `envconfig:"CHAT_PORT" default:"5192"`
 	DBPath      string `envconfig:"DB_PATH" required:"true"`
 	DisableAuth bool   `envconfig:"DISABLE_AUTH" default:"false"`
 	FailFast    bool   `envconfig:"FAIL_FAST" default:"false"`
-	OSCARHost   string `envconfig:"OSCAR_HOST" required:"true"`
-	OSCARPort   int    `envconfig:"OSCAR_PORT" default:"5190"`
 	LogLevel    string `envconfig:"LOG_LEVEL" default:"info"`
+	OSCARHost   string `envconfig:"OSCAR_HOST" required:"true"`
 }
 
 func Address(host string, port int) string {