diff options
| author | Jeff Halter <868228+jhalter@users.noreply.github.com> | 2026-03-14 14:43:24 -0700 |
|---|---|---|
| committer | Jeff Halter <868228+jhalter@users.noreply.github.com> | 2026-03-14 14:43:24 -0700 |
| commit | 2cf9f33ef42188dd35eaf4905cd2f05557aecca1 (patch) | |
| tree | e2cb7db1ccd7a4defae39395b76b144d66aacf2c /hotline/client_conn.go | |
| parent | 0003a0912b04308fbbdfcb2801d0373e6d4de2f0 (diff) | |
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.
Diffstat (limited to 'hotline/client_conn.go')
| -rw-r--r-- | hotline/client_conn.go | 7 |
1 files changed, 7 insertions, 0 deletions
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 |