mirror of
				https://github.com/juanfont/headscale.git
				synced 2025-10-28 10:51:44 +01:00 
			
		
		
		
	Move config struct to its own file
This commit is contained in:
		
							parent
							
								
									f1db2d0c8e
								
							
						
					
					
						commit
						533ecee252
					
				
							
								
								
									
										89
									
								
								app.go
									
									
									
									
									
								
							
							
						
						
									
										89
									
								
								app.go
									
									
									
									
									
								
							@ -6,10 +6,8 @@ import (
 | 
				
			|||||||
	"errors"
 | 
						"errors"
 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
	"io"
 | 
						"io"
 | 
				
			||||||
	"io/fs"
 | 
					 | 
				
			||||||
	"net"
 | 
						"net"
 | 
				
			||||||
	"net/http"
 | 
						"net/http"
 | 
				
			||||||
	"net/url"
 | 
					 | 
				
			||||||
	"os"
 | 
						"os"
 | 
				
			||||||
	"os/signal"
 | 
						"os/signal"
 | 
				
			||||||
	"sort"
 | 
						"sort"
 | 
				
			||||||
@ -42,7 +40,6 @@ import (
 | 
				
			|||||||
	"google.golang.org/grpc/reflection"
 | 
						"google.golang.org/grpc/reflection"
 | 
				
			||||||
	"google.golang.org/grpc/status"
 | 
						"google.golang.org/grpc/status"
 | 
				
			||||||
	"gorm.io/gorm"
 | 
						"gorm.io/gorm"
 | 
				
			||||||
	"inet.af/netaddr"
 | 
					 | 
				
			||||||
	"tailscale.com/tailcfg"
 | 
						"tailscale.com/tailcfg"
 | 
				
			||||||
	"tailscale.com/types/dnstype"
 | 
						"tailscale.com/types/dnstype"
 | 
				
			||||||
	"tailscale.com/types/key"
 | 
						"tailscale.com/types/key"
 | 
				
			||||||
@ -72,92 +69,6 @@ const (
 | 
				
			|||||||
	EnforcedClientAuth = "enforced"
 | 
						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.
 | 
					// Headscale represents the base app of the service.
 | 
				
			||||||
type Headscale struct {
 | 
					type Headscale struct {
 | 
				
			||||||
	cfg        Config
 | 
						cfg        Config
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										97
									
								
								config.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										97
									
								
								config.go
									
									
									
									
									
										Normal file
									
								
							@ -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
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user