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 json
|
||||
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.read(configPath + "torch.conf")
|
||||
|
||||
torProxyPort = config['tor'].getint('ProxyPort', fallback = 9050)
|
||||
torControllerPort = config['tor'].getint('ControllerPort', fallback = 9051)
|
||||
|
||||
sshPort = config['ssh'].getint('Port', fallback = 22)
|
||||
|
||||
mqttConfig = config['mqtt']
|
||||
mqttBrokerHost = mqttConfig.get('BrokerHost', fallback = "localhost")
|
||||
mqttBrokerPort = mqttConfig.getint('BrokerPort', fallback = 1883)
|
||||
|
@ -43,7 +57,12 @@ with Controller.from_port(port = torControllerPort) as controller:
|
|||
|
||||
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()
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user