From b0d4d7c9a47b20b82d8eeb51f6b7904b46812da9 Mon Sep 17 00:00:00 2001 From: eyedeekay Date: Wed, 21 Aug 2024 17:37:01 -0400 Subject: [PATCH] bail out of the main sooner when testing --- contrib/dendrite-demo-i2p/main_i2p.go | 9 ++++++++- contrib/dendrite-demo-tor/main_tor.go | 18 ++++++++++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/contrib/dendrite-demo-i2p/main_i2p.go b/contrib/dendrite-demo-i2p/main_i2p.go index bfe5730b4a..3e3730988a 100644 --- a/contrib/dendrite-demo-i2p/main_i2p.go +++ b/contrib/dendrite-demo-i2p/main_i2p.go @@ -42,7 +42,14 @@ import ( "github.com/matrix-org/dendrite/setup/config" ) -var sam, err = goSam.NewClient(*samAddr) +func client() (*goSam.Client, error) { + if skip { + return nil, nil + } + return goSam.NewClient(*samAddr) +} + +var sam, err = client() // Dial a network connection to an I2P server or a unix socket. Fail for clearnet addresses. func Dial(network, addr string) (net.Conn, error) { diff --git a/contrib/dendrite-demo-tor/main_tor.go b/contrib/dendrite-demo-tor/main_tor.go index ba240961f4..9222870531 100644 --- a/contrib/dendrite-demo-tor/main_tor.go +++ b/contrib/dendrite-demo-tor/main_tor.go @@ -40,8 +40,22 @@ import ( "github.com/matrix-org/dendrite/setup/config" ) -var t, terr = tor.Start(context.Background(), nil) -var tdialer, tderr = t.Dialer(context.TODO(), nil) +func start() (*tor.Tor, error) { + if skip { + return nil, nil + } + return tor.Start(context.Background(), nil) +} + +func dialer() (*tor.Dialer, error) { + if skip { + return nil, nil + } + return t.Dialer(context.TODO(), nil) +} + +var t, terr = start() +var tdialer, tderr = dialer() // Dial either a unix socket address, or connect to a remote address over Tor. Always uses Tor. func Dial(network, addr string) (net.Conn, error) {