Skip to content

Commit 59efe37

Browse files
authored
Merge pull request #230 from joostjager/doc-insecure
loopd: group and clarify swap server parameters
2 parents de41c93 + b61b886 commit 59efe37

File tree

5 files changed

+33
-25
lines changed

5 files changed

+33
-25
lines changed

client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ type ClientConfig struct {
9191
// connection.
9292
ProxyAddress string
9393

94-
// Insecure skips TLS when set.
95-
Insecure bool
94+
// SwapServerNoTLS skips TLS for the swap server connection when set.
95+
SwapServerNoTLS bool
9696

9797
// TLSPathServer is the path to the TLS certificate that is required to
9898
// connect to the server.

loopd/config.go

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,22 @@ type lndConfig struct {
2626
TLSPath string `long:"tlspath" description:"Path to lnd tls certificate"`
2727
}
2828

29+
type loopServerConfig struct {
30+
Host string `long:"host" description:"Loop server address host:port"`
31+
Proxy string `long:"proxy" description:"The host:port of a SOCKS proxy through which all connections to the loop server will be established over"`
32+
33+
NoTLS bool `long:"notls" description:"Disable tls for communication to the loop server [testing only]"`
34+
TLSPath string `long:"tlspath" description:"Path to loop server tls certificate [testing only]"`
35+
}
36+
2937
type viewParameters struct{}
3038

3139
type Config struct {
32-
ShowVersion bool `long:"version" description:"Display version information and exit"`
33-
Insecure bool `long:"insecure" description:"disable tls"`
34-
Network string `long:"network" description:"network to run on" choice:"regtest" choice:"testnet" choice:"mainnet" choice:"simnet"`
35-
SwapServer string `long:"swapserver" description:"swap server address host:port"`
36-
TLSPathSwapSrv string `long:"tlspathswapserver" description:"Path to swap server tls certificate. Only needed if the swap server uses a self-signed certificate."`
37-
RPCListen string `long:"rpclisten" description:"Address to listen on for gRPC clients"`
38-
RESTListen string `long:"restlisten" description:"Address to listen on for REST clients"`
39-
CORSOrigin string `long:"corsorigin" description:"The value to send in the Access-Control-Allow-Origin header. Header will be omitted if empty."`
40+
ShowVersion bool `long:"version" description:"Display version information and exit"`
41+
Network string `long:"network" description:"network to run on" choice:"regtest" choice:"testnet" choice:"mainnet" choice:"simnet"`
42+
RPCListen string `long:"rpclisten" description:"Address to listen on for gRPC clients"`
43+
RESTListen string `long:"restlisten" description:"Address to listen on for REST clients"`
44+
CORSOrigin string `long:"corsorigin" description:"The value to send in the Access-Control-Allow-Origin header. Header will be omitted if empty."`
4045

4146
LogDir string `long:"logdir" description:"Directory to log output."`
4247
MaxLogFiles int `long:"maxlogfiles" description:"Maximum logfiles to keep (0 for no rotation)"`
@@ -48,8 +53,9 @@ type Config struct {
4853

4954
LoopOutMaxParts uint32 `long:"loopoutmaxparts" description:"The maximum number of payment parts that may be used for a loop out swap."`
5055

51-
Lnd *lndConfig `group:"lnd" namespace:"lnd"`
52-
Proxy string `long:"proxy" description:"The host:port of a SOCKS proxy through which all connections to the swap server will be established over."`
56+
Lnd *lndConfig `group:"lnd" namespace:"lnd"`
57+
58+
Server *loopServerConfig `group:"server" namespace:"server"`
5359

5460
View viewParameters `command:"view" alias:"v" description:"View all swaps in the database. This command can only be executed when loopd is not running."`
5561
}
@@ -62,10 +68,12 @@ const (
6268
// DefaultConfig returns all default values for the Config struct.
6369
func DefaultConfig() Config {
6470
return Config{
65-
Network: "mainnet",
66-
RPCListen: "localhost:11010",
67-
RESTListen: "localhost:8081",
68-
Insecure: false,
71+
Network: "mainnet",
72+
RPCListen: "localhost:11010",
73+
RESTListen: "localhost:8081",
74+
Server: &loopServerConfig{
75+
NoTLS: false,
76+
},
6977
LogDir: defaultLogDir,
7078
MaxLogFiles: defaultMaxLogFiles,
7179
MaxLogFileSize: defaultMaxLogFileSize,

loopd/daemon.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,20 +269,20 @@ func (d *Daemon) startWebServers() error {
269269
func (d *Daemon) initialize() error {
270270
// If no swap server is specified, use the default addresses for mainnet
271271
// and testnet.
272-
if d.cfg.SwapServer == "" {
272+
if d.cfg.Server.Host == "" {
273273
// TODO(wilmer): Use onion service addresses when proxy is
274274
// active.
275275
switch d.cfg.Network {
276276
case "mainnet":
277-
d.cfg.SwapServer = mainnetServer
277+
d.cfg.Server.Host = mainnetServer
278278
case "testnet":
279-
d.cfg.SwapServer = testnetServer
279+
d.cfg.Server.Host = testnetServer
280280
default:
281281
return errors.New("no swap server address specified")
282282
}
283283
}
284284

285-
log.Infof("Swap server address: %v", d.cfg.SwapServer)
285+
log.Infof("Swap server address: %v", d.cfg.Server.Host)
286286

287287
// Create an instance of the loop client library.
288288
swapclient, clientCleanup, err := getClient(d.cfg, &d.lnd.LndServices)

loopd/utils.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ func getClient(config *Config, lnd *lndclient.LndServices) (*loop.Client,
1919
}
2020

2121
clientConfig := &loop.ClientConfig{
22-
ServerAddress: config.SwapServer,
23-
ProxyAddress: config.Proxy,
24-
Insecure: config.Insecure,
25-
TLSPathServer: config.TLSPathSwapSrv,
22+
ServerAddress: config.Server.Host,
23+
ProxyAddress: config.Server.Proxy,
24+
SwapServerNoTLS: config.Server.NoTLS,
25+
TLSPathServer: config.Server.TLSPath,
2626
Lnd: lnd,
2727
MaxLsatCost: btcutil.Amount(config.MaxLSATCost),
2828
MaxLsatFee: btcutil.Amount(config.MaxLSATFee),

swap_server_client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func newSwapServerClient(cfg *ClientConfig, lsatStore lsat.Store) (
7070
cfg.MaxLsatFee,
7171
)
7272
serverConn, err := getSwapServerConn(
73-
cfg.ServerAddress, cfg.ProxyAddress, cfg.Insecure,
73+
cfg.ServerAddress, cfg.ProxyAddress, cfg.SwapServerNoTLS,
7474
cfg.TLSPathServer, clientInterceptor,
7575
)
7676
if err != nil {

0 commit comments

Comments
 (0)