Skip to content

Commit c8aa0c9

Browse files
committed
multi: add "disable" mode for all subservers
1 parent ba3193b commit c8aa0c9

File tree

2 files changed

+35
-22
lines changed

2 files changed

+35
-22
lines changed

config.go

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ const (
4141

4242
ModeIntegrated = "integrated"
4343
ModeRemote = "remote"
44+
ModeDisable = "disable"
4445

4546
DefaultLndMode = ModeRemote
4647
defaultFaradayMode = ModeIntegrated
@@ -181,13 +182,13 @@ type Config struct {
181182
LndMode string `long:"lnd-mode" description:"The mode to run lnd in, either 'remote' (default) or 'integrated'. 'integrated' means lnd is started alongside the UI and everything is stored in lnd's main data directory, configure everything by using the --lnd.* flags. 'remote' means the UI connects to an existing lnd node and acts as a proxy for gRPC calls to it. In the remote node LiT creates its own directory for log and configuration files, configure everything using the --remote.* flags." choice:"integrated" choice:"remote"`
182183
Lnd *lnd.Config `group:"Integrated lnd (use when lnd-mode=integrated)" namespace:"lnd"`
183184

184-
FaradayMode string `long:"faraday-mode" description:"The mode to run faraday in, either 'integrated' (default) or 'remote'. 'integrated' means faraday is started alongside the UI and everything is stored in faraday's main data directory, configure everything by using the --faraday.* flags. 'remote' means the UI connects to an existing faraday node and acts as a proxy for gRPC calls to it." choice:"integrated" choice:"remote"`
185+
FaradayMode string `long:"faraday-mode" description:"The mode to run faraday in, either 'integrated' (default), 'remote' or 'disable'. 'integrated' means faraday is started alongside the UI and everything is stored in faraday's main data directory, configure everything by using the --faraday.* flags. 'remote' means the UI connects to an existing faraday node and acts as a proxy for gRPC calls to it. 'disable' means that LiT is started without a connection to faraday" choice:"integrated" choice:"remote" choice:"disable"`
185186
Faraday *faraday.Config `group:"Integrated faraday options (use when faraday-mode=integrated)" namespace:"faraday"`
186187

187-
LoopMode string `long:"loop-mode" description:"The mode to run loop in, either 'integrated' (default) or 'remote'. 'integrated' means loopd is started alongside the UI and everything is stored in loop's main data directory, configure everything by using the --loop.* flags. 'remote' means the UI connects to an existing loopd node and acts as a proxy for gRPC calls to it." choice:"integrated" choice:"remote"`
188+
LoopMode string `long:"loop-mode" description:"The mode to run loop in, either 'integrated' (default), 'remote' or 'disable'. 'integrated' means loopd is started alongside the UI and everything is stored in loop's main data directory, configure everything by using the --loop.* flags. 'remote' means the UI connects to an existing loopd node and acts as a proxy for gRPC calls to it. 'disable' means that LiT is started without a connection to loop" choice:"integrated" choice:"remote" choice:"disable"`
188189
Loop *loopd.Config `group:"Integrated loop options (use when loop-mode=integrated)" namespace:"loop"`
189190

190-
PoolMode string `long:"pool-mode" description:"The mode to run pool in, either 'integrated' (default) or 'remote'. 'integrated' means poold is started alongside the UI and everything is stored in pool's main data directory, configure everything by using the --pool.* flags. 'remote' means the UI connects to an existing poold node and acts as a proxy for gRPC calls to it." choice:"integrated" choice:"remote"`
191+
PoolMode string `long:"pool-mode" description:"The mode to run pool in, either 'integrated' (default) or 'remote'. 'integrated' means poold is started alongside the UI and everything is stored in pool's main data directory, configure everything by using the --pool.* flags. 'remote' means the UI connects to an existing poold node and acts as a proxy for gRPC calls to it. 'disable' means that LiT is started without a connection to pool" choice:"integrated" choice:"remote" choice:"disable"`
191192
Pool *pool.Config `group:"Integrated pool options (use when pool-mode=integrated)" namespace:"pool"`
192193

193194
RPCMiddleware *mid.Config `group:"RPC middleware options" namespace:"rpcmiddleware"`
@@ -429,20 +430,26 @@ func loadAndValidateConfig(interceptor signal.Interceptor) (*Config, error) {
429430
// (like the log or lnd options) as they will be taken from lnd's config
430431
// struct. Others we want to force to be the same as lnd so the user
431432
// doesn't have to set them manually, like the network for example.
432-
cfg.Faraday.Lnd.MacaroonPath = faraday.DefaultLndMacaroonPath
433-
if err := faraday.ValidateConfig(cfg.Faraday); err != nil {
434-
return nil, err
433+
if cfg.FaradayMode != ModeDisable {
434+
cfg.Faraday.Lnd.MacaroonPath = faraday.DefaultLndMacaroonPath
435+
if err := faraday.ValidateConfig(cfg.Faraday); err != nil {
436+
return nil, err
437+
}
435438
}
436439

437440
defaultLoopCfg := loopd.DefaultConfig()
438-
cfg.Loop.Lnd.MacaroonPath = defaultLoopCfg.Lnd.MacaroonPath
439-
if err := loopd.Validate(cfg.Loop); err != nil {
440-
return nil, err
441+
if cfg.LoopMode != ModeDisable {
442+
cfg.Loop.Lnd.MacaroonPath = defaultLoopCfg.Lnd.MacaroonPath
443+
if err := loopd.Validate(cfg.Loop); err != nil {
444+
return nil, err
445+
}
441446
}
442447

443-
cfg.Pool.Lnd.MacaroonPath = pool.DefaultLndMacaroonPath
444-
if err := pool.Validate(cfg.Pool); err != nil {
445-
return nil, err
448+
if cfg.PoolMode != ModeDisable {
449+
cfg.Pool.Lnd.MacaroonPath = pool.DefaultLndMacaroonPath
450+
if err := pool.Validate(cfg.Pool); err != nil {
451+
return nil, err
452+
}
446453
}
447454

448455
// We've set the network before and have now validated the loop config

terminal.go

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1409,18 +1409,24 @@ func (g *LightningTerminal) validateSuperMacaroon(ctx context.Context,
14091409
// initSubServers registers the faraday and loop sub-servers with the
14101410
// subServerMgr.
14111411
func (g *LightningTerminal) initSubServers() {
1412-
g.subServerMgr.AddServer(subservers.NewFaradaySubServer(
1413-
g.cfg.Faraday, g.cfg.faradayRpcConfig, g.cfg.Remote.Faraday,
1414-
g.cfg.faradayRemote,
1415-
))
1412+
if g.cfg.FaradayMode != ModeDisable {
1413+
g.subServerMgr.AddServer(subservers.NewFaradaySubServer(
1414+
g.cfg.Faraday, g.cfg.faradayRpcConfig,
1415+
g.cfg.Remote.Faraday, g.cfg.faradayRemote,
1416+
))
1417+
}
14161418

1417-
g.subServerMgr.AddServer(subservers.NewLoopSubServer(
1418-
g.cfg.Loop, g.cfg.Remote.Loop, g.cfg.loopRemote,
1419-
))
1419+
if g.cfg.LoopMode != ModeDisable {
1420+
g.subServerMgr.AddServer(subservers.NewLoopSubServer(
1421+
g.cfg.Loop, g.cfg.Remote.Loop, g.cfg.loopRemote,
1422+
))
1423+
}
14201424

1421-
g.subServerMgr.AddServer(subservers.NewPoolSubServer(
1422-
g.cfg.Pool, g.cfg.Remote.Pool, g.cfg.poolRemote,
1423-
))
1425+
if g.cfg.PoolMode != ModeDisable {
1426+
g.subServerMgr.AddServer(subservers.NewPoolSubServer(
1427+
g.cfg.Pool, g.cfg.Remote.Pool, g.cfg.poolRemote,
1428+
))
1429+
}
14241430
}
14251431

14261432
// BakeSuperMacaroon uses the lnd client to bake a macaroon that can include

0 commit comments

Comments
 (0)