修改adress.go的convPort方法,支持IPv6地址之间建立连接。 (#248)
monapi: http: '[::]:5800' address: - '[::1]'
This commit is contained in:
parent
520dda70c0
commit
b63c4e510c
|
@ -40,7 +40,11 @@ func GetRPCPort(mod string) int {
|
|||
}
|
||||
|
||||
func convPort(module, listen, portType string) int {
|
||||
port, err := strconv.Atoi(strings.Split(listen, ":")[1])
|
||||
splitChar := ":"
|
||||
if IsIPv6(listen) {
|
||||
splitChar = "]:"
|
||||
}
|
||||
port, err := strconv.Atoi(strings.Split(listen, splitChar)[1])
|
||||
if err != nil {
|
||||
fmt.Printf("%s.%s invalid", module, portType)
|
||||
os.Exit(1)
|
||||
|
@ -127,3 +131,8 @@ func getConf() string {
|
|||
os.Exit(1)
|
||||
return ""
|
||||
}
|
||||
|
||||
func IsIPv6(address string) bool {
|
||||
return strings.Count(address,":") >=2
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue