feat/optimize: print SubscriptionTag in AliveDialerSet::printLatencies() (#319)

This commit is contained in:
Luo Chen 2023-09-03 21:17:58 +08:00 committed by GitHub
parent 371e0c19d1
commit bfd4d99744
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 11 deletions

View File

@ -135,7 +135,7 @@ func (a *AliveDialerSet) printLatencies() {
return alive[i].l+alive[i].o < alive[j].l+alive[j].o
})
for i, dl := range alive {
builder.WriteString(fmt.Sprintf("%4d. %v: %v\n", i+1, dl.d.property.Name, latencyString(dl.l, dl.o)))
builder.WriteString(fmt.Sprintf("%4d. [%v] %v: %v\n", i+1, dl.d.property.SubscriptionTag, dl.d.property.Name, latencyString(dl.l, dl.o)))
}
a.log.Infoln(strings.TrimSuffix(builder.String(), "\n"))
}

View File

@ -48,10 +48,11 @@ type InstanceOption struct {
}
type Property struct {
Name string
Address string
Protocol string
Link string
Name string
Address string
Protocol string
Link string
SubscriptionTag string
}
type AliveDialerSetSet map[*AliveDialerSet]int

View File

@ -23,16 +23,17 @@ func FromLinkRegister(name string, creator FromLinkCreator) {
fromLinkCreators[name] = creator
}
func NewFromLink(gOption *GlobalOption, iOption InstanceOption, link string) (*Dialer, error) {
func NewFromLink(gOption *GlobalOption, iOption InstanceOption, link string, subscriptionTag string) (*Dialer, error) {
/// Get overwritten name.
overwrittenName, linklike := common.GetTagFromLinkLikePlaintext(link)
links := strings.Split(linklike, "->")
d := direct.SymmetricDirect
p := &Property{
Name: "",
Address: "",
Protocol: "",
Link: link,
Name: "",
Address: "",
Protocol: "",
Link: link,
SubscriptionTag: subscriptionTag,
}
for i := len(links) - 1; i >= 0; i-- {
link := strings.TrimSpace(links[i])

View File

@ -39,7 +39,7 @@ func NewDialerSetFromLinks(option *dialer.GlobalOption, tagToNodeList map[string
}
for subscriptionTag, nodes := range tagToNodeList {
for _, node := range nodes {
d, err := dialer.NewFromLink(option, dialer.InstanceOption{CheckEnabled: false}, node)
d, err := dialer.NewFromLink(option, dialer.InstanceOption{CheckEnabled: false}, node, subscriptionTag)
if err != nil {
option.Log.Infof("failed to parse node: %v", err)
continue