Added --config-dir parameter and timestamp in payload
This commit is contained in:
parent
5db0672423
commit
c415b548c5
23
torch-pub.py
23
torch-pub.py
|
@ -6,15 +6,29 @@ import socks
|
||||||
import socket
|
import socket
|
||||||
import json
|
import json
|
||||||
import configparser
|
import configparser
|
||||||
|
import argparse
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
configPath = "/etc/torch/"
|
parser = argparse.ArgumentParser(description='Broadcast SSH hidden service hostname via MQTT')
|
||||||
|
|
||||||
|
parser.add_argument('--config-dir', nargs='?', dest='configPath', default='/etc/torch',
|
||||||
|
help='configuration directory (default: /etc/torch)')
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
configPath = args.configPath
|
||||||
|
|
||||||
|
if not configPath.endswith("/"):
|
||||||
|
configPath = configPath + "/"
|
||||||
|
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
config.read(configPath + "torch.conf")
|
config.read(configPath + "torch.conf")
|
||||||
|
|
||||||
torProxyPort = config['tor'].getint('ProxyPort', fallback = 9050)
|
torProxyPort = config['tor'].getint('ProxyPort', fallback = 9050)
|
||||||
torControllerPort = config['tor'].getint('ControllerPort', fallback = 9051)
|
torControllerPort = config['tor'].getint('ControllerPort', fallback = 9051)
|
||||||
|
|
||||||
sshPort = config['ssh'].getint('Port', fallback = 22)
|
sshPort = config['ssh'].getint('Port', fallback = 22)
|
||||||
|
|
||||||
mqttConfig = config['mqtt']
|
mqttConfig = config['mqtt']
|
||||||
mqttBrokerHost = mqttConfig.get('BrokerHost', fallback = "localhost")
|
mqttBrokerHost = mqttConfig.get('BrokerHost', fallback = "localhost")
|
||||||
mqttBrokerPort = mqttConfig.getint('BrokerPort', fallback = 1883)
|
mqttBrokerPort = mqttConfig.getint('BrokerPort', fallback = 1883)
|
||||||
|
@ -43,7 +57,12 @@ with Controller.from_port(port = torControllerPort) as controller:
|
||||||
|
|
||||||
onionAddress = "%s.onion" % (service.service_id)
|
onionAddress = "%s.onion" % (service.service_id)
|
||||||
|
|
||||||
payload = { 'clientId': clientID, 'onionAddress': onionAddress }
|
payload = {
|
||||||
|
'clientId': clientID,
|
||||||
|
'timestamp': datetime.now().strftime("%d-%b-%Y (%H:%M:%S.%f)"),
|
||||||
|
'onionAddress': onionAddress,
|
||||||
|
'sshPort': sshPort
|
||||||
|
}
|
||||||
|
|
||||||
client = mqtt.Client()
|
client = mqtt.Client()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user