#!/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_lan_speed_test


class LanSpeedTestSkill(BaseSkill):
    """内网测速Skill"""
    
    def get_metadata(self):
        return {
            "name": "lan_speed_test",
            "display_name": "内网测速",
            "description": "测试局域网连接速度和延迟",
            "category": "advanced",
            "keywords": ["内网", "局域网", "测速", "lan", "speed"],
            "parameters": [
                {
                    "name": "target_ip",
                    "type": "string",
                    "required": True,
                    "description": "目标IP地址"
                },
                {
                    "name": "duration",
                    "type": "int",
                    "required": False,
                    "default": 10,
                    "description": "测试时长(秒)"
                }
            ],
            "examples": [
                "局域网测速192.168.1.1",
                "内网测速192.168.1.100",
                "测试内网速度192.168.1.1"
            ],
            "requires_admin": False,
            "requires_ui": False
        }
    
    def execute(self, target_ip: str, duration: int = 10) -> str:
        """执行内网测速"""
        return run_lan_speed_test(target_ip, duration)
