Skip to content

Commit

Permalink
fix: bug
Browse files Browse the repository at this point in the history
  • Loading branch information
hiddify-com committed Jul 26, 2024
1 parent dc1ac19 commit e9a7563
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions outbound/xray.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,15 @@ type Xray struct {

func getRandomFreePort() uint16 {
for {
port := rand.Intn(35535) + 30000 // range 30000 to 65535
l, err := net.Listen("tcp", fmt.Sprintf(":%d", port))
port := rand.Intn(25535) + 30000 // range 30000 to 65535
l, err := net.Listen("tcp", fmt.Sprintf("127.0.0.1:%d", port))
if err == nil {
l.Close()
return uint16(port)
l, err := net.Listen("udp", fmt.Sprintf("127.0.0.1:%d", port))
if err == nil {
l.Close()
return uint16(port)
}
}
}
}
Expand Down

0 comments on commit e9a7563

Please sign in to comment.