diff --git a/app.go b/app.go index 054fd178..9b92fd3b 100644 --- a/app.go +++ b/app.go @@ -6,10 +6,8 @@ import ( "errors" "fmt" "io" - "io/fs" "net" "net/http" - "net/url" "os" "os/signal" "sort" @@ -42,7 +40,6 @@ import ( "google.golang.org/grpc/reflection" "google.golang.org/grpc/status" "gorm.io/gorm" - "inet.af/netaddr" "tailscale.com/tailcfg" "tailscale.com/types/dnstype" "tailscale.com/types/key" @@ -72,92 +69,6 @@ const ( EnforcedClientAuth = "enforced" ) -// Config contains the initial Headscale configuration. -type Config struct { - ServerURL string - Addr string - MetricsAddr string - GRPCAddr string - GRPCAllowInsecure bool - EphemeralNodeInactivityTimeout time.Duration - IPPrefixes []netaddr.IPPrefix - PrivateKeyPath string - BaseDomain string - - DERP DERPConfig - - DBtype string - DBpath string - DBhost string - DBport int - DBname string - DBuser string - DBpass string - - TLSLetsEncryptListen string - TLSLetsEncryptHostname string - TLSLetsEncryptCacheDir string - TLSLetsEncryptChallengeType string - - TLSCertPath string - TLSKeyPath string - TLSClientAuthMode tls.ClientAuthType - - ACMEURL string - ACMEEmail string - - DNSConfig *tailcfg.DNSConfig - - UnixSocket string - UnixSocketPermission fs.FileMode - - OIDC OIDCConfig - - LogTail LogTailConfig - - CLI CLIConfig - - ACL ACLConfig -} - -type OIDCConfig struct { - Issuer string - ClientID string - ClientSecret string - Scope []string - ExtraParams map[string]string - AllowedDomains []string - AllowedUsers []string - StripEmaildomain bool -} - -type DERPConfig struct { - ServerEnabled bool - ServerRegionID int - ServerRegionCode string - ServerRegionName string - STUNAddr string - URLs []url.URL - Paths []string - AutoUpdate bool - UpdateFrequency time.Duration -} - -type LogTailConfig struct { - Enabled bool -} - -type CLIConfig struct { - Address string - APIKey string - Timeout time.Duration - Insecure bool -} - -type ACLConfig struct { - PolicyPath string -} - // Headscale represents the base app of the service. type Headscale struct { cfg Config diff --git a/config.go b/config.go new file mode 100644 index 00000000..29337fd1 --- /dev/null +++ b/config.go @@ -0,0 +1,97 @@ +package headscale + +import ( + "crypto/tls" + "io/fs" + "net/url" + "time" + + "inet.af/netaddr" + "tailscale.com/tailcfg" +) + +// Config contains the initial Headscale configuration. +type Config struct { + ServerURL string + Addr string + MetricsAddr string + GRPCAddr string + GRPCAllowInsecure bool + EphemeralNodeInactivityTimeout time.Duration + IPPrefixes []netaddr.IPPrefix + PrivateKeyPath string + BaseDomain string + + DERP DERPConfig + + DBtype string + DBpath string + DBhost string + DBport int + DBname string + DBuser string + DBpass string + + TLSLetsEncryptListen string + TLSLetsEncryptHostname string + TLSLetsEncryptCacheDir string + TLSLetsEncryptChallengeType string + + TLSCertPath string + TLSKeyPath string + TLSClientAuthMode tls.ClientAuthType + + ACMEURL string + ACMEEmail string + + DNSConfig *tailcfg.DNSConfig + + UnixSocket string + UnixSocketPermission fs.FileMode + + OIDC OIDCConfig + + LogTail LogTailConfig + + CLI CLIConfig + + ACL ACLConfig +} + +type OIDCConfig struct { + Issuer string + ClientID string + ClientSecret string + Scope []string + ExtraParams map[string]string + AllowedDomains []string + AllowedUsers []string + StripEmaildomain bool +} + +type DERPConfig struct { + ServerEnabled bool + ServerRegionID int + ServerRegionCode string + ServerRegionName string + STUNAddr string + URLs []url.URL + Paths []string + AutoUpdate bool + UpdateFrequency time.Duration +} + +type LogTailConfig struct { + Enabled bool +} + +type CLIConfig struct { + Address string + APIKey string + Timeout time.Duration + Insecure bool +} + +type ACLConfig struct { + PolicyPath string +}