53 lines
913 B
Go
53 lines
913 B
Go
package proxy
|
|
|
|
import "forge.cadoles.com/Cadoles/emissary/internal/spec"
|
|
|
|
const (
|
|
Name string = "proxy.emissary.cadoles.com"
|
|
Version = "0.0.0"
|
|
)
|
|
|
|
type ID string
|
|
|
|
type Spec struct {
|
|
Revision int `json:"revision"`
|
|
Proxies map[ID]ProxyEntry `json:"proxies"`
|
|
}
|
|
|
|
type ProxyEntry struct {
|
|
Address string `json:"address"`
|
|
Mappings []ProxyMapping `json:"mappings"`
|
|
}
|
|
|
|
type ProxyMapping struct {
|
|
HostPattern string `json:"hostPattern"`
|
|
Target string `json:"target"`
|
|
}
|
|
|
|
func (s *Spec) SpecDefinitionName() string {
|
|
return Name
|
|
}
|
|
|
|
func (s *Spec) SpecDefinitionVersion() string {
|
|
return Version
|
|
}
|
|
|
|
func (s *Spec) SpecRevision() int {
|
|
return s.Revision
|
|
}
|
|
|
|
func (s *Spec) SpecData() map[string]any {
|
|
return map[string]any{
|
|
"proxies": s.Proxies,
|
|
}
|
|
}
|
|
|
|
func NewSpec() *Spec {
|
|
return &Spec{
|
|
Revision: -1,
|
|
Proxies: make(map[ID]ProxyEntry),
|
|
}
|
|
}
|
|
|
|
var _ spec.Spec = &Spec{}
|