Add network scan page (arp-scan)
New /scan page lists all active devices on the subnet (ARP scan): - 静态绑定: matches a host declaration - 动态分配: matches a dhcpd.leases entry - 未知 / 外部: nothing matches (manually configured or from other DHCP server) Click '转为静态绑定' to convert a discovered device to a static host binding. Also includes: - arp-scan wrapper in dhcp_ops.py (get_local_network, arp_scan, classify_devices) - /scan route with optional auto-refresh every 30s - README updated with arp-scan install step + new feature bullet
This commit is contained in:
@@ -459,6 +459,34 @@ def lease_list():
|
||||
return render_template("leases.html", leases=leases, q=q)
|
||||
|
||||
|
||||
# ---------- 网络扫描 (arp-scan) ----------
|
||||
|
||||
@app.route("/scan", methods=["GET", "POST"])
|
||||
@login_required
|
||||
def scan():
|
||||
"""网络扫描 - 用 arp-scan 列出网段内所有活跃设备"""
|
||||
ifaces = dhcp_ops.get_interfaces()
|
||||
iface = request.values.get("iface") or (ifaces[0] if ifaces else "enp0s31f6-ovs")
|
||||
network = request.values.get("network") or dhcp_ops.get_local_network(iface)
|
||||
|
||||
devices = []
|
||||
scan_msg = ""
|
||||
did_scan = False
|
||||
|
||||
if request.method == "POST" or request.args.get("auto") == "1":
|
||||
did_scan = True
|
||||
ok, scan_msg, devices = dhcp_ops.arp_scan(iface, network)
|
||||
if ok:
|
||||
# 交叉 dhcpd.leases 和 host 静态绑定
|
||||
hosts = get_hosts()
|
||||
leases = dhcp_ops.parse_leases()
|
||||
devices = dhcp_ops.classify_devices(devices, hosts, leases)
|
||||
|
||||
return render_template("scan.html",
|
||||
ifaces=ifaces, iface=iface, network=network,
|
||||
devices=devices, scan_msg=scan_msg, did_scan=did_scan)
|
||||
|
||||
|
||||
# ---------- config (interfaces + 原始 conf) ----------
|
||||
|
||||
@app.route("/config", methods=["GET", "POST"])
|
||||
|
||||
Reference in New Issue
Block a user