Skip to content

Commit 600477d

Browse files
authored
Merge pull request #163 from lightninglabs/insecure-http
add insecure HTTP only listener option
2 parents 22c72ac + 2ebff9b commit 600477d

File tree

2 files changed

+36
-3
lines changed

2 files changed

+36
-3
lines changed

config.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ var (
112112
// daemon's short name.
113113
type Config struct {
114114
HTTPSListen string `long:"httpslisten" description:"The host:port to listen for incoming HTTP/2 connections on for the web UI only."`
115+
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."`
115116
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."`
116117
UIPasswordFile string `long:"uipassword_file" description:"Same as uipassword but instead of passing in the value directly, read the password from the specified file."`
117118
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."`
@@ -329,7 +330,7 @@ func loadAndValidateConfig() (*Config, error) {
329330
if err := pool.Validate(cfg.Pool); err != nil {
330331
return nil, err
331332
}
332-
333+
333334
cfg.Faraday.Network = cfg.network
334335
if err := faraday.ValidateConfig(cfg.Faraday); err != nil {
335336
return nil, err

terminal.go

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,28 @@ func (g *LightningTerminal) startMainWebServer() error {
592592
}
593593
}()
594594

595+
// We only enable an additional HTTP only listener if the user
596+
// explicitly sets a value.
597+
if g.cfg.HTTPListen != "" {
598+
insecureListener, err := net.Listen("tcp", g.cfg.HTTPListen)
599+
if err != nil {
600+
return fmt.Errorf("unable to listen on %v: %v",
601+
g.cfg.HTTPListen, err)
602+
}
603+
604+
g.wg.Add(1)
605+
go func() {
606+
defer g.wg.Done()
607+
608+
log.Infof("Listening for http on: %v",
609+
insecureListener.Addr())
610+
err := g.httpServer.Serve(insecureListener)
611+
if err != nil && err != http.ErrServerClosed {
612+
log.Errorf("http server error: %v", err)
613+
}
614+
}()
615+
}
616+
595617
return nil
596618
}
597619

@@ -611,8 +633,8 @@ func (g *LightningTerminal) showStartupInfo() error {
611633
version: build.Version(),
612634
webURI: fmt.Sprintf("https://%s", strings.ReplaceAll(
613635
strings.ReplaceAll(
614-
g.cfg.HTTPSListen, "0.0.0.0", "127.0.0.1",
615-
), "[::]", "[::1]",
636+
g.cfg.HTTPSListen, "0.0.0.0", "localhost",
637+
), "[::]", "localhost",
616638
)),
617639
}
618640

@@ -659,6 +681,16 @@ func (g *LightningTerminal) showStartupInfo() error {
659681
}
660682
}
661683

684+
// If there's an additional HTTP listener, list it as well.
685+
if g.cfg.HTTPListen != "" {
686+
host := strings.ReplaceAll(
687+
strings.ReplaceAll(
688+
g.cfg.HTTPListen, "0.0.0.0", "localhost",
689+
), "[::]", "localhost",
690+
)
691+
info.webURI = fmt.Sprintf("%s, http://%s", info.webURI, host)
692+
}
693+
662694
str := "" +
663695
"----------------------------------------------------------\n" +
664696
" Lightning Terminal (LiT) by Lightning Labs \n" +

0 commit comments

Comments
 (0)