URI: 
       tUse argparse in damhs.py. - tordam - A library for peer discovery inside the Tor network
  HTML git clone https://git.parazyd.org/tordam
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
   DIR commit 06e03f40cc8014ace861696e1089cbda15154638
   DIR parent 6d8fac0b3c2775ae45669b3ed69fc6a113e5388a
  HTML Author: parazyd <parazyd@dyne.org>
       Date:   Wed, 26 Dec 2018 09:58:28 -0500
       
       Use argparse in damhs.py.
       
       Diffstat:
         M cmd/dam-client/main.go              |       5 +++--
         M python/damhs.py                     |      19 +++++++++++++++----
       
       2 files changed, 18 insertions(+), 6 deletions(-)
       ---
   DIR diff --git a/cmd/dam-client/main.go b/cmd/dam-client/main.go
       t@@ -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 {
       t@@ -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)
   DIR diff --git a/python/damhs.py b/python/damhs.py
       t@@ -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
        
        
       t@@ -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()
        
       t@@ -63,7 +74,7 @@ def main():
            stdout.write('OK\n')
            stdout.flush()
            while True:
       -            sleep(60)
       +        sleep(60)
        
        
        if __name__ == '__main__':