Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadOrGenerateHostKey ¶
*
- Loads existing Ed25519 host key or generates a new one if not found.
- @param path - Filesystem path to store/load the key
- @return SSH signer for the host key
- @return error if key operations fail
- @effects Creates key file on disk if it doesn't exist
func StartServer ¶
*
- Starts the SSH server and begins accepting connections.
- @param cfg - Server configuration (port, password, keys)
- @return error if server fails to start or crashes
- @effects Blocks current goroutine until server stops
Types ¶
type Config ¶
type Config struct {
Port int
HostKeyPath string
MaxPerMinute int // Rate limit: connections per minute per IP
}
*
- Server configuration loaded from environment variables.
func LoadConfig ¶
func LoadConfig() *Config
*
- Loads server configuration from environment variables with defaults.
- @return Config populated with values from env or defaults
type RateLimiter ¶
type RateLimiter struct {
// contains filtered or unexported fields
}
*
- Rate limiter that tracks connection attempts per IP address.
func NewRateLimiter ¶
func NewRateLimiter(requestsPerMinute int) *RateLimiter
*
- Creates a new rate limiter with specified requests per minute.
- @param requestsPerMinute - Maximum requests allowed per minute per IP
- @return Configured RateLimiter instance
func (*RateLimiter) Allow ¶
func (rl *RateLimiter) Allow(ip string) bool
*
- Checks if a connection from the given IP should be allowed.
- @param ip - IP address to check
- @return true if connection is allowed, false if rate limited
- @effects Updates internal rate limit state for the IP
func (*RateLimiter) CleanupOldLimiters ¶
func (rl *RateLimiter) CleanupOldLimiters()
*
- Cleans up old limiters to prevent memory leaks.
- Should be called periodically in a goroutine.
- @effects Removes inactive IP entries from the limiter map
Click to show internal directories.
Click to hide internal directories.