ext-respondd.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/usr/bin/env python3
  2. import json
  3. import argparse
  4. import sys
  5. from lib.respondd_client import ResponddClient
  6. import lib.helper
  7. parser = argparse.ArgumentParser()
  8. parser.add_argument('-c', '--cfg', default='config.json', metavar='<file>', help='Config File',required=False,)
  9. parser.add_argument('-d', '--test', action='store_true', help='Test Output', required=False)
  10. parser.add_argument('-v', '--verbose', action='store_true', help='Verbose Output', required=False)
  11. parser.add_argument('-t', '--dry-run', action='store_true', help='Dry Run', required=False)
  12. args = parser.parse_args()
  13. options = vars(args)
  14. config = {
  15. 'bridge': 'br-client',
  16. 'batman': 'bat0',
  17. 'port': 1001,
  18. 'addr': 'ff05::2:1001',
  19. 'caching': 5,
  20. 'rate_limit': 30,
  21. 'rate_limit_burst': 10
  22. }
  23. try:
  24. with open(options['cfg'], 'r') as fh:
  25. config = lib.helper.merge(config, json.load(fh))
  26. except IOError:
  27. print('no ' + options['cfg'] + ', use defaults')
  28. if options['test']:
  29. from lib.nodeinfo import Nodeinfo
  30. from lib.statistics import Statistics
  31. from lib.neighbours import Neighbours
  32. print(json.dumps(Nodeinfo(config).getStruct(), sort_keys=True, indent=4))
  33. print(json.dumps(Statistics(config).getStruct(), sort_keys=True, indent=4))
  34. print(json.dumps(Neighbours(config).getStruct(), sort_keys=True, indent=4))
  35. sys.exit(1)
  36. config['verbose'] = options['verbose']
  37. config['dry_run'] = options['dry_run']
  38. extResponddClient = ResponddClient(config)
  39. extResponddClient.start()