MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / start

Method start

traffic_analyzer.py:514–550  ·  view source on GitHub ↗

Start traffic capture and analysis

(self)

Source from the content-addressed store, hash-verified

512 logger.debug(f"Socket IP detection error: {e}")
513
514 # Method 3: Try to get IPs from shared_data if available (Flask config)
515 if self.shared_data:
516 try:
517 # Check if there's a configured host IP
518 host = self.shared_data.get('host', '')
519 if host and host not in ['0.0.0.0', '']:
520 local_ips.add(host)
521 logger.debug(f"Detected local IP (config): {host}")
522 except Exception:
523 pass
524
525 # Add common local network ranges that might be Ragnar
526 # These are private IP patterns that are likely to be the host
527 try:
528 for ip in list(local_ips):
529 if ip.startswith('192.168.') or ip.startswith('10.') or ip.startswith('172.'):
530 # This is a private IP, likely the actual machine IP
531 logger.info(f"Ragnar local IP detected: {ip}")
532 except Exception:
533 pass
534
535 logger.info(f"Local IPs (excluded from alerts): {local_ips}")
536 return local_ips
537
538 def _detect_gateway_ips(self) -> set:
539 gateways: set = set()
540 try:
541 result = subprocess.run(
542 ['ip', 'route', 'show', 'default'],
543 capture_output=True, text=True, timeout=5
544 )
545 if result.returncode == 0:
546 for match in re.finditer(
547 r'default\s+via\s+(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})',
548 result.stdout
549 ):
550 gateways.add(match.group(1))
551 except Exception as e:
552 logger.debug(f"Gateway detection error: {e}")
553 if gateways:

Callers 2

_capture_loopMethod · 0.45
_start_sidecarsMethod · 0.45

Calls 6

is_availableMethod · 0.95
_start_sidecarsMethod · 0.95
errorMethod · 0.80
warningMethod · 0.80
debugMethod · 0.80
infoMethod · 0.80

Tested by

no test coverage detected