Skip to content

Commit

Permalink
Merge #1094: Don't throw when disabled socks config missing
Browse files Browse the repository at this point in the history
ca85ac6 Don't throw when disabled socks config missing (Daniel McNally)

Pull request description:

  Previously, the default config file generated by JM causes an error due to not having `socks5_host` and `socks5_port`, which are commented out since `socks5` is disabled by default. This commit makes those fields optional when `socks5` is not set to `true` in the config. It also makes `socks5` default to `false` if it is not specified in the config for a given IRC server.

ACKs for top commit:
  kristapsk:
    re-ACK ca85ac6

Tree-SHA512: eb33298573c684f5f845bafbec41f37f89c46431d7b5e94f9341c92563dfbfb9146e277f19a2fa4844e57fb6d8accab51340472c5ae6e73097b62a98f5c2afc5
  • Loading branch information
kristapsk committed Dec 9, 2021
2 parents ecd1083 + ca85ac6 commit e0236a8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
15 changes: 12 additions & 3 deletions jmclient/jmclient/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,13 +496,22 @@ def get_irc_mchannels():
irc_sections.append(s)
assert irc_sections

fields = [("host", str), ("port", int), ("channel", str), ("usessl", str),
("socks5", str), ("socks5_host", str), ("socks5_port", str)]
req_fields = [("host", str), ("port", int), ("channel", str), ("usessl", str)]

configs = []
for section in irc_sections:
server_data = {}
for option, otype in fields:

# check if socks5 is enabled for tor and load relevant config if so
try:
server_data["socks5"] = jm_single().config.get(section, "socks5")
except NoOptionError:
server_data["socks5"] = "false"
if server_data["socks5"].lower() == 'true':
server_data["socks5_host"] = jm_single().config.get(section, "socks5_host")
server_data["socks5_port"] = jm_single().config.get(section, "socks5_port")

for option, otype in req_fields:
val = jm_single().config.get(section, option)
server_data[option] = otype(val)
server_data['btcnet'] = get_network()
Expand Down
5 changes: 3 additions & 2 deletions jmdaemon/jmdaemon/irc.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,9 @@ def __init__(self,
self.hostid = configdata['host'] + str(configdata['port'])
self.socks5 = configdata["socks5"]
self.usessl = configdata["usessl"]
self.socks5_host = configdata["socks5_host"]
self.socks5_port = int(configdata["socks5_port"])
if self.socks5.lower() == 'true':
self.socks5_host = configdata["socks5_host"]
self.socks5_port = int(configdata["socks5_port"])
self.channel = get_config_irc_channel(configdata["channel"],
configdata["btcnet"])
self.userrealname = (username, realname)
Expand Down

0 comments on commit e0236a8

Please sign in to comment.