Skip to content

Commit 6879aea

Browse files
committed
multi: add "disable" mode for all subservers
1 parent 1f7668d commit 6879aea

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"`
@@ -427,20 +428,26 @@ func loadAndValidateConfig(interceptor signal.Interceptor) (*Config, error) {
427428
// (like the log or lnd options) as they will be taken from lnd's config
428429
// struct. Others we want to force to be the same as lnd so the user
429430
// doesn't have to set them manually, like the network for example.
430-
cfg.Faraday.Lnd.MacaroonPath = faraday.DefaultLndMacaroonPath
431-
if err := faraday.ValidateConfig(cfg.Faraday); err != nil {
432-
return nil, err
431+
if cfg.FaradayMode != ModeDisable {
432+
cfg.Faraday.Lnd.MacaroonPath = faraday.DefaultLndMacaroonPath
433+
if err := faraday.ValidateConfig(cfg.Faraday); err != nil {
434+
return nil, err
435+
}
433436
}
434437

435438
defaultLoopCfg := loopd.DefaultConfig()
436-
cfg.Loop.Lnd.MacaroonPath = defaultLoopCfg.Lnd.MacaroonPath
437-
if err := loopd.Validate(cfg.Loop); err != nil {
438-
return nil, err
439+
if cfg.LoopMode != ModeDisable {
440+
cfg.Loop.Lnd.MacaroonPath = defaultLoopCfg.Lnd.MacaroonPath
441+
if err := loopd.Validate(cfg.Loop); err != nil {
442+
return nil, err
443+
}
439444
}
440445

441-
cfg.Pool.Lnd.MacaroonPath = pool.DefaultLndMacaroonPath
442-
if err := pool.Validate(cfg.Pool); err != nil {
443-
return nil, err
446+
if cfg.PoolMode != ModeDisable {
447+
cfg.Pool.Lnd.MacaroonPath = pool.DefaultLndMacaroonPath
448+
if err := pool.Validate(cfg.Pool); err != nil {
449+
return nil, err
450+
}
444451
}
445452

446453
// 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
@@ -1406,18 +1406,24 @@ func (g *LightningTerminal) validateSuperMacaroon(ctx context.Context,
14061406
// initSubServers registers the faraday and loop sub-servers with the
14071407
// subServerMgr.
14081408
func (g *LightningTerminal) initSubServers() {
1409-
g.subServerMgr.AddServer(subservers.NewFaradaySubServer(
1410-
g.cfg.Faraday, g.cfg.faradayRpcConfig, g.cfg.Remote.Faraday,
1411-
g.cfg.faradayRemote,
1412-
))
1409+
if g.cfg.FaradayMode != ModeDisable {
1410+
g.subServerMgr.AddServer(subservers.NewFaradaySubServer(
1411+
g.cfg.Faraday, g.cfg.faradayRpcConfig,
1412+
g.cfg.Remote.Faraday, g.cfg.faradayRemote,
1413+
))
1414+
}
14131415

1414-
g.subServerMgr.AddServer(subservers.NewLoopSubServer(
1415-
g.cfg.Loop, g.cfg.Remote.Loop, g.cfg.loopRemote,
1416-
))
1416+
if g.cfg.LoopMode != ModeDisable {
1417+
g.subServerMgr.AddServer(subservers.NewLoopSubServer(
1418+
g.cfg.Loop, g.cfg.Remote.Loop, g.cfg.loopRemote,
1419+
))
1420+
}
14171421

1418-
g.subServerMgr.AddServer(subservers.NewPoolSubServer(
1419-
g.cfg.Pool, g.cfg.Remote.Pool, g.cfg.poolRemote,
1420-
))
1422+
if g.cfg.PoolMode != ModeDisable {
1423+
g.subServerMgr.AddServer(subservers.NewPoolSubServer(
1424+
g.cfg.Pool, g.cfg.Remote.Pool, g.cfg.poolRemote,
1425+
))
1426+
}
14211427
}
14221428

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

0 commit comments

Comments
 (0)