ext-respondd.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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('-d', '--test', action='store_true', help='Test Output', required=False)
  9. parser.add_argument('-v', '--verbose', action='store_true', help='Verbose Output', required=False)
  10. parser.add_argument('-t', '--dry-run', action='store_true', help='Dry Run', required=False)
  11. args = parser.parse_args()
  12. options = vars(args)
  13. config = {
  14. 'bridge': 'br-client',
  15. 'batman': 'bat0',
  16. 'port': 1001,
  17. 'addr': 'ff02::2:1001',
  18. 'caching': 5,
  19. 'rate_limit': 30,
  20. 'rate_limit_burst': 10
  21. }
  22. try:
  23. with open("config.json", 'r') as fh:
  24. config = lib.helper.merge(config, json.load(fh))
  25. except IOError:
  26. print('no config.json, use defaults')
  27. if options["test"]:
  28. from lib.nodeinfo import Nodeinfo
  29. from lib.statistics import Statistics
  30. from lib.neighbours import Neighbours
  31. print(json.dumps(Nodeinfo(config).getStruct(), sort_keys=True, indent=4))
  32. print(json.dumps(Statistics(config).getStruct(), sort_keys=True, indent=4))
  33. print(json.dumps(Neighbours(config).getStruct(), sort_keys=True, indent=4))
  34. sys.exit(1)
  35. config['verbose'] = options['verbose']
  36. config['dry_run'] = options['dry_run']
  37. extResponddClient = ResponddClient(config)
  38. extResponddClient.start()