tordam

A library for peer discovery inside the Tor network
git clone https://git.parazyd.org/tordam
Log | Files | Refs | README | LICENSE

commit 06e03f40cc8014ace861696e1089cbda15154638
parent 6d8fac0b3c2775ae45669b3ed69fc6a113e5388a
Author: parazyd <parazyd@dyne.org>
Date:   Wed, 26 Dec 2018 09:58:28 -0500

Use argparse in damhs.py.

Diffstat:
Mcmd/dam-client/main.go | 5+++--
Mpython/damhs.py | 19+++++++++++++++----
2 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/cmd/dam-client/main.go b/cmd/dam-client/main.go @@ -37,8 +37,9 @@ import ( "sync" "time" - lib "github.com/parazyd/tor-dam/pkg/damlib" "golang.org/x/crypto/ed25519" + + lib "github.com/parazyd/tor-dam/pkg/damlib" ) type msgStruct struct { @@ -251,7 +252,7 @@ func main() { } log.Println("Starting up the hidden service.") - cmd := exec.Command("damhs.py", lib.PrivKeyPath, lib.TorPortMap) + cmd := exec.Command("damhs.py", "-k", lib.PrivKeyPath, "-p", lib.TorPortMap) defer cmd.Process.Kill() stdout, err := cmd.StdoutPipe() lib.CheckError(err) diff --git a/python/damhs.py b/python/damhs.py @@ -26,8 +26,10 @@ Usage: damhs.py <path_to_private.key> <portmap> following element: 80:49371 (80 is the remote, 49371 is local) """ -from sys import argv, stdout +from argparse import ArgumentParser +from sys import stdout from time import sleep + from stem.control import Controller @@ -44,16 +46,25 @@ def main(): """ Main loop """ + parser = ArgumentParser() + parser.add_argument('-k', '--private-key', + help='Path to the ed25519 private key', + default='/home/decode/.dam/private.key') + parser.add_argument('-p', '--port-map', action='store_true', + help='Comma-separated string of local:remote ports', + default='80:49731,5000:5000') + args = parser.parse_args() + ctl = Controller.from_port() ctl.authenticate(password='topkek') portmap = {} - ports = argv[2].split(',') + ports = args.port_map.split(',') for i in ports: tup = i.split(':') portmap[int(tup[0])] = int(tup[1]) - keyfile = argv[1] + keyfile = args.private_key ktype = 'ED25519-V3' kcont = open(keyfile).read() @@ -63,7 +74,7 @@ def main(): stdout.write('OK\n') stdout.flush() while True: - sleep(60) + sleep(60) if __name__ == '__main__':