Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update asn.go #9

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions asn.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@ type Result struct {
var (
rIp = []string{"219.141.136.12", "202.106.50.1", "221.179.155.161", "202.96.209.133", "210.22.97.1", "211.136.112.200", "58.60.188.222", "210.21.196.6", "120.196.165.24", "61.139.2.69", "119.6.6.6", "211.137.96.205"}
rName = []string{"北京电信", "北京联通", "北京移动", "上海电信", "上海联通", "上海移动", "广州电信", "广州联通", "广州移动", "成都电信", "成都联通", "成都移动"}
ca = []color.Attribute{color.FgHiYellow, color.FgHiMagenta, color.FgHiBlue, color.FgHiGreen, color.FgHiCyan, color.FgHiRed}
ca = []color.Attribute{color.FgHiYellow, color.FgHiMagenta, color.FgHiBlue, color.FgHiGreen, color.FgHiCyan, color.FgHiRed, color.FgHiWhite}
m = map[string]string{"AS4134": "电信163 [普通线路]", "AS4809": "电信CN2 [优质线路]", "AS4837": "联通4837[普通线路]", "AS9929": "联通9929[优质线路]", "AS9808": "移动CMI [普通线路]", "AS58453": "移动CMI [普通线路]"}
)

func trace(ch chan Result, i int) {

hops, err := Trace(net.ParseIP(rIp[i]))
if err != nil {
s := fmt.Sprintf("%v %-15s %v", rName[i], rIp[i], err)
Expand All @@ -35,12 +34,16 @@ func trace(ch chan Result, i int) {
continue
} else {
as := m[asn]
cai := i % 6
c := color.New(ca[cai]).Add(color.Bold).SprintFunc()
s := fmt.Sprintf("%v %-15s %-23s", rName[i], rIp[i], c(as))
var c *color.Color
if strings.Contains(as, "[优质线路]") {
c = color.New(color.FgHiGreen).Add(color.Bold)
} else {
c = color.New(color.FgHiYellow).Add(color.Bold)
}
s := fmt.Sprintf("%v %-15s %-23s", rName[i], rIp[i], c.Sprint(as))
ch <- Result{i, s}
return
}
}
}
}

Expand Down