cmd

package
v0.0.0-...-f91a516 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package cmd contains command implementations

Index

Constants

View Source
const (
	// API is the URL of ifconfig network info API
	API string = "https://ifconfig.is/json/"
)

Variables

View Source
var (
	// Name is the name of the program
	Name = "tcping"
	// Version is the version of the program
	Version = "- not set -"
	// Commit is the commit of the build
	Commit = "snapshot"
	// Date is the date of the build
	Date = ""
)
View Source
var CommandLine = flag.NewFlagSet(os.Args[0], flag.ExitOnError)

CommandLine is the flag command line

View Source
var HTTPingDst string

HTTPingDst is the HTTP Ping URL

View Source
var Logger = logrus.New()

Logger is the global logger

View Source
var MtrDst string

MtrDst is the MTR Trace Address

View Source
var PingDst string

PingDst is the ICMP Ping Address

View Source
var Query string

Query is the Query IP Address

View Source
var TCPingDst string

TCPingDst is the TCP Ping Address

View Source
var Usage = func() {
	_, _ = fmt.Fprintf(CommandLine.Output(), "Usage:\n")
	flag.PrintDefaults()
}

Usage prints the usage

View Source
var VersionFlg bool

VersionFlg is the version flag

Functions

func GetVersion

func GetVersion(print bool) (txt string)

GetVersion extract compiled version info

func HasFlag

func HasFlag() bool

HasFlag checks if any flag is passed

func InitFlag

func InitFlag()

InitFlag initializes the flags

func InitLog

func InitLog()

InitLog initializes the logger

func IsFlagPassed

func IsFlagPassed(name string) bool

IsFlagPassed checks if a specific flag is passed

func IsPrivateIPv4

func IsPrivateIPv4(s string) bool

IsPrivateIPv4 checks if the input string is a private IPv4 address

func IsPrivateIPv6

func IsPrivateIPv6(s string) bool

IsPrivateIPv6 checks if the input string is a private IPv6 address

func IsValidIP

func IsValidIP(s string) bool

IsValidIP checks if the input string is a valid IP address

func LogHttping

func LogHttping(stats httping.Stats, err error, address string)

LogHttping logs the httping results

func LogMtr

func LogMtr(hops []mtr.Hops)

LogMtr logs the mtr results

func LogPing

func LogPing(dst *net.IPAddr, dur time.Duration, err error)

LogPing logs the ping results

func LogQuery

func LogQuery(info IPInfo)

LogQuery logs the query results

func LogTcping

func LogTcping(code int, address string)

LogTcping logs the tcping results

func LookupIP

func LookupIP(s string) string

LookupIP looks up the IP address of a hostname

func ParseInput

func ParseInput(s string) string

ParseInput parses the input string

Types

type IPInfo

type IPInfo struct {
	Continent string  `json:"Continent"`
	Country   string  `json:"Country"`
	City      string  `json:"City"`
	Latitude  float64 `json:"Latitude"`
	Longitude float64 `json:"Longitude"`
	TimeZone  string  `json:"TimeZone"`
	ASN       uint    `json:"ASN"`
	ORG       string  `json:"Organization"`
}

IPInfo is the struct of IP information

func QueryInfo

func QueryInfo(address string) IPInfo

QueryInfo queries the IP information

Jump to

Keyboard shortcuts

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