improve cmd

This commit is contained in:
ginuerzh
2022-01-20 23:50:56 +08:00
parent 3ef98c16aa
commit bb889412d2
3 changed files with 52 additions and 19 deletions

View File

@ -74,9 +74,12 @@ func (r *Router) resolve(ctx context.Context, addr string) (string, error) {
}
host, port, err := net.SplitHostPort(addr)
if err != nil || host == "" {
if err != nil {
return "", err
}
if host == "" {
return addr, nil
}
if r.Hosts != nil {
if ips, _ := r.Hosts.Lookup("ip", host); len(ips) > 0 {

View File

@ -93,6 +93,10 @@ func GetDuration(md Metadata, key string) (v time.Duration) {
return time.Duration(vv) * time.Second
case string:
v, _ = time.ParseDuration(vv)
if v == 0 {
n, _ := strconv.Atoi(vv)
v = time.Duration(n) * time.Second
}
}
return
}