Skip to content

Commit

Permalink
feat: 连接北极星获取自身IP时增加超时,防止卡死 (#200)
Browse files Browse the repository at this point in the history
  • Loading branch information
WTIFS authored Feb 1, 2024
1 parent c316572 commit f88e184
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion api/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,8 @@ func initSelfIP(cfg config.Configuration) {
return
}

conn, _ := net.Dial("tcp", address[0])
timeout := cfg.GetGlobal().GetServerConnector().GetConnectTimeout()
conn, _ := net.DialTimeout("tcp", address[0], timeout)
if conn != nil {
localAddr := conn.LocalAddr().String()
colonIdx := strings.LastIndex(localAddr, ":")
Expand Down

0 comments on commit f88e184

Please sign in to comment.