feat(scan): 增强MAC厂商识别和主机名自动发现
- MAC厂商: 替换硬编码OUI_MAP为mac_vendor_lookup库(IEEE OUI官方数据库) - 主机名发现新增NetBIOS广播(nmblookup),支持Windows/SMB设备 - 综合扫描支持enable_netbios参数 - 新增NetBIOS主机名发现API端点 - 扫描时自动补全缺失厂商(有MAC无vendor时自动识别)
This commit is contained in:
@@ -24,6 +24,7 @@ def comprehensive_scan(
|
||||
enable_ping: bool = True,
|
||||
enable_arp: bool = True,
|
||||
enable_dns: bool = True,
|
||||
enable_netbios: bool = True,
|
||||
timeout: int = 2,
|
||||
db: Session = Depends(get_db)
|
||||
):
|
||||
@@ -32,7 +33,8 @@ def comprehensive_scan(
|
||||
- Ping 扫描检测在线状态
|
||||
- ARP 扫描获取MAC地址
|
||||
- 反向DNS解析获取主机名
|
||||
- MAC厂商识别
|
||||
- NetBIOS 广播获取主机名(Windows/SMB 设备)
|
||||
- MAC 厂商识别(IEEE OUI 数据库)
|
||||
"""
|
||||
network = NetworkService.get_by_id(db, network_id)
|
||||
if not network:
|
||||
@@ -51,6 +53,7 @@ def comprehensive_scan(
|
||||
enable_ping=enable_ping,
|
||||
enable_arp=enable_arp,
|
||||
enable_dns=enable_dns,
|
||||
enable_netbios=enable_netbios,
|
||||
timeout=timeout
|
||||
)
|
||||
|
||||
@@ -90,6 +93,7 @@ def comprehensive_scan_ip(
|
||||
enable_ping: bool = True,
|
||||
enable_arp: bool = True,
|
||||
enable_dns: bool = True,
|
||||
enable_netbios: bool = True,
|
||||
timeout: int = 2,
|
||||
db: Session = Depends(get_db)
|
||||
):
|
||||
@@ -101,6 +105,7 @@ def comprehensive_scan_ip(
|
||||
enable_ping=enable_ping,
|
||||
enable_arp=enable_arp,
|
||||
enable_dns=enable_dns,
|
||||
enable_netbios=enable_netbios,
|
||||
timeout=timeout
|
||||
)
|
||||
|
||||
@@ -140,6 +145,17 @@ def reverse_dns(ip_address: str, timeout: int = 2):
|
||||
"hostname": hostname or "Unknown"
|
||||
}
|
||||
|
||||
@router.post("/netbios/lookup/{ip_address}", summary="NetBIOS 主机名发现")
|
||||
def netbios_lookup(ip_address: str, timeout: int = 3):
|
||||
"""
|
||||
通过 NetBIOS 广播协议获取主机名(Windows / SMB 设备)
|
||||
"""
|
||||
hostname = EnhancedScanService.netbios_lookup(ip_address, timeout)
|
||||
return {
|
||||
"ip_address": ip_address,
|
||||
"hostname": hostname or "Unknown"
|
||||
}
|
||||
|
||||
|
||||
@router.get("/online/ips", summary="获取所有在线IP列表")
|
||||
def get_online_ips(
|
||||
|
||||
Reference in New Issue
Block a user