mirror of
https://github.com/oneclickvirt/backtrace.git
synced 2025-04-22 04:02:07 +08:00
feat: 结构化IPV4和IPV6的代码
This commit is contained in:
parent
a832d354da
commit
aad93e51f8
@ -7,8 +7,8 @@ import (
|
|||||||
"github.com/oneclickvirt/backtrace/model"
|
"github.com/oneclickvirt/backtrace/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
func BackTrace(test bool) {
|
func BackTrace(enableIpv6 bool) {
|
||||||
if test {
|
if enableIpv6 {
|
||||||
ipv4Count := len(model.Ipv4s)
|
ipv4Count := len(model.Ipv4s)
|
||||||
ipv6Count := len(model.Ipv6s)
|
ipv6Count := len(model.Ipv6s)
|
||||||
totalCount := ipv4Count + ipv6Count
|
totalCount := ipv4Count + ipv6Count
|
||||||
|
@ -155,7 +155,6 @@ func traceIPv6(ch chan Result, i int, offset int) {
|
|||||||
}
|
}
|
||||||
if tempText == (fmt.Sprintf("%v ", model.Ipv6Names[i]) + fmt.Sprintf("%-40s ", model.Ipv6s[i])) {
|
if tempText == (fmt.Sprintf("%v ", model.Ipv6Names[i]) + fmt.Sprintf("%-40s ", model.Ipv6s[i])) {
|
||||||
tempText += fmt.Sprintf("%v", Red("检测不到已知线路的ASN"))
|
tempText += fmt.Sprintf("%v", Red("检测不到已知线路的ASN"))
|
||||||
|
|
||||||
if model.EnableLoger {
|
if model.EnableLoger {
|
||||||
Logger.Warn(fmt.Sprintf("%s (%s) 检测不到已知线路的ASN", model.Ipv6Names[i], model.Ipv6s[i]))
|
Logger.Warn(fmt.Sprintf("%s (%s) 检测不到已知线路的ASN", model.Ipv6Names[i], model.Ipv6s[i]))
|
||||||
}
|
}
|
||||||
|
@ -26,13 +26,13 @@ func main() {
|
|||||||
http.Get("https://hits.spiritlhl.net/backtrace.svg?action=hit&title=Hits&title_bg=%23555555&count_bg=%230eecf8&edge_flat=false")
|
http.Get("https://hits.spiritlhl.net/backtrace.svg?action=hit&title=Hits&title_bg=%23555555&count_bg=%230eecf8&edge_flat=false")
|
||||||
}()
|
}()
|
||||||
fmt.Println(Green("项目地址:"), Yellow("https://github.com/oneclickvirt/backtrace"))
|
fmt.Println(Green("项目地址:"), Yellow("https://github.com/oneclickvirt/backtrace"))
|
||||||
var showVersion, showIpInfo, help, test bool
|
var showVersion, showIpInfo, help, ipv6 bool
|
||||||
backtraceFlag := flag.NewFlagSet("backtrace", flag.ContinueOnError)
|
backtraceFlag := flag.NewFlagSet("backtrace", flag.ContinueOnError)
|
||||||
backtraceFlag.BoolVar(&help, "h", false, "Show help information")
|
backtraceFlag.BoolVar(&help, "h", false, "Show help information")
|
||||||
backtraceFlag.BoolVar(&showVersion, "v", false, "Show version")
|
backtraceFlag.BoolVar(&showVersion, "v", false, "Show version")
|
||||||
backtraceFlag.BoolVar(&showIpInfo, "s", true, "Disabe show ip info")
|
backtraceFlag.BoolVar(&showIpInfo, "s", true, "Disabe show ip info")
|
||||||
backtraceFlag.BoolVar(&model.EnableLoger, "log", false, "Enable logging")
|
backtraceFlag.BoolVar(&model.EnableLoger, "log", false, "Enable logging")
|
||||||
backtraceFlag.BoolVar(&test, "test", false, "Test Mode")
|
backtraceFlag.BoolVar(&ipv6, "ipv6", false, "Enable ipv6 testing")
|
||||||
backtraceFlag.Parse(os.Args[1:])
|
backtraceFlag.Parse(os.Args[1:])
|
||||||
if help {
|
if help {
|
||||||
fmt.Printf("Usage: %s [options]\n", os.Args[0])
|
fmt.Printf("Usage: %s [options]\n", os.Args[0])
|
||||||
@ -58,7 +58,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
backtrace.BackTrace(test)
|
backtrace.BackTrace(ipv6)
|
||||||
fmt.Println(Yellow("准确线路自行查看详细路由,本测试结果仅作参考"))
|
fmt.Println(Yellow("准确线路自行查看详细路由,本测试结果仅作参考"))
|
||||||
fmt.Println(Yellow("同一目标地址多个线路时,可能检测已越过汇聚层,除了第一个线路外,后续信息可能无效"))
|
fmt.Println(Yellow("同一目标地址多个线路时,可能检测已越过汇聚层,除了第一个线路外,后续信息可能无效"))
|
||||||
if runtime.GOOS == "windows" || runtime.GOOS == "darwin" {
|
if runtime.GOOS == "windows" || runtime.GOOS == "darwin" {
|
||||||
|
Loading…
Reference in New Issue
Block a user