Skip to content

Commit f52b046

Browse files
authored
Merge pull request #519 from ellemouton/disableui
multi: add DisableUI option
2 parents cea367c + 4a132f1 commit f52b046

14 files changed

+1060
-108
lines changed

cmd/litcli/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ func main() {
7575
app.Commands = append(app.Commands, listActionsCommand)
7676
app.Commands = append(app.Commands, privacyMapCommands)
7777
app.Commands = append(app.Commands, autopilotCommands)
78+
app.Commands = append(app.Commands, litCommands...)
7879

7980
err := app.Run(os.Args)
8081
if err != nil {

cmd/litcli/proxy.go

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
package main
2+
3+
import (
4+
"context"
5+
"fmt"
6+
7+
"github.com/lightninglabs/lightning-terminal/litrpc"
8+
"github.com/urfave/cli"
9+
)
10+
11+
var litCommands = []cli.Command{
12+
{
13+
Name: "stop",
14+
Usage: "shutdown the LiT daemon",
15+
Category: "LiT",
16+
Action: shutdownLit,
17+
},
18+
{
19+
Name: "getinfo",
20+
Usage: "Returns basic information related to the active " +
21+
"daemon.",
22+
Category: "LiT",
23+
Action: getInfo,
24+
},
25+
}
26+
27+
func getInfo(ctx *cli.Context) error {
28+
clientConn, cleanup, err := connectClient(ctx)
29+
if err != nil {
30+
return err
31+
}
32+
defer cleanup()
33+
client := litrpc.NewProxyClient(clientConn)
34+
35+
ctxb := context.Background()
36+
resp, err := client.GetInfo(ctxb, &litrpc.GetInfoRequest{})
37+
if err != nil {
38+
return err
39+
}
40+
41+
printRespJSON(resp)
42+
43+
return nil
44+
}
45+
46+
func shutdownLit(ctx *cli.Context) error {
47+
clientConn, cleanup, err := connectClient(ctx)
48+
if err != nil {
49+
return err
50+
}
51+
defer cleanup()
52+
client := litrpc.NewProxyClient(clientConn)
53+
54+
ctxb := context.Background()
55+
_, err = client.StopDaemon(ctxb, &litrpc.StopDaemonRequest{})
56+
if err != nil {
57+
return err
58+
}
59+
60+
fmt.Println("Successfully shutdown LiTd")
61+
62+
return nil
63+
}

config.go

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,10 @@ type Config struct {
143143
HTTPListen string `long:"insecure-httplisten" description:"The host:port to listen on with TLS disabled. This is dangerous to enable as credentials will be submitted without encryption. Should only be used in combination with Tor hidden services or other external encryption."`
144144
EnableREST bool `long:"enablerest" description:"Also allow REST requests to be made to the main HTTP(s) port(s) configured above."`
145145
RestCORS []string `long:"restcors" description:"Add an ip:port/hostname to allow cross origin access from. To allow all origins, set as \"*\"."`
146-
UIPassword string `long:"uipassword" description:"The password that must be entered when using the loop UI. use a strong password to protect your node from unauthorized access through the web UI."`
146+
UIPassword string `long:"uipassword" description:"The password that must be entered when using the UI. Use a strong password to protect your node from unauthorized access through the web UI."`
147147
UIPasswordFile string `long:"uipassword_file" description:"Same as uipassword but instead of passing in the value directly, read the password from the specified file."`
148148
UIPasswordEnv string `long:"uipassword_env" description:"Same as uipassword but instead of passing in the value directly, read the password from the specified environment variable."`
149+
DisableUI bool `long:"disableui" description:"If set to true, no web UI will be served and so the uipassword will also not need to be set."`
149150

150151
LetsEncrypt bool `long:"letsencrypt" description:"Use Let's Encrypt to create a TLS certificate for the UI instead of using lnd's TLS certificate. Port 80 must be free to listen on and must be reachable from the internet for this to work."`
151152
LetsEncryptHost string `long:"letsencrypthost" description:"The host name to create a Let's Encrypt certificate for."`
@@ -424,13 +425,19 @@ func loadAndValidateConfig(interceptor signal.Interceptor) (*Config, error) {
424425
return nil, err
425426
}
426427
}
427-
err = readUIPassword(cfg)
428-
if err != nil {
429-
return nil, fmt.Errorf("could not read UI password: %v", err)
430-
}
431-
if len(cfg.UIPassword) < uiPasswordMinLength {
432-
return nil, fmt.Errorf("please set a strong password for the "+
433-
"UI, at least %d characters long", uiPasswordMinLength)
428+
429+
// If the web UI is enabled, a UI password must be provided.
430+
if !cfg.DisableUI {
431+
err = readUIPassword(cfg)
432+
if err != nil {
433+
return nil, fmt.Errorf("could not read UI password: %v",
434+
err)
435+
}
436+
if len(cfg.UIPassword) < uiPasswordMinLength {
437+
return nil, fmt.Errorf("please set a strong "+
438+
"password for the UI, at least %d characters "+
439+
"long", uiPasswordMinLength)
440+
}
434441
}
435442

436443
if cfg.Network != DefaultNetwork {

0 commit comments

Comments
 (0)