Enable or disable continuous threat monitoring.
()
| 11862 | try: |
| 11863 | net = _ip.ip_network(raw, strict=False) |
| 11864 | normalised = str(net) |
| 11865 | except ValueError: |
| 11866 | return jsonify({'error': f'Invalid CIDR: {raw}'}), 400 |
| 11867 | |
| 11868 | if request.method == 'POST': |
| 11869 | if normalised == primary: |
| 11870 | return jsonify({'error': 'This is already your primary subnet — no need to add it'}), 400 |
| 11871 | if normalised not in subnets: |
| 11872 | subnets.append(normalised) |
| 11873 | shared_data.config['scan_subnets'] = subnets |
| 11874 | shared_data.scan_subnets = subnets |
| 11875 | shared_data.save_config() |
| 11876 | return jsonify({'subnets': subnets, 'primary': primary}) |
| 11877 | |
| 11878 | if request.method == 'DELETE': |
| 11879 | subnets = [s for s in subnets if s != normalised] |
| 11880 | shared_data.config['scan_subnets'] = subnets |
| 11881 | shared_data.scan_subnets = subnets |
| 11882 | shared_data.save_config() |
| 11883 | return jsonify({'subnets': subnets, 'primary': primary}) |
| 11884 | |
| 11885 | except Exception as e: |
| 11886 | logger.error(f"Error managing scan subnets: {e}") |
| 11887 | return jsonify({'error': str(e)}), 500 |
| 11888 | |
| 11889 | |
| 11890 | _MAC_RE = re.compile(r'^([0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}$') |
| 11891 | |
| 11892 | |
| 11893 | @app.route('/api/config/scan-blacklist', methods=['GET', 'POST', 'DELETE']) |
| 11894 | def manage_scan_blacklist(): |