Run nmap ping scan to discover active hosts
(network=None)
| 8611 | if raw_ip.lower() in ('unknown', ''): |
| 8612 | raw_ip = '' |
| 8613 | |
| 8614 | # Validate whatever was supplied; require at least one usable field. |
| 8615 | if raw_mac and not _MAC_RE.match(raw_mac): |
| 8616 | return jsonify({'error': f'Invalid MAC: {raw_mac}'}), 400 |
| 8617 | if raw_ip: |
| 8618 | try: |
| 8619 | raw_ip = str(_ip.ip_address(raw_ip)) |
| 8620 | except ValueError: |
| 8621 | return jsonify({'error': f'Invalid IP: {raw_ip}'}), 400 |
| 8622 | if not raw_mac and not raw_ip: |
| 8623 | return jsonify({'error': 'Provide a mac and/or ip to ignore'}), 400 |
| 8624 | |
| 8625 | changed = False |
| 8626 | if request.method == 'POST': |
| 8627 | if raw_mac and raw_mac not in macs: |
| 8628 | macs.append(raw_mac) |
| 8629 | changed = True |
| 8630 | if raw_ip and raw_ip not in ips: |
| 8631 | ips.append(raw_ip) |
| 8632 | changed = True |
| 8633 | else: # DELETE |
| 8634 | if raw_mac and raw_mac in macs: |
| 8635 | macs = [m for m in macs if m != raw_mac] |
| 8636 | changed = True |
| 8637 | if raw_ip and raw_ip in ips: |
| 8638 | ips = [i for i in ips if i != raw_ip] |
| 8639 | changed = True |
| 8640 |
no test coverage detected