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


class TracertSkill(BaseSkill):
    """路由追踪Skill"""
    
    def get_metadata(self):
        return {
            "name": "tracert",
            "display_name": "路由追踪",
            "description": "追踪数据包到目标主机的路径",
            "category": "network",
            "keywords": ["tracert", "traceroute", "路由", "追踪", "跳数"],
            "parameters": [
                {
                    "name": "host",
                    "type": "string",
                    "required": True,
                    "description": "目标主机IP或域名"
                },
                {
                    "name": "max_hops",
                    "type": "int",
                    "required": False,
                    "default": 30,
                    "description": "最大跳数"
                }
            ],
            "examples": [
                "tracert 8.8.8.8",
                "追踪到百度的路由",
                "路由追踪baidu.com"
            ],
            "requires_admin": False,
            "requires_ui": False
        }
    
    def execute(self, host: str, max_hops: int = 30) -> str:
        """执行路由追踪"""
        return run_tracert(host, max_hops)
