46 lines
818 B
Go
46 lines
818 B
Go
package proxy
|
|
|
|
import "forge.cadoles.com/Cadoles/emissary/internal/spec"
|
|
|
|
const NameProxy spec.Name = "proxy.emissary.cadoles.com"
|
|
|
|
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) SpecName() spec.Name {
|
|
return NameProxy
|
|
}
|
|
|
|
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{}
|