2023-02-09 10:58:30 +08:00
|
|
|
package network
|
|
|
|
|
|
2023-03-06 18:26:23 +08:00
|
|
|
import (
|
2023-03-16 10:46:06 +08:00
|
|
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
|
2023-03-06 18:26:23 +08:00
|
|
|
utils "github.com/OpenIMSDK/open_utils"
|
|
|
|
|
)
|
2023-02-09 10:58:30 +08:00
|
|
|
|
2023-02-09 11:30:31 +08:00
|
|
|
func GetRpcRegisterIP(configIP string) (string, error) {
|
2023-02-09 10:58:30 +08:00
|
|
|
registerIP := configIP
|
|
|
|
|
if registerIP == "" {
|
|
|
|
|
ip, err := utils.GetLocalIP()
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", err
|
|
|
|
|
}
|
|
|
|
|
registerIP = ip
|
|
|
|
|
}
|
|
|
|
|
return registerIP, nil
|
|
|
|
|
}
|
2023-02-09 11:30:31 +08:00
|
|
|
|
|
|
|
|
func GetListenIP(configIP string) string {
|
|
|
|
|
if configIP == "" {
|
2023-03-06 18:26:23 +08:00
|
|
|
return constant.LocalHost
|
2023-02-09 11:30:31 +08:00
|
|
|
} else {
|
|
|
|
|
return configIP
|
|
|
|
|
}
|
|
|
|
|
}
|