initial commit
This commit is contained in:
@@ -0,0 +1,155 @@
|
||||
package models
|
||||
|
||||
// These types are the core domain models for Helix Proxy.
|
||||
// They are used by the Store interface (any backend), the API, the proxy engine,
|
||||
// and the certificate manager.
|
||||
|
||||
type Root struct {
|
||||
Version int
|
||||
|
||||
Users []User
|
||||
ProxyHosts []ProxyHost
|
||||
AccessLists []AccessList
|
||||
Streams []Stream
|
||||
Certificates []Certificate
|
||||
RedirectionHosts []RedirectionHost
|
||||
DeadHosts []DeadHost
|
||||
Settings map[string]any
|
||||
AuditLogs []AuditLog
|
||||
|
||||
// meta for internal use by store impls
|
||||
Meta map[string]any
|
||||
}
|
||||
|
||||
type User struct {
|
||||
ID int `json:"id"`
|
||||
Email string `json:"email"`
|
||||
Name string `json:"name"`
|
||||
Password string `json:"password,omitempty"` // bcrypt hash; empty for demo seeded admin. (API responses manually omit the value)
|
||||
Roles []string `json:"roles"`
|
||||
TotpSecret string `json:"totpSecret,omitempty"` // include for bbolt persistence (API never returns the secret value)
|
||||
TotpEnabled bool `json:"totpEnabled"`
|
||||
}
|
||||
|
||||
// HeaderRule is a name/value pair for request or response header overrides.
|
||||
type HeaderRule struct {
|
||||
Name string `json:"name"`
|
||||
Value string `json:"value,omitempty"`
|
||||
}
|
||||
|
||||
type ProxyHost struct {
|
||||
ID int `json:"id"`
|
||||
DomainNames []string `json:"domainNames"`
|
||||
ForwardScheme string `json:"forwardScheme"`
|
||||
ForwardHost string `json:"forwardHost"`
|
||||
ForwardPort int `json:"forwardPort"`
|
||||
AccessListID int `json:"accessListId,omitempty"`
|
||||
CertificateID int `json:"certificateId,omitempty"`
|
||||
SslForced bool `json:"sslForced"`
|
||||
CachingEnabled bool `json:"cachingEnabled"`
|
||||
BlockExploits bool `json:"blockExploits"`
|
||||
AllowWebsocketUpgrade bool `json:"allowWebsocketUpgrade"`
|
||||
Http2Support bool `json:"http2Support"`
|
||||
HstsEnabled bool `json:"hstsEnabled"`
|
||||
HstsSubdomains bool `json:"hstsSubdomains"`
|
||||
TrustForwardedProto bool `json:"trustForwardedProto"`
|
||||
RequestHeaders []HeaderRule `json:"requestHeaders,omitempty"`
|
||||
ResponseHeaders []HeaderRule `json:"responseHeaders,omitempty"`
|
||||
HideHeaders []string `json:"hideHeaders,omitempty"`
|
||||
AdvancedConfig string `json:"advancedConfig,omitempty"` // legacy; engine falls back when structured headers are empty
|
||||
Enabled bool `json:"enabled"`
|
||||
Locations []Location `json:"locations,omitempty"`
|
||||
Meta map[string]any `json:"meta,omitempty"`
|
||||
OwnerUserID int `json:"ownerUserId,omitempty"`
|
||||
CreatedOn string `json:"createdOn,omitempty"` // server-set UTC on create (via store); preserved on update; empty for legacy DB records
|
||||
}
|
||||
|
||||
type Location struct {
|
||||
ID int `json:"id,omitempty"`
|
||||
Path string `json:"path"`
|
||||
ForwardScheme string `json:"forwardScheme"`
|
||||
ForwardHost string `json:"forwardHost"`
|
||||
ForwardPort int `json:"forwardPort"`
|
||||
ForwardPath string `json:"forwardPath,omitempty"`
|
||||
AdvancedConfig string `json:"advancedConfig,omitempty"`
|
||||
}
|
||||
|
||||
type AccessList struct {
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
SatisfyAny bool `json:"satisfyAny"`
|
||||
Clients []AccessClient `json:"clients"`
|
||||
Items []AccessItem `json:"items"`
|
||||
PassAuth bool `json:"passAuth"`
|
||||
OwnerUserID int `json:"ownerUserId,omitempty"`
|
||||
CreatedOn string `json:"createdOn,omitempty"` // server-set UTC on create (via store); preserved on update; empty for legacy DB records
|
||||
}
|
||||
|
||||
type AccessClient struct {
|
||||
Address string `json:"address"`
|
||||
Directive string `json:"directive"` // "allow" or "deny"
|
||||
}
|
||||
|
||||
type AccessItem struct {
|
||||
Username string `json:"username"`
|
||||
Password string `json:"password"` // plain for demo access lists (separate from User bcrypt)
|
||||
}
|
||||
|
||||
type Stream struct {
|
||||
ID int `json:"id"`
|
||||
IncomingPort int `json:"incomingPort"`
|
||||
ForwardingHost string `json:"forwardingHost"`
|
||||
ForwardingPort int `json:"forwardingPort"`
|
||||
TCPForwarding bool `json:"tcpForwarding"`
|
||||
UDPForwarding bool `json:"udpForwarding"`
|
||||
Enabled bool `json:"enabled"`
|
||||
CertificateID int `json:"certificateId"`
|
||||
Meta map[string]any `json:"meta,omitempty"`
|
||||
OwnerUserID int `json:"ownerUserId,omitempty"`
|
||||
CreatedOn string `json:"createdOn,omitempty"` // server-set UTC on create (via store); preserved on update; empty for legacy DB records
|
||||
}
|
||||
|
||||
type Certificate struct {
|
||||
ID int `json:"id"`
|
||||
Provider string `json:"provider"` // "letsencrypt" or "other"
|
||||
NiceName string `json:"niceName"`
|
||||
DomainNames []string `json:"domainNames"`
|
||||
ExpiresOn string `json:"expiresOn"`
|
||||
Meta map[string]any `json:"meta"`
|
||||
OwnerUserID int `json:"ownerUserId,omitempty"`
|
||||
CreatedOn string `json:"createdOn,omitempty"` // server-set UTC on create (via store); preserved on update; empty for legacy DB records
|
||||
}
|
||||
|
||||
type RedirectionHost struct {
|
||||
ID int `json:"id"`
|
||||
DomainNames []string `json:"domainNames"`
|
||||
ForwardHTTPCode int `json:"forwardHttpCode"`
|
||||
ForwardScheme string `json:"forwardScheme"`
|
||||
ForwardDomainName string `json:"forwardDomainName"`
|
||||
PreservePath bool `json:"preservePath"`
|
||||
Enabled bool `json:"enabled"`
|
||||
AdvancedConfig string `json:"advancedConfig,omitempty"`
|
||||
Meta map[string]any `json:"meta,omitempty"`
|
||||
OwnerUserID int `json:"ownerUserId,omitempty"`
|
||||
CreatedOn string `json:"createdOn,omitempty"` // server-set UTC on create (via store); preserved on update; empty for legacy DB records
|
||||
}
|
||||
|
||||
type DeadHost struct {
|
||||
ID int `json:"id"`
|
||||
DomainNames []string `json:"domainNames"`
|
||||
Enabled bool `json:"enabled"`
|
||||
AdvancedConfig string `json:"advancedConfig,omitempty"`
|
||||
Meta map[string]any `json:"meta,omitempty"`
|
||||
OwnerUserID int `json:"ownerUserId,omitempty"`
|
||||
CreatedOn string `json:"createdOn,omitempty"` // server-set UTC on create (via store); preserved on update; empty for legacy DB records
|
||||
}
|
||||
|
||||
type AuditLog struct {
|
||||
ID int `json:"id"`
|
||||
UserID int `json:"userId"`
|
||||
ObjectType string `json:"objectType"`
|
||||
ObjectID int `json:"objectId"`
|
||||
Action string `json:"action"`
|
||||
Meta map[string]any `json:"meta"`
|
||||
CreatedOn string `json:"createdOn"`
|
||||
}
|
||||
Reference in New Issue
Block a user