Skip to content

Commit 7bdc85b

Browse files
committed
triggerforceclose: skip onion addresses when no proxy given
1 parent f20e729 commit 7bdc85b

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

cmd/chantools/triggerforceclose.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,17 @@ func (c *triggerForceCloseCommand) Execute(_ *cobra.Command, _ []string) error {
172172
for idx, openChan := range channels {
173173
addr := pickAddr(openChan.Node2Info.Node.Addresses)
174174
peerAddr := fmt.Sprintf("%s@%s", openChan.Node2, addr)
175+
176+
if c.TorProxy == "" &&
177+
strings.Contains(addr, ".onion") {
178+
179+
log.Infof("Skipping channel %s with peer %s "+
180+
"because it is a Tor address and no "+
181+
"Tor proxy is configured",
182+
openChan.ChanPoint, peerAddr)
183+
continue
184+
}
185+
175186
log.Infof("Attempting to force close channel %s with "+
176187
"peer %s (channel %d of %d)",
177188
openChan.ChanPoint, peerAddr, idx+1,
@@ -223,7 +234,7 @@ func pickAddr(addrs []*gqAddress) string {
223234

224235
// We'll pick the first address that is not a Tor address.
225236
for _, addr := range addrs {
226-
if !strings.HasSuffix(addr.Address, ".onion") {
237+
if !strings.Contains(addr.Address, ".onion") {
227238
return addr.Address
228239
}
229240
}

0 commit comments

Comments
 (0)