config: modify private key path to be onion type agnostic
This commit is contained in:
1 file changed
+17
-6
@@ -57,6 +57,7 @@ const (
|
|||||||
defaultTorDNSPort = 53
|
defaultTorDNSPort = 53
|
||||||
defaultTorControlPort = 9051
|
defaultTorControlPort = 9051
|
||||||
defaultTorV2PrivateKeyFilename = "v2_onion_private_key"
|
defaultTorV2PrivateKeyFilename = "v2_onion_private_key"
|
||||||
|
defaultTorV3PrivateKeyFilename = "v3_onion_private_key"
|
||||||
|
|
||||||
defaultBroadcastDelta = 10
|
defaultBroadcastDelta = 10
|
||||||
|
|
||||||
@@ -89,7 +90,6 @@ var (
|
|||||||
defaultTorSOCKS = net.JoinHostPort("localhost", strconv.Itoa(defaultTorSOCKSPort))
|
defaultTorSOCKS = net.JoinHostPort("localhost", strconv.Itoa(defaultTorSOCKSPort))
|
||||||
defaultTorDNS = net.JoinHostPort(defaultTorDNSHost, strconv.Itoa(defaultTorDNSPort))
|
defaultTorDNS = net.JoinHostPort(defaultTorDNSHost, strconv.Itoa(defaultTorDNSPort))
|
||||||
defaultTorControl = net.JoinHostPort("localhost", strconv.Itoa(defaultTorControlPort))
|
defaultTorControl = net.JoinHostPort("localhost", strconv.Itoa(defaultTorControlPort))
|
||||||
defaultTorV2PrivateKeyPath = filepath.Join(defaultLndDir, defaultTorV2PrivateKeyFilename)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type chainConfig struct {
|
type chainConfig struct {
|
||||||
@@ -154,8 +154,8 @@ type torConfig struct {
|
|||||||
StreamIsolation bool `long:"streamisolation" description:"Enable Tor stream isolation by randomizing user credentials for each connection."`
|
StreamIsolation bool `long:"streamisolation" description:"Enable Tor stream isolation by randomizing user credentials for each connection."`
|
||||||
Control string `long:"control" description:"The host:port that Tor is listening on for Tor control connections"`
|
Control string `long:"control" description:"The host:port that Tor is listening on for Tor control connections"`
|
||||||
V2 bool `long:"v2" description:"Automatically set up a v2 onion service to listen for inbound connections"`
|
V2 bool `long:"v2" description:"Automatically set up a v2 onion service to listen for inbound connections"`
|
||||||
V2PrivateKeyPath string `long:"v2privatekeypath" description:"The path to the private key of the onion service being created"`
|
V3 bool `long:"v3" description:"Automatically set up a v3 onion service to listen for inbound connections"`
|
||||||
V3 bool `long:"v3" description:"Use a v3 onion service to listen for inbound connections"`
|
PrivateKeyPath string `long:"privatekeypath" description:"The path to the private key of the onion service being created"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// config defines the configuration options for lnd.
|
// config defines the configuration options for lnd.
|
||||||
@@ -307,7 +307,6 @@ func loadConfig() (*config, error) {
|
|||||||
SOCKS: defaultTorSOCKS,
|
SOCKS: defaultTorSOCKS,
|
||||||
DNS: defaultTorDNS,
|
DNS: defaultTorDNS,
|
||||||
Control: defaultTorControl,
|
Control: defaultTorControl,
|
||||||
V2PrivateKeyPath: defaultTorV2PrivateKeyPath,
|
|
||||||
},
|
},
|
||||||
net: &tor.ClearNet{},
|
net: &tor.ClearNet{},
|
||||||
}
|
}
|
||||||
@@ -363,7 +362,6 @@ func loadConfig() (*config, error) {
|
|||||||
cfg.TLSCertPath = filepath.Join(lndDir, defaultTLSCertFilename)
|
cfg.TLSCertPath = filepath.Join(lndDir, defaultTLSCertFilename)
|
||||||
cfg.TLSKeyPath = filepath.Join(lndDir, defaultTLSKeyFilename)
|
cfg.TLSKeyPath = filepath.Join(lndDir, defaultTLSKeyFilename)
|
||||||
cfg.LogDir = filepath.Join(lndDir, defaultLogDirname)
|
cfg.LogDir = filepath.Join(lndDir, defaultLogDirname)
|
||||||
cfg.Tor.V2PrivateKeyPath = filepath.Join(lndDir, defaultTorV2PrivateKeyFilename)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the lnd directory if it doesn't already exist.
|
// Create the lnd directory if it doesn't already exist.
|
||||||
@@ -399,7 +397,7 @@ func loadConfig() (*config, error) {
|
|||||||
cfg.LtcdMode.Dir = cleanAndExpandPath(cfg.LtcdMode.Dir)
|
cfg.LtcdMode.Dir = cleanAndExpandPath(cfg.LtcdMode.Dir)
|
||||||
cfg.BitcoindMode.Dir = cleanAndExpandPath(cfg.BitcoindMode.Dir)
|
cfg.BitcoindMode.Dir = cleanAndExpandPath(cfg.BitcoindMode.Dir)
|
||||||
cfg.LitecoindMode.Dir = cleanAndExpandPath(cfg.LitecoindMode.Dir)
|
cfg.LitecoindMode.Dir = cleanAndExpandPath(cfg.LitecoindMode.Dir)
|
||||||
cfg.Tor.V2PrivateKeyPath = cleanAndExpandPath(cfg.Tor.V2PrivateKeyPath)
|
cfg.Tor.PrivateKeyPath = cleanAndExpandPath(cfg.Tor.PrivateKeyPath)
|
||||||
|
|
||||||
// Ensure that the user didn't attempt to specify negative values for
|
// Ensure that the user didn't attempt to specify negative values for
|
||||||
// any of the autopilot params.
|
// any of the autopilot params.
|
||||||
@@ -490,6 +488,19 @@ func loadConfig() (*config, error) {
|
|||||||
cfg.DisableListen = true
|
cfg.DisableListen = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if cfg.Tor.PrivateKeyPath == "" {
|
||||||
|
switch {
|
||||||
|
case cfg.Tor.V2:
|
||||||
|
cfg.Tor.PrivateKeyPath = filepath.Join(
|
||||||
|
lndDir, defaultTorV2PrivateKeyFilename,
|
||||||
|
)
|
||||||
|
case cfg.Tor.V3:
|
||||||
|
cfg.Tor.PrivateKeyPath = filepath.Join(
|
||||||
|
lndDir, defaultTorV3PrivateKeyFilename,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Set up the network-related functions that will be used throughout
|
// Set up the network-related functions that will be used throughout
|
||||||
// the daemon. We use the standard Go "net" package functions by
|
// the daemon. We use the standard Go "net" package functions by
|
||||||
// default. If we should be proxying all traffic through Tor, then
|
// default. If we should be proxying all traffic through Tor, then
|
||||||
|
|||||||
Reference in new issue
Block a user