diff --git a/jmclient/jmclient/configure.py b/jmclient/jmclient/configure.py index 2899af6..1fa7c26 100644 --- a/jmclient/jmclient/configure.py +++ b/jmclient/jmclient/configure.py @@ -582,6 +582,7 @@ def get_mchannels(mode="TAKER"): # the onion messaging section must specify whether # to serve an onion: onion_data["serving"] = mode == "MAKER" + onion_data["passive"] = mode == "PASSIVE" onion_data['btcnet'] = get_network() # Just to allow a dynamic set of var: onion_data["section-name"] = s diff --git a/jmdaemon/jmdaemon/onionmc.py b/jmdaemon/jmdaemon/onionmc.py index 400053f..f398ec1 100644 --- a/jmdaemon/jmdaemon/onionmc.py +++ b/jmdaemon/jmdaemon/onionmc.py @@ -551,6 +551,13 @@ class OnionPeer(object): self.update_status(PEER_STATUS_DISCONNECTED) self.factory = None +class OnionPeerPassive(OnionPeer): + """ a type of remote peer that we are + not interested in connecting outwards to. + """ + def try_to_connect(self) -> None: + pass + class OnionDirectoryPeer(OnionPeer): delay = 4.0 def try_to_connect(self) -> None: @@ -603,6 +610,11 @@ class OnionMessageChannel(MessageChannel): # client side config: self.socks5_host = configdata["socks5_host"] self.socks5_port = configdata["socks5_port"] + # passive configuration is for bots who never need/want to connect + # to peers (apart from directories) + self.passive = False + if "passive" in configdata: + self.passive = configdata["passive"] # we use the setting in the config sent over from # the client, to decide whether to set up our connections # over localhost (if testing), without Tor: @@ -1226,9 +1238,10 @@ class OnionMessageChannel(MessageChannel): else: peer = peerdata + cls = OnionPeerPassive if self.passive else OnionPeer # assumed that it's passing a full string try: - temp_p = OnionPeer.from_location_string(self, peer, + temp_p = cls.from_location_string(self, peer, self.socks5_host, self.socks5_port, handshake_callback=self.handshake_as_client) except Exception as e: diff --git a/scripts/obwatch/ob-watcher.py b/scripts/obwatch/ob-watcher.py index f94629b..7835feb 100755 --- a/scripts/obwatch/ob-watcher.py +++ b/scripts/obwatch/ob-watcher.py @@ -807,7 +807,7 @@ def main(): check_and_start_tor() hostport = (options.host, options.port) mcs = [] - chan_configs = get_mchannels() + chan_configs = get_mchannels(mode="PASSIVE") for c in chan_configs: if "type" in c and c["type"] == "onion": mcs.append(OnionMessageChannel(c))