mirror of
				https://github.com/juanfont/headscale.git
				synced 2025-10-28 10:51:44 +01:00 
			
		
		
		
	Merge pull request #197 from kradalby/config-simplification
This commit is contained in:
		
						commit
						6d162eeff9
					
				@ -27,7 +27,7 @@ func (s *Suite) SetUpSuite(c *check.C) {
 | 
			
		||||
func (s *Suite) TearDownSuite(c *check.C) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (*Suite) TestPostgresConfigLoading(c *check.C) {
 | 
			
		||||
func (*Suite) TestConfigLoading(c *check.C) {
 | 
			
		||||
	tmpDir, err := ioutil.TempDir("", "headscale")
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		c.Fatal(err)
 | 
			
		||||
@ -40,39 +40,7 @@ func (*Suite) TestPostgresConfigLoading(c *check.C) {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Symlink the example config file
 | 
			
		||||
	err = os.Symlink(filepath.Clean(path+"/../../config.yaml.postgres.example"), filepath.Join(tmpDir, "config.yaml"))
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		c.Fatal(err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Load example config, it should load without validation errors
 | 
			
		||||
	err = cli.LoadConfig(tmpDir)
 | 
			
		||||
	c.Assert(err, check.IsNil)
 | 
			
		||||
 | 
			
		||||
	// Test that config file was interpreted correctly
 | 
			
		||||
	c.Assert(viper.GetString("server_url"), check.Equals, "http://127.0.0.1:8080")
 | 
			
		||||
	c.Assert(viper.GetString("listen_addr"), check.Equals, "0.0.0.0:8080")
 | 
			
		||||
	c.Assert(viper.GetString("db_type"), check.Equals, "postgres")
 | 
			
		||||
	c.Assert(viper.GetString("db_port"), check.Equals, "5432")
 | 
			
		||||
	c.Assert(viper.GetString("tls_letsencrypt_hostname"), check.Equals, "")
 | 
			
		||||
	c.Assert(viper.GetString("tls_letsencrypt_listen"), check.Equals, ":http")
 | 
			
		||||
	c.Assert(viper.GetStringSlice("dns_config.nameservers")[0], check.Equals, "1.1.1.1")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (*Suite) TestSqliteConfigLoading(c *check.C) {
 | 
			
		||||
	tmpDir, err := ioutil.TempDir("", "headscale")
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		c.Fatal(err)
 | 
			
		||||
	}
 | 
			
		||||
	defer os.RemoveAll(tmpDir)
 | 
			
		||||
 | 
			
		||||
	path, err := os.Getwd()
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		c.Fatal(err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Symlink the example config file
 | 
			
		||||
	err = os.Symlink(filepath.Clean(path+"/../../config.yaml.sqlite.example"), filepath.Join(tmpDir, "config.yaml"))
 | 
			
		||||
	err = os.Symlink(filepath.Clean(path+"/../../config-example.yaml"), filepath.Join(tmpDir, "config.yaml"))
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		c.Fatal(err)
 | 
			
		||||
	}
 | 
			
		||||
@ -106,7 +74,7 @@ func (*Suite) TestDNSConfigLoading(c *check.C) {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Symlink the example config file
 | 
			
		||||
	err = os.Symlink(filepath.Clean(path+"/../../config.yaml.sqlite.example"), filepath.Join(tmpDir, "config.yaml"))
 | 
			
		||||
	err = os.Symlink(filepath.Clean(path+"/../../config-example.yaml"), filepath.Join(tmpDir, "config.yaml"))
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		c.Fatal(err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@ -1,13 +1,13 @@
 | 
			
		||||
---
 | 
			
		||||
log_level: info
 | 
			
		||||
# The url clients will connect to.
 | 
			
		||||
# Typically this will be a domain.
 | 
			
		||||
server_url: http://127.0.0.1:8080
 | 
			
		||||
listen_addr: 0.0.0.0:8080
 | 
			
		||||
private_key_path: private.key
 | 
			
		||||
ephemeral_node_inactivity_timeout: 30m
 | 
			
		||||
 | 
			
		||||
# SQLite config (uncomment it if you want to use SQLite)
 | 
			
		||||
db_type: sqlite3
 | 
			
		||||
db_path: db.sqlite
 | 
			
		||||
# Address to listen to / bind to on the server
 | 
			
		||||
listen_addr: 0.0.0.0:8080
 | 
			
		||||
 | 
			
		||||
# Path to WireGuard private key file
 | 
			
		||||
private_key_path: private.key
 | 
			
		||||
 | 
			
		||||
derp:
 | 
			
		||||
  # List of externally available DERP maps encoded in JSON
 | 
			
		||||
@ -26,18 +26,41 @@ derp:
 | 
			
		||||
  # How often should we check for updates?
 | 
			
		||||
  update_frequency: 24h
 | 
			
		||||
 | 
			
		||||
# Disables the automatic check for updates on startup
 | 
			
		||||
disable_check_updates: false
 | 
			
		||||
ephemeral_node_inactivity_timeout: 30m
 | 
			
		||||
 | 
			
		||||
# SQLite config
 | 
			
		||||
db_type: sqlite3
 | 
			
		||||
db_path: db.sqlite
 | 
			
		||||
 | 
			
		||||
# # Postgres config
 | 
			
		||||
# db_type: postgres
 | 
			
		||||
# db_host: localhost
 | 
			
		||||
# db_port: 5432
 | 
			
		||||
# db_name: headscale
 | 
			
		||||
# db_user: foo
 | 
			
		||||
# db_pass: bar
 | 
			
		||||
 | 
			
		||||
acme_url: https://acme-v02.api.letsencrypt.org/directory
 | 
			
		||||
acme_email: ""
 | 
			
		||||
 | 
			
		||||
tls_letsencrypt_hostname: ""
 | 
			
		||||
tls_letsencrypt_listen: ":http"
 | 
			
		||||
tls_letsencrypt_cache_dir: ".cache"
 | 
			
		||||
tls_letsencrypt_challenge_type: HTTP-01
 | 
			
		||||
 | 
			
		||||
tls_cert_path: ""
 | 
			
		||||
tls_key_path: ""
 | 
			
		||||
 | 
			
		||||
# Path to a file containg ACL policies.
 | 
			
		||||
acl_policy_path: ""
 | 
			
		||||
 | 
			
		||||
dns_config:
 | 
			
		||||
  # Upstream DNS servers
 | 
			
		||||
  nameservers:
 | 
			
		||||
    - 1.1.1.1
 | 
			
		||||
  domains: []
 | 
			
		||||
 | 
			
		||||
  magic_dns: true
 | 
			
		||||
  base_domain: example.com
 | 
			
		||||
@ -1,29 +0,0 @@
 | 
			
		||||
---
 | 
			
		||||
server_url: http://127.0.0.1:8080
 | 
			
		||||
listen_addr: 0.0.0.0:8080
 | 
			
		||||
private_key_path: private.key
 | 
			
		||||
ephemeral_node_inactivity_timeout: 30m
 | 
			
		||||
 | 
			
		||||
# Postgres config
 | 
			
		||||
db_type: postgres
 | 
			
		||||
db_host: localhost
 | 
			
		||||
db_port: 5432
 | 
			
		||||
db_name: headscale
 | 
			
		||||
db_user: foo
 | 
			
		||||
db_pass: bar
 | 
			
		||||
 | 
			
		||||
acme_url: https://acme-v02.api.letsencrypt.org/directory
 | 
			
		||||
acme_email: ''
 | 
			
		||||
tls_letsencrypt_hostname: ''
 | 
			
		||||
tls_letsencrypt_listen: ":http"
 | 
			
		||||
tls_letsencrypt_cache_dir: ".cache"
 | 
			
		||||
tls_letsencrypt_challenge_type: HTTP-01
 | 
			
		||||
tls_cert_path: ''
 | 
			
		||||
tls_key_path: ''
 | 
			
		||||
acl_policy_path: ''
 | 
			
		||||
dns_config:
 | 
			
		||||
  nameservers:
 | 
			
		||||
  - 1.1.1.1
 | 
			
		||||
  domains: []
 | 
			
		||||
  magic_dns: true
 | 
			
		||||
  base_domain: example.com
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user