#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""IP冲突检测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_ip_conflict_detection


class IpConflictSkill(BaseSkill):
    """IP冲突检测Skill"""
    
    def get_metadata(self):
        return {
            "name": "ip_conflict",
            "display_name": "IP冲突检测",
            "description": "检测网络中的IP地址冲突",
            "category": "advanced",
            "keywords": ["ip", "冲突", "检测", "conflict", "重复"],
            "parameters": [
                {
                    "name": "ip_range",
                    "type": "string",
                    "required": True,
                    "description": "IP范围,格式:192.168.1.1-254"
                },
                {
                    "name": "interface",
                    "type": "string",
                    "required": False,
                    "default": "auto",
                    "description": "网卡名称或auto(自动检测)"
                }
            ],
            "examples": [
                "检测IP冲突192.168.1.1-254",
                "查找IP冲突",
                "IP冲突检测192.168.1.1-100"
            ],
            "requires_admin": True,
            "requires_ui": False
        }
    
    def execute(self, ip_range: str, interface: str = "auto") -> str:
        """执行IP冲突检测"""
        return run_ip_conflict_detection(ip_range, interface)
