1
0
mirror of https://github.com/fumiama/terasu-cloudflared.git synced 2026-06-17 00:55:25 +08:00

AUTH-2587 add config watcher and reload logic for access client forwarder

This commit is contained in:
Dalton
2020-04-13 12:22:00 -05:00
parent 976eb24883
commit 41c358147c
32 changed files with 2929 additions and 8 deletions

View File

@@ -0,0 +1,37 @@
package config
import (
"crypto/md5"
"fmt"
"io"
)
// Forwarder represents a client side listener to forward traffic to the edge
type Forwarder struct {
URL string `json:"url"`
Listener string `json:"listener"`
}
// Tunnel represents a tunnel that should be started
type Tunnel struct {
URL string `json:"url"`
Origin string `json:"origin"`
ProtocolType string `json:"type"`
}
// Root is the base options to configure the service
type Root struct {
OrgKey string `json:"org_key"`
ConfigType string `json:"type"`
CheckinInterval int `json:"checkin_interval"`
Forwarders []Forwarder `json:"forwarders,omitempty"`
Tunnels []Tunnel `json:"tunnels,omitempty"`
}
// Hash returns the computed values to see if the forwarder values change
func (f *Forwarder) Hash() string {
h := md5.New()
io.WriteString(h, f.URL)
io.WriteString(h, f.Listener)
return fmt.Sprintf("%x", h.Sum(nil))
}