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

Function get_network_intelligence

webapp_modern.py:12959–12993  ·  view source on GitHub ↗

Get network intelligence summary and findings

()

Source from the content-addressed store, hash-verified

12957 if port < 1024 or port > 65535:
12958 return jsonify({'success': False, 'error': 'Web port must be between 1024 and 65535'}), 400
12959 if 'main.name' in validated:
12960 name = validated['main.name']
12961 if not name or len(name) > 32 or not re.match(r'^[a-zA-Z0-9_-]+$', name):
12962 return jsonify({'success': False, 'error': 'Name must be 1-32 alphanumeric characters (plus - and _)'}), 400
12963 if 'personality.min_rssi' in validated:
12964 rssi = validated['personality.min_rssi']
12965 if rssi < -200 or rssi > 0:
12966 return jsonify({'success': False, 'error': 'Min RSSI must be between -200 and 0'}), 400
12967
12968 # Convert comma-separated strings to TOML lists
12969 if 'main.whitelist' in validated:
12970 raw = validated['main.whitelist']
12971 validated['main.whitelist'] = [s.strip() for s in raw.split(',') if s.strip()] if raw.strip() else []
12972 if 'personality.channels' in validated:
12973 raw = validated['personality.channels']
12974 if raw.strip():
12975 try:
12976 validated['personality.channels'] = [int(c.strip()) for c in raw.split(',') if c.strip()]
12977 except ValueError:
12978 return jsonify({'success': False, 'error': 'Channels must be comma-separated numbers (e.g. 1, 6, 11)'}), 400
12979 else:
12980 validated['personality.channels'] = []
12981
12982 try:
12983 import tomlkit
12984 with open(PWN_CONFIG_FILE, 'r', encoding='utf-8') as f:
12985 doc = tomlkit.parse(f.read())
12986
12987 for dotted_key, value in validated.items():
12988 _set_toml_value(doc, dotted_key, value)
12989
12990 with open(PWN_CONFIG_FILE, 'w', encoding='utf-8') as f:
12991 f.write(tomlkit.dumps(doc))
12992 except ImportError:
12993 # Fallback: use the shell helper from install script
12994 script_path = os.path.join(shared_data.currentdir, 'scripts', 'install_pwnagotchi.sh')
12995 for dotted_key, value in validated.items():
12996 _set_toml_value_fallback(dotted_key, value)

Callers

nothing calls this directly

Calls 6

get_network_summaryMethod · 0.80
errorMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected