Skip to content

Commit

Permalink
change maxport from maxInt to 65535
Browse files Browse the repository at this point in the history
  • Loading branch information
YenchangChan committed Apr 17, 2024
1 parent aca7950 commit d379713
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 1 addition & 5 deletions cmd/clickhouse_sinker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ var (
runner *task.Sinker
)

const (
HttpPortBase = 10000
)

func initCmdOptions() {
// 1. Set options to default value.
cmdOps = util.CmdOptions{
Expand Down Expand Up @@ -201,7 +197,7 @@ func main() {
// cmdOps.HTTPPort=0: let OS choose the listen port, and record the exact metrics URL to log.
httpPort := cmdOps.HTTPPort
if httpPort == 0 {
httpPort = HttpPortBase
httpPort = util.HttpPortBase
}
httpPort = util.GetSpareTCPPort(httpPort)

Expand Down
8 changes: 6 additions & 2 deletions util/net.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@ package util

import (
"fmt"
"math"
"net"

"github.com/thanos-io/thanos/pkg/errors"
)

const (
HttpPortBase = 10000
MaxPort = 65535
)

func GetIP4Byname(host string) (ips []string, err error) {
addrs, err := net.LookupIP(host)
if err != nil {
Expand Down Expand Up @@ -53,7 +57,7 @@ func GetOutboundIP() (ip net.IP, err error) {

// GetSpareTCPPort finds a spare TCP port.
func GetSpareTCPPort(portBegin int) int {
for port := portBegin; port < math.MaxInt; port++ {
for port := portBegin; port <= MaxPort; port++ {
if err := testListenOnPort(port); err == nil {
return port
}
Expand Down

0 comments on commit d379713

Please sign in to comment.