• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

lightningnetwork / lnd / 13236757158

10 Feb 2025 08:39AM UTC coverage: 57.649% (-1.2%) from 58.815%
13236757158

Pull #9493

github

ziggie1984
lncli: for some cmds we don't replace the data of the response.

For some cmds it is not very practical to replace the json output
because we might pipe it into other commands. For example when
creating the route we want to pipe it into sendtoRoute.
Pull Request #9493: For some lncli cmds we should not replace the content with other data

0 of 9 new or added lines in 2 files covered. (0.0%)

19535 existing lines in 252 files now uncovered.

103517 of 179563 relevant lines covered (57.65%)

24878.49 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

12.5
/watchtower/conf.go
1
package watchtower
2

3
import (
4
        "strconv"
5
        "time"
6
)
7

8
// Conf specifies the watchtower options that can be configured from the command
9
// line or configuration file.
10
type Conf struct {
11
        // RawListeners configures the watchtower's listening ports/interfaces.
12
        RawListeners []string `long:"listen" description:"Add interfaces/ports to listen for peer connections"`
13

14
        // RawExternalIPs configures the watchtower's external ports/interfaces.
15
        RawExternalIPs []string `long:"externalip" description:"Add interfaces/ports where the watchtower can accept peer connections"`
16

17
        // ReadTimeout specifies the duration the tower will wait when trying to
18
        // read a message from a client before hanging up.
19
        ReadTimeout time.Duration `long:"readtimeout" description:"Duration the watchtower server will wait for messages to be received before hanging up on clients"`
20

21
        // WriteTimeout specifies the duration the tower will wait when trying
22
        // to write a message from a client before hanging up.
23
        WriteTimeout time.Duration `long:"writetimeout" description:"Duration the watchtower server will wait for messages to be written before hanging up on client connections"`
24
}
25

26
// DefaultConf returns a Conf with some default values filled in.
27
func DefaultConf() *Conf {
1✔
28
        return &Conf{
1✔
29
                ReadTimeout:  DefaultReadTimeout,
1✔
30
                WriteTimeout: DefaultWriteTimeout,
1✔
31
        }
1✔
32
}
1✔
33

34
// Apply completes the passed Config struct by applying any parsed Conf options.
35
// If the corresponding values parsed by Conf are already set in the Config,
36
// those fields will be not be modified.
37
func (c *Conf) Apply(cfg *Config,
UNCOV
38
        normalizer AddressNormalizer) (*Config, error) {
×
UNCOV
39

×
UNCOV
40
        // Set the Config's listening addresses if they are empty.
×
UNCOV
41
        if cfg.ListenAddrs == nil {
×
UNCOV
42
                // Without a network, we will be unable to resolve the listening
×
UNCOV
43
                // addresses.
×
UNCOV
44
                if cfg.Net == nil {
×
45
                        return nil, ErrNoNetwork
×
46
                }
×
47

48
                // If no addresses are specified by the Config, we will resort
49
                // to the default peer port.
UNCOV
50
                if len(c.RawListeners) == 0 {
×
51
                        addr := DefaultListenAddr
×
52
                        c.RawListeners = append(c.RawListeners, addr)
×
53
                }
×
54

55
                // Normalize the raw listening addresses so that they can be
56
                // used by the brontide listener.
UNCOV
57
                var err error
×
UNCOV
58
                cfg.ListenAddrs, err = normalizer(
×
UNCOV
59
                        c.RawListeners, strconv.Itoa(DefaultPeerPort),
×
UNCOV
60
                        cfg.Net.ResolveTCPAddr,
×
UNCOV
61
                )
×
UNCOV
62
                if err != nil {
×
63
                        return nil, err
×
64
                }
×
65
        }
66

67
        // Set the Config's external ips if they are empty.
UNCOV
68
        if cfg.ExternalIPs == nil {
×
UNCOV
69
                // Without a network, we will be unable to resolve the external
×
UNCOV
70
                // IP addresses.
×
UNCOV
71
                if cfg.Net == nil {
×
72
                        return nil, ErrNoNetwork
×
73
                }
×
74

UNCOV
75
                var err error
×
UNCOV
76
                cfg.ExternalIPs, err = normalizer(
×
UNCOV
77
                        c.RawExternalIPs, strconv.Itoa(DefaultPeerPort),
×
UNCOV
78
                        cfg.Net.ResolveTCPAddr,
×
UNCOV
79
                )
×
UNCOV
80
                if err != nil {
×
81
                        return nil, err
×
82
                }
×
83
        }
84

85
        // If the Config has no read timeout, we will use the parsed Conf
86
        // value.
UNCOV
87
        if cfg.ReadTimeout == 0 && c.ReadTimeout != 0 {
×
UNCOV
88
                cfg.ReadTimeout = c.ReadTimeout
×
UNCOV
89
        }
×
90

91
        // If the Config has no write timeout, we will use the parsed Conf
92
        // value.
UNCOV
93
        if cfg.WriteTimeout == 0 && c.WriteTimeout != 0 {
×
UNCOV
94
                cfg.WriteTimeout = c.WriteTimeout
×
UNCOV
95
        }
×
96

UNCOV
97
        return cfg, nil
×
98
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc