traceroute

package module
v0.0.0-...-abf9d5e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 2, 2016 License: Apache-2.0 Imports: 7 Imported by: 1

README

traceroute

golang traceroute

####需要ROOT权限运行

package main

import (
	"fmt"
	"github.com/lixiangzhong/traceroute"
)

func main() {
	t := traceroute.New("qq.com")
	//t.MaxTTL=30
	//t.Timeout=3 * time.Second
	//t.LocalAddr="0.0.0.0"
	result, err := t.Do()
	if err != nil {
		fmt.Println(err)
		return
	}
	for _, v := range result {
		fmt.Println(v)
	}
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRemoteAddr = errors.New("RemoteAddr error")
)

Functions

This section is empty.

Types

type Result

type Result struct {
	ID  int
	IP  string
	RTT time.Duration
}

func (Result) String

func (r Result) String() string

type TraceRoute

type TraceRoute struct {
	LocalAddr  string //default 0.0.0.0
	RemoteAddr string
	MaxTTL     int           //default 30
	Timeout    time.Duration //default 3 sec
}

func New

func New(remote string) *TraceRoute

func (*TraceRoute) Do

func (t *TraceRoute) Do() ([]Result, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL