Beispiel #1
0
  def __init__(self, config):
    self._config = config

    if 'rate_limit' in self._config:
      if 'rate_limit_burst' not in self._config:
        self._config['rate_limit_burst'] = 10
      self.__RateLimit = rateLimit(self._config['rate_limit'], self._config['rate_limit_burst'])
    else:
      self.__RateLimit = None

    self._nodeinfo = Nodeinfo(self._config)
    self._neighbours = Neighbours(self._config)
    self._statistics = Statistics(self._config)

    self._sock = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
config = {
    'bridge': 'br-client',
    'batman': 'bat0',
    'port': 1001,
    'addr': 'ff05::2:1001',
    'caching': 5,
    'rate_limit': 30,
    'rate_limit_burst': 10
}

try:
    with open(options['cfg'], 'r') as fh:
        config = lib.helper.merge(config, json.load(fh))
except IOError:
    print('no ' + options['cfg'] + ', use defaults')

if options['test']:
    from lib.nodeinfo import Nodeinfo
    from lib.statistics import Statistics
    from lib.neighbours import Neighbours
    print(json.dumps(Nodeinfo(config).getStruct(), sort_keys=True, indent=4))
    print(json.dumps(Statistics(config).getStruct(), sort_keys=True, indent=4))
    print(json.dumps(Neighbours(config).getStruct(), sort_keys=True, indent=4))
    sys.exit(1)

config['verbose'] = options['verbose']
config['dry_run'] = options['dry_run']

extResponddClient = ResponddClient(config)
extResponddClient.start()