From 2cf9f33ef42188dd35eaf4905cd2f05557aecca1 Mon Sep 17 00:00:00 2001 From: Jeff Halter <868228+jhalter@users.noreply.github.com> Date: Sat, 14 Mar 2026 14:43:24 -0700 Subject: Refactor ban management behind BanMgr interface Extract ban logic into a BanMgr interface with two implementations: - BanFile: file-based YAML storage with support for IP, username, and nickname bans (backwards-compatible with legacy format) - RedisBanMgr: Redis-backed implementation with permanent and temporary ban support, using fail-safe deny-on-error behavior This replaces scattered Redis calls in API handlers, transaction handlers, and server connection logic with unified interface calls, removing the Redis dependency from the API server constructor and enabling ban functionality for both file-only and Redis deployments. --- hotline/client_conn.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'hotline/client_conn.go') diff --git a/hotline/client_conn.go b/hotline/client_conn.go index a203630..d8fd435 100644 --- a/hotline/client_conn.go +++ b/hotline/client_conn.go @@ -6,6 +6,7 @@ import ( "fmt" "io" "log/slog" + "net" "strings" "sync" @@ -50,6 +51,12 @@ func (cc *ClientConn) FileRoot() string { return cc.Server.Config.FileRoot } +// IP returns the IP address portion of the client's remote address. +func (cc *ClientConn) IP() string { + ip, _, _ := net.SplitHostPort(cc.RemoteAddr) + return ip +} + type ClientFileTransferMgr struct { transfers map[FileTransferType]map[FileTransferID]*FileTransfer -- cgit