Initial vibeproxy implementation
Self-contained HTTP/HTTPS/TCP/UDP reverse proxy manager written in Go, with SQLite storage, a Bootstrap 5 admin UI (Go templates, no JS framework), and a REST API under /api/v1. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QTXFrNP1imCW7jtfL5SZrw
This commit is contained in:
@@ -0,0 +1,237 @@
|
||||
// Package models defines the persistent entities stored in SQLite.
|
||||
package models
|
||||
|
||||
import "time"
|
||||
|
||||
type User struct {
|
||||
ID int64
|
||||
Username string
|
||||
PasswordHash string
|
||||
MustChangePW bool
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
type APIToken struct {
|
||||
ID int64
|
||||
Name string
|
||||
TokenHash string
|
||||
Prefix string
|
||||
CreatedAt time.Time
|
||||
LastUsedAt *time.Time
|
||||
RevokedAt *time.Time
|
||||
}
|
||||
|
||||
type ProxyHostType string
|
||||
|
||||
const (
|
||||
ProxyHostTypeProxy ProxyHostType = "proxy"
|
||||
ProxyHostTypeRedirect ProxyHostType = "redirect"
|
||||
)
|
||||
|
||||
type ProxyHost struct {
|
||||
ID int64
|
||||
Name string
|
||||
Type ProxyHostType
|
||||
Domains []string
|
||||
ListenAddr string // e.g. "0.0.0.0" or "" for all
|
||||
ForwardScheme string // http or https (upstream scheme)
|
||||
PreserveHostHeader bool
|
||||
WebsocketSupport bool
|
||||
ForceHTTPS bool
|
||||
HSTSEnabled bool
|
||||
CertificateID *int64
|
||||
AccessListID *int64
|
||||
ConnectTimeoutMS int
|
||||
ReadTimeoutMS int
|
||||
WriteTimeoutMS int
|
||||
IdleTimeoutMS int
|
||||
LoadBalancingMethod string // round_robin, least_conn, weighted
|
||||
RedirectTargetURL string
|
||||
RedirectCode int
|
||||
RedirectPreservePath bool
|
||||
RedirectPreserveQS bool
|
||||
Enabled bool
|
||||
Comments string
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
|
||||
Backends []Backend
|
||||
CustomHeaders []CustomHeader
|
||||
}
|
||||
|
||||
type CustomHeaderAction string
|
||||
|
||||
const (
|
||||
HeaderActionSet CustomHeaderAction = "set"
|
||||
HeaderActionRemove CustomHeaderAction = "remove"
|
||||
)
|
||||
|
||||
type CustomHeaderDirection string
|
||||
|
||||
const (
|
||||
HeaderDirectionRequest CustomHeaderDirection = "request"
|
||||
HeaderDirectionResponse CustomHeaderDirection = "response"
|
||||
)
|
||||
|
||||
type CustomHeader struct {
|
||||
ID int64
|
||||
ProxyHostID int64
|
||||
Direction CustomHeaderDirection
|
||||
Action CustomHeaderAction
|
||||
Name string
|
||||
Value string
|
||||
}
|
||||
|
||||
type HealthCheckType string
|
||||
|
||||
const (
|
||||
HealthCheckTCP HealthCheckType = "tcp"
|
||||
HealthCheckHTTP HealthCheckType = "http"
|
||||
HealthCheckNone HealthCheckType = "none"
|
||||
)
|
||||
|
||||
type Backend struct {
|
||||
ID int64
|
||||
ProxyHostID int64
|
||||
Host string
|
||||
Port int
|
||||
Weight int
|
||||
Enabled bool
|
||||
HealthCheckType HealthCheckType
|
||||
HealthCheckPath string
|
||||
HealthCheckStatus int
|
||||
IntervalSeconds int
|
||||
FailureThreshold int
|
||||
RecoveryThreshold int
|
||||
|
||||
// Runtime-only (not persisted)
|
||||
Healthy bool `db:"-"`
|
||||
}
|
||||
|
||||
type StreamProtocol string
|
||||
|
||||
const (
|
||||
StreamTCP StreamProtocol = "tcp"
|
||||
StreamUDP StreamProtocol = "udp"
|
||||
)
|
||||
|
||||
type Stream struct {
|
||||
ID int64
|
||||
Protocol StreamProtocol
|
||||
ListenIP string
|
||||
ListenPort int
|
||||
DestinationHost string
|
||||
DestinationPort int
|
||||
ConnectTimeoutMS int
|
||||
IdleTimeoutMS int
|
||||
ProxyProtocol bool
|
||||
Enabled bool
|
||||
Comments string
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
type CertificateType string
|
||||
|
||||
const (
|
||||
CertTypeLetsEncrypt CertificateType = "letsencrypt"
|
||||
CertTypeCustom CertificateType = "custom"
|
||||
)
|
||||
|
||||
type ChallengeType string
|
||||
|
||||
const (
|
||||
ChallengeHTTP01 ChallengeType = "http-01"
|
||||
ChallengeDNS01 ChallengeType = "dns-01"
|
||||
)
|
||||
|
||||
type Certificate struct {
|
||||
ID int64
|
||||
Name string
|
||||
Type CertificateType
|
||||
Domains []string
|
||||
ChallengeType ChallengeType
|
||||
DNSProvider string
|
||||
CertPath string
|
||||
KeyPath string
|
||||
NotBefore *time.Time
|
||||
NotAfter *time.Time
|
||||
LastRenewedAt *time.Time
|
||||
LastError string
|
||||
AutoRenew bool
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
type AccessList struct {
|
||||
ID int64
|
||||
Name string
|
||||
DefaultAllow bool
|
||||
Comments string
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
Rules []AccessRule
|
||||
BasicAuthUsers []AccessListUser
|
||||
}
|
||||
|
||||
type AccessRuleAction string
|
||||
|
||||
const (
|
||||
AccessAllow AccessRuleAction = "allow"
|
||||
AccessDeny AccessRuleAction = "deny"
|
||||
)
|
||||
|
||||
type AccessRule struct {
|
||||
ID int64
|
||||
AccessListID int64
|
||||
Action AccessRuleAction
|
||||
CIDR string
|
||||
Priority int
|
||||
}
|
||||
|
||||
type AccessListUser struct {
|
||||
ID int64
|
||||
AccessListID int64
|
||||
Username string
|
||||
PasswordHash string
|
||||
}
|
||||
|
||||
type RequestLog struct {
|
||||
ID int64
|
||||
Timestamp time.Time
|
||||
ProxyHostID *int64
|
||||
ProxyHostName string
|
||||
ClientIP string
|
||||
Method string
|
||||
Host string
|
||||
Path string
|
||||
Status int
|
||||
ResponseSize int64
|
||||
Backend string
|
||||
ResponseTimeMS int64
|
||||
UserAgent string
|
||||
}
|
||||
|
||||
type AuditLog struct {
|
||||
ID int64
|
||||
Timestamp time.Time
|
||||
Actor string
|
||||
Action string
|
||||
Target string
|
||||
Details string
|
||||
}
|
||||
|
||||
type Settings struct {
|
||||
AdminUsername string
|
||||
ACMEEmail string
|
||||
ACMEStaging bool
|
||||
ACMERenewalWindowDays int
|
||||
CertStoragePath string
|
||||
LogRetentionDays int
|
||||
TrustedProxyCIDRs []string
|
||||
BackupEnabled bool
|
||||
BackupIntervalHours int
|
||||
BackupRetentionCount int
|
||||
BackupPath string
|
||||
}
|
||||
Reference in New Issue
Block a user