feat: set port in addr
This commit is contained in:
@ -7,6 +7,7 @@ import (
|
||||
|
||||
type Adddress struct {
|
||||
Host string
|
||||
Port string
|
||||
Route string
|
||||
}
|
||||
|
||||
@ -24,12 +25,23 @@ func ParseAddress(address string) (*Adddress, error) {
|
||||
|
||||
addr := parts[0]
|
||||
|
||||
port := HSP_PORT
|
||||
|
||||
if strings.Contains(addr, ":") {
|
||||
p := strings.Split(addr, ":")
|
||||
if len(p) >= 2 {
|
||||
port = p[len(p) - 1]
|
||||
addr = p[0]
|
||||
}
|
||||
}
|
||||
|
||||
return &Adddress{
|
||||
Host: addr,
|
||||
Port: port,
|
||||
Route: route,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (a *Adddress) String() string {
|
||||
return fmt.Sprintf("%s:%s", a.Host, HSP_PORT)
|
||||
return fmt.Sprintf("%s:%s", a.Host, a.Port)
|
||||
}
|
||||
|
Reference in New Issue
Block a user