@@ -37,16 +37,28 @@ type EtcdConfig struct {
37
37
}
38
38
39
39
type AuthConfig struct {
40
+ Network string `long:"network" description:"The network LND is connected to." choice:"regtest" choice:"simnet" choice:"testnet" choice:"mainnet"`
41
+
42
+ Disable bool `long:"disable" description:"Whether to disable auth."`
43
+
40
44
// LndHost is the hostname of the LND instance to connect to.
41
45
LndHost string `long:"lndhost" description:"Hostname of the LND instance to connect to"`
42
46
43
47
TLSPath string `long:"tlspath" description:"Path to LND instance's tls certificate"`
44
48
45
49
MacDir string `long:"macdir" description:"Directory containing LND instance's macaroons"`
46
50
47
- Network string `long:"network" description:"The network LND is connected to." choice:"regtest" choice:"simnet" choice:"testnet" choice:"mainnet"`
51
+ // The one-time-use passphrase used to set up the connection. This field
52
+ // identifies the connection that will be used.
53
+ Passphrase string `long:"passphrase" description:"the lnc passphrase"`
54
+
55
+ // MailboxAddress is the address of the mailbox that the client will
56
+ // use for the LNC connection.
57
+ MailboxAddress string `long:"mailboxaddress" description:"the host:port of the mailbox server to be used"`
48
58
49
- Disable bool `long:"disable" description:"Whether to disable LND auth."`
59
+ // DevServer set to true to skip verification of the mailbox server's
60
+ // tls cert.
61
+ DevServer bool `long:"devserver" description:"set to true to skip verification of the server's tls cert."`
50
62
}
51
63
52
64
func (a * AuthConfig ) validate () error {
@@ -55,6 +67,30 @@ func (a *AuthConfig) validate() error {
55
67
return nil
56
68
}
57
69
70
+ switch {
71
+ // If LndHost is set we connect directly to the LND node.
72
+ case a .LndHost != "" :
73
+ log .Info ("Validating lnd configuration" )
74
+
75
+ if a .Passphrase != "" {
76
+ return errors .New ("passphrase field cannot be set " +
77
+ "when connecting directly to the lnd node" )
78
+ }
79
+
80
+ return a .validateLNDAuth ()
81
+
82
+ // If Passphrase is set we connect to the LND node through LNC.
83
+ case a .Passphrase != "" :
84
+ log .Info ("Validating lnc configuration" )
85
+ return a .validateLNCAuth ()
86
+
87
+ default :
88
+ return errors .New ("invalid authenticator configuration" )
89
+ }
90
+ }
91
+
92
+ // validateLNDAuth validates the direct LND auth configuration.
93
+ func (a * AuthConfig ) validateLNDAuth () error {
58
94
if a .LndHost == "" {
59
95
return errors .New ("lnd host required" )
60
96
}
@@ -70,6 +106,22 @@ func (a *AuthConfig) validate() error {
70
106
return nil
71
107
}
72
108
109
+ // validateLNCAuth validates the LNC auth configuration.
110
+ func (a * AuthConfig ) validateLNCAuth () error {
111
+ switch {
112
+ case a .Passphrase == "" :
113
+ return errors .New ("lnc passphrase required" )
114
+
115
+ case a .MailboxAddress == "" :
116
+ return errors .New ("lnc mailbox address required" )
117
+
118
+ case a .Network == "" :
119
+ return errors .New ("lnc network required" )
120
+ }
121
+
122
+ return nil
123
+ }
124
+
73
125
type HashMailConfig struct {
74
126
Enabled bool `long:"enabled"`
75
127
MessageRate time.Duration `long:"messagerate" description:"The average minimum time that should pass between each message."`
@@ -120,6 +172,8 @@ type Config struct {
120
172
// Etcd is the configuration section for the Etcd database backend.
121
173
Etcd * EtcdConfig `group:"etcd" namespace:"etcd"`
122
174
175
+ // Authenticator is the configuration section for connecting directly
176
+ // to the LND node.
123
177
Authenticator * AuthConfig `group:"authenticator" namespace:"authenticator"`
124
178
125
179
Tor * TorConfig `group:"tor" namespace:"tor"`
@@ -151,8 +205,10 @@ type Config struct {
151
205
}
152
206
153
207
func (c * Config ) validate () error {
154
- if err := c .Authenticator .validate (); err != nil {
155
- return err
208
+ if ! c .Authenticator .Disable {
209
+ if err := c .Authenticator .validate (); err != nil {
210
+ return err
211
+ }
156
212
}
157
213
158
214
if c .ListenAddr == "" {
0 commit comments