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) {