feat: initial VRRP implementation with health checking

- VRRP protocol implementation (RFC 3768/5798)
- Virtual IP management (add/remove VIPs)
- State machine (INIT/BACKUP/MASTER/FAULT)
- Priority-based master election
- Gratuitous ARP for network updates
- Health checking (TCP, HTTP, ICMP, Script)
- Configuration hot-reload (SIGHUP)

🤖 Generated with [Qoder][https://qoder.com]
This commit is contained in:
loveuer
2025-12-08 22:23:45 +08:00
commit 894ddb53d3
35 changed files with 4893 additions and 0 deletions

44
pkg/logger/logger.go Normal file
View File

@@ -0,0 +1,44 @@
package logger
import (
"fmt"
"log"
"os"
"time"
)
type Logger struct {
debug bool
logger *log.Logger
}
func New(debug bool) *Logger {
return &Logger{
debug: debug,
logger: log.New(os.Stdout, "", 0),
}
}
func (l *Logger) Info(format string, args ...interface{}) {
l.log("INFO", format, args...)
}
func (l *Logger) Error(format string, args ...interface{}) {
l.log("ERROR", format, args...)
}
func (l *Logger) Debug(format string, args ...interface{}) {
if l.debug {
l.log("DEBUG", format, args...)
}
}
func (l *Logger) Warn(format string, args ...interface{}) {
l.log("WARN", format, args...)
}
func (l *Logger) log(level string, format string, args ...interface{}) {
timestamp := time.Now().Format("2006-01-02 15:04:05")
message := fmt.Sprintf(format, args...)
l.logger.Printf("[%s] %s: %s", timestamp, level, message)
}