Merge pull request #2704 from MDrollette/multiple-opts

config: allow adding multiple tls ips and domains
This commit is contained in:
Johan T. Halseth 2019-05-22 08:59:19 +02:00 committed by GitHub
commit 4806003b74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 21 deletions

@ -224,8 +224,8 @@ type config struct {
DataDir string `short:"b" long:"datadir" description:"The directory to store lnd's data within"` DataDir string `short:"b" long:"datadir" description:"The directory to store lnd's data within"`
TLSCertPath string `long:"tlscertpath" description:"Path to write the TLS certificate for lnd's RPC and REST services"` TLSCertPath string `long:"tlscertpath" description:"Path to write the TLS certificate for lnd's RPC and REST services"`
TLSKeyPath string `long:"tlskeypath" description:"Path to write the TLS private key for lnd's RPC and REST services"` TLSKeyPath string `long:"tlskeypath" description:"Path to write the TLS private key for lnd's RPC and REST services"`
TLSExtraIP string `long:"tlsextraip" description:"Adds an extra ip to the generated certificate"` TLSExtraIPs []string `long:"tlsextraip" description:"Adds an extra ip to the generated certificate"`
TLSExtraDomain string `long:"tlsextradomain" description:"Adds an extra domain to the generated certificate"` TLSExtraDomains []string `long:"tlsextradomain" description:"Adds an extra domain to the generated certificate"`
NoMacaroons bool `long:"no-macaroons" description:"Disable macaroon authentication"` NoMacaroons bool `long:"no-macaroons" description:"Disable macaroon authentication"`
AdminMacPath string `long:"adminmacaroonpath" description:"Path to write the admin macaroon for lnd's RPC and REST services if it doesn't exist"` AdminMacPath string `long:"adminmacaroonpath" description:"Path to write the admin macaroon for lnd's RPC and REST services if it doesn't exist"`
ReadMacPath string `long:"readonlymacaroonpath" description:"Path to write the read-only macaroon for lnd's RPC and REST services if it doesn't exist"` ReadMacPath string `long:"readonlymacaroonpath" description:"Path to write the read-only macaroon for lnd's RPC and REST services if it doesn't exist"`

10
lnd.go

@ -531,11 +531,13 @@ func genCertPair(certFile, keyFile string) error {
} }
} }
// Add extra IP to the slice. // Add extra IPs to the slice.
ipAddr := net.ParseIP(cfg.TLSExtraIP) for _, ip := range cfg.TLSExtraIPs {
ipAddr := net.ParseIP(ip)
if ipAddr != nil { if ipAddr != nil {
addIP(ipAddr) addIP(ipAddr)
} }
}
// Collect the host's names into a slice. // Collect the host's names into a slice.
host, err := os.Hostname() host, err := os.Hostname()
@ -546,9 +548,7 @@ func genCertPair(certFile, keyFile string) error {
if host != "localhost" { if host != "localhost" {
dnsNames = append(dnsNames, "localhost") dnsNames = append(dnsNames, "localhost")
} }
if cfg.TLSExtraDomain != "" { dnsNames = append(dnsNames, cfg.TLSExtraDomains...)
dnsNames = append(dnsNames, cfg.TLSExtraDomain)
}
// Also add fake hostnames for unix sockets, otherwise hostname // Also add fake hostnames for unix sockets, otherwise hostname
// verification will fail in the client. // verification will fail in the client.