From 7e95b3501dcf8239e59c9cf6607ff67968d08b65 Mon Sep 17 00:00:00 2001 From: Eugen Date: Wed, 1 Dec 2021 19:32:47 +0100 Subject: [PATCH 1/5] Ignoe derp.yaml, don't panic in Serve() --- .gitignore | 1 + app.go | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 610550b9..ddec49c0 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ /headscale config.json config.yaml +derp.yaml *.key /db.sqlite *.sqlite3 diff --git a/app.go b/app.go index db788908..0fe65761 100644 --- a/app.go +++ b/app.go @@ -418,12 +418,12 @@ func (h *Headscale) Serve() error { err = h.ensureUnixSocketIsAbsent() if err != nil { - panic(err) + return err } socketListener, err := net.Listen("unix", h.cfg.UnixSocket) if err != nil { - panic(err) + return err } // Handle common process-killing signals so we can gracefully shut down: @@ -441,7 +441,7 @@ func (h *Headscale) Serve() error { networkListener, err := net.Listen("tcp", h.cfg.Addr) if err != nil { - panic(err) + return err } // Create the cmux object that will multiplex 2 protocols on the same port. From a6e99525aca8e32e1807f84017627e112b2e67ef Mon Sep 17 00:00:00 2001 From: Eugen Date: Wed, 1 Dec 2021 20:02:00 +0100 Subject: [PATCH 2/5] Add log_level to config, more ACL debug log --- .gitignore | 1 + acls.go | 7 +++++++ config-example.yaml | 2 ++ 3 files changed, 10 insertions(+) diff --git a/.gitignore b/.gitignore index ddec49c0..d047cbfd 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ config.json config.yaml derp.yaml +*.hujson *.key /db.sqlite *.sqlite3 diff --git a/acls.go b/acls.go index 1550c340..4017e28e 100644 --- a/acls.go +++ b/acls.go @@ -34,6 +34,11 @@ const ( // LoadACLPolicy loads the ACL policy from the specify path, and generates the ACL rules. func (h *Headscale) LoadACLPolicy(path string) error { + log.Debug(). + Str("func", "LoadACLPolicy"). + Str("path", path). + Msg("Loading ACL policy from path") + policyFile, err := os.Open(path) if err != nil { return err @@ -67,6 +72,8 @@ func (h *Headscale) LoadACLPolicy(path string) error { } h.aclRules = rules + log.Trace().Interface("ACL", rules).Msg("ACL rules generated") + return nil } diff --git a/config-example.yaml b/config-example.yaml index 692c605a..29b2f3ff 100644 --- a/config-example.yaml +++ b/config-example.yaml @@ -54,6 +54,8 @@ tls_letsencrypt_challenge_type: HTTP-01 tls_cert_path: "" tls_key_path: "" +log_level: info + # Path to a file containg ACL policies. acl_policy_path: "" From 3a85c4d367ffdeb5aeb41859ec01a5fd25a1f9e5 Mon Sep 17 00:00:00 2001 From: Eugen Date: Tue, 7 Dec 2021 08:46:55 +0100 Subject: [PATCH 3/5] Better error description --- app.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.go b/app.go index 0fe65761..2d3f69c2 100644 --- a/app.go +++ b/app.go @@ -418,7 +418,7 @@ func (h *Headscale) Serve() error { err = h.ensureUnixSocketIsAbsent() if err != nil { - return err + return fmt.Errorf("unable to remove old socket file: %w", err) } socketListener, err := net.Listen("unix", h.cfg.UnixSocket) From b4cce224154b9dd70bb26f6c07c826c1fc55cacb Mon Sep 17 00:00:00 2001 From: Eugen Biegler Date: Tue, 7 Dec 2021 11:44:00 +0100 Subject: [PATCH 4/5] Better error description Co-authored-by: Kristoffer Dalby --- app.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.go b/app.go index 2d3f69c2..696d8f4d 100644 --- a/app.go +++ b/app.go @@ -423,7 +423,7 @@ func (h *Headscale) Serve() error { socketListener, err := net.Listen("unix", h.cfg.UnixSocket) if err != nil { - return err + return fmt.Errorf("failed to set up gRPC socket: %w", err) } // Handle common process-killing signals so we can gracefully shut down: From 5a504fa71190ef64c4daee8790294d93766f13bf Mon Sep 17 00:00:00 2001 From: Eugen Biegler Date: Tue, 7 Dec 2021 11:44:09 +0100 Subject: [PATCH 5/5] Better error description Co-authored-by: Kristoffer Dalby --- app.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.go b/app.go index 696d8f4d..b9d570c5 100644 --- a/app.go +++ b/app.go @@ -441,7 +441,7 @@ func (h *Headscale) Serve() error { networkListener, err := net.Listen("tcp", h.cfg.Addr) if err != nil { - return err + return fmt.Errorf("failed to bind to TCP address: %w", err) } // Create the cmux object that will multiplex 2 protocols on the same port.