@@ 428-461 (lines=34) @@ | ||
425 | return False |
|
426 | ||
427 | ||
428 | @Command.register('text', 'announce route-refresh') |
|
429 | def announce_refresh(self, reactor, service, command): |
|
430 | def callback(self, command, peers): |
|
431 | refreshes = self.api_refresh(command) |
|
432 | if not refreshes: |
|
433 | self.log_failure("Command could not parse route-refresh command : %s" % command) |
|
434 | reactor.processes.answer_error(service) |
|
435 | yield True |
|
436 | return |
|
437 | ||
438 | reactor.configuration.inject_refresh(peers, refreshes) |
|
439 | for refresh in refreshes: |
|
440 | self.log_message( |
|
441 | "Sent to %s : %s" |
|
442 | % (', '.join(peers if peers else []) if peers is not None else 'all peers', refresh.extensive()) |
|
443 | ) |
|
444 | ||
445 | yield False |
|
446 | reactor.processes.answer_done(service) |
|
447 | ||
448 | try: |
|
449 | descriptions, command = extract_neighbors(command) |
|
450 | peers = match_neighbors(reactor.established_peers(), descriptions) |
|
451 | if not peers: |
|
452 | self.log_failure('no neighbor matching the command : %s' % command) |
|
453 | reactor.processes.answer_error(service) |
|
454 | return False |
|
455 | reactor.asynchronous.schedule(service, command, callback(self, command, peers)) |
|
456 | return True |
|
457 | except ValueError: |
|
458 | self.log_failure('issue parsing the command') |
|
459 | reactor.processes.answer_error(service) |
|
460 | return False |
|
461 | except IndexError: |
|
462 | self.log_failure('issue parsing the command') |
|
463 | reactor.processes.answer_error(service) |
|
464 | return False |
|
@@ 390-422 (lines=33) @@ | ||
387 | return True |
|
388 | ||
389 | ||
390 | @Command.register('text', 'announce eor') |
|
391 | def announce_eor(self, reactor, service, command): |
|
392 | def callback(self, command, peers): |
|
393 | family = self.api_eor(command) |
|
394 | if not family: |
|
395 | self.log_failure("Command could not parse eor : %s" % command) |
|
396 | reactor.processes.answer_error(service) |
|
397 | yield True |
|
398 | return |
|
399 | ||
400 | reactor.configuration.inject_eor(peers, family) |
|
401 | self.log_message( |
|
402 | "Sent to %s : %s" |
|
403 | % (', '.join(peers if peers else []) if peers is not None else 'all peers', family.extensive()) |
|
404 | ) |
|
405 | yield False |
|
406 | ||
407 | reactor.processes.answer_done(service) |
|
408 | ||
409 | try: |
|
410 | descriptions, command = extract_neighbors(command) |
|
411 | peers = match_neighbors(reactor.established_peers(), descriptions) |
|
412 | if not peers: |
|
413 | self.log_failure('no neighbor matching the command : %s' % command) |
|
414 | reactor.processes.answer_error(service) |
|
415 | return False |
|
416 | reactor.asynchronous.schedule(service, command, callback(self, command, peers)) |
|
417 | return True |
|
418 | except ValueError: |
|
419 | self.log_failure('issue parsing the command') |
|
420 | reactor.processes.answer_error(service) |
|
421 | return False |
|
422 | except IndexError: |
|
423 | self.log_failure('issue parsing the command') |
|
424 | reactor.processes.answer_error(service) |
|
425 | return False |