2023-03-21 13:28:41 +01:00
|
|
|
package proxy
|
2023-02-28 15:50:35 +01:00
|
|
|
|
|
|
|
import "forge.cadoles.com/Cadoles/emissary/internal/spec"
|
|
|
|
|
2024-03-12 16:22:35 +01:00
|
|
|
const (
|
|
|
|
Name string = "proxy.emissary.cadoles.com"
|
|
|
|
Version = "0.0.0"
|
|
|
|
)
|
2023-02-28 15:50:35 +01:00
|
|
|
|
|
|
|
type ID string
|
|
|
|
|
|
|
|
type Spec struct {
|
2023-03-21 13:28:41 +01:00
|
|
|
Revision int `json:"revision"`
|
|
|
|
Proxies map[ID]ProxyEntry `json:"proxies"`
|
2023-02-28 15:50:35 +01:00
|
|
|
}
|
|
|
|
|
2023-03-21 13:28:41 +01:00
|
|
|
type ProxyEntry struct {
|
2023-03-22 18:15:22 +01:00
|
|
|
Address string `json:"address"`
|
|
|
|
Mappings []ProxyMapping `json:"mappings"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type ProxyMapping struct {
|
|
|
|
HostPattern string `json:"hostPattern"`
|
|
|
|
Target string `json:"target"`
|
2023-02-28 15:50:35 +01:00
|
|
|
}
|
|
|
|
|
2024-03-12 16:22:35 +01:00
|
|
|
func (s *Spec) SpecDefinitionName() string {
|
|
|
|
return Name
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Spec) SpecDefinitionVersion() string {
|
|
|
|
return Version
|
2023-02-28 15:50:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Spec) SpecRevision() int {
|
|
|
|
return s.Revision
|
|
|
|
}
|
|
|
|
|
2023-03-03 20:37:09 +01:00
|
|
|
func (s *Spec) SpecData() map[string]any {
|
|
|
|
return map[string]any{
|
2023-03-21 13:28:41 +01:00
|
|
|
"proxies": s.Proxies,
|
2023-03-03 20:37:09 +01:00
|
|
|
}
|
2023-02-28 15:50:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func NewSpec() *Spec {
|
|
|
|
return &Spec{
|
2023-03-13 10:44:58 +01:00
|
|
|
Revision: -1,
|
2023-03-21 13:28:41 +01:00
|
|
|
Proxies: make(map[ID]ProxyEntry),
|
2023-02-28 15:50:35 +01:00
|
|
|
}
|
|
|
|
}
|
2023-03-03 20:37:09 +01:00
|
|
|
|
|
|
|
var _ spec.Spec = &Spec{}
|