Skip to content

Commit

Permalink
Merge pull request #140 from qbit/buypass
Browse files Browse the repository at this point in the history
Add the ability to specify the directory URL used for ACME.
  • Loading branch information
juanfont authored Oct 3, 2021
2 parents 63fa475 + 817cc1e commit 06689ed
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/rs/zerolog/log"

"github.com/gin-gonic/gin"
"golang.org/x/crypto/acme"
"golang.org/x/crypto/acme/autocert"
"gorm.io/gorm"
"inet.af/netaddr"
Expand Down Expand Up @@ -44,6 +45,9 @@ type Config struct {
TLSCertPath string
TLSKeyPath string

ACMEURL string
ACMEEmail string

DNSConfig *tailcfg.DNSConfig
}

Expand Down Expand Up @@ -195,6 +199,10 @@ func (h *Headscale) Serve() error {
Prompt: autocert.AcceptTOS,
HostPolicy: autocert.HostWhitelist(h.cfg.TLSLetsEncryptHostname),
Cache: autocert.DirCache(h.cfg.TLSLetsEncryptCacheDir),
Client: &acme.Client{
DirectoryURL: h.cfg.ACMEURL,
},
Email: h.cfg.ACMEEmail,
}

s.TLSConfig = m.TLSConfig()
Expand Down
3 changes: 3 additions & 0 deletions cmd/headscale/cli/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ func getHeadscaleApp() (*headscale.Headscale, error) {
TLSCertPath: absPath(viper.GetString("tls_cert_path")),
TLSKeyPath: absPath(viper.GetString("tls_key_path")),

ACMEEmail: viper.GetString("acme_email"),
ACMEURL: viper.GetString("acme_url"),

DNSConfig: GetDNSConfig(),
}

Expand Down
2 changes: 2 additions & 0 deletions config.json.postgres.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"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",
Expand Down
2 changes: 2 additions & 0 deletions config.json.sqlite.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
"ephemeral_node_inactivity_timeout": "30m",
"db_type": "sqlite3",
"db_path": "db.sqlite",
"acme_url": "https://acme-v02.api.letsencrypt.org/directory",
"acme_email": "",
"tls_letsencrypt_hostname": "",
"tls_letsencrypt_listen": ":http",
"tls_letsencrypt_cache_dir": ".cache",
Expand Down

0 comments on commit 06689ed

Please sign in to comment.