#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""主机发现Skill"""

import sys
import os
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(__file__))))

from skills.base_skill import BaseSkill
from network_tools import run_host_discovery


class HostDiscoverySkill(BaseSkill):
    """主机发现Skill"""
    
    def get_metadata(self):
        return {
            "name": "host_discovery",
            "display_name": "主机发现",
            "description": "扫描网络中的活动主机",
            "category": "network",
            "keywords": ["主机", "发现", "扫描", "局域网", "设备"],
            "parameters": [
                {
                    "name": "network",
                    "type": "string",
                    "required": True,
                    "description": "网段,格式:192.168.1.0/24"
                }
            ],
            "examples": [
                "扫描192.168.1.0/24网段",
                "发现局域网设备",
                "扫描192.168.0.0/24有哪些设备"
            ],
            "requires_admin": False,
            "requires_ui": False
        }
    
    def execute(self, network: str) -> str:
        """执行主机发现"""
        return run_host_discovery(network)
