Skip to content
This repository has been archived by the owner on May 26, 2022. It is now read-only.

deprecate the use of LIBP2P_TCP_REUSEPORT #103

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions reuseport.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,25 @@ import (
)

// envReuseport is the env variable name used to turn off reuse port.
// It default to true.
// It defaults to true.
// Deprecated: use the constructor option DisableReuseport instead.
const envReuseport = "LIBP2P_TCP_REUSEPORT"
const deprecatedEnvReuseport = "IPFS_REUSEPORT"

// envReuseportVal stores the value of envReuseport. defaults to true.
var envReuseportVal = true

func init() {
v := strings.ToLower(os.Getenv(envReuseport))
if len(v) > 0 {
log.Warn("LIBP2P_TCP_REUSEPORT is deprecated. Use the DisableReuseport constructor option instead.")
}
if v == "false" || v == "f" || v == "0" {
envReuseportVal = false
log.Infof("REUSEPORT disabled (LIBP2P_TCP_REUSEPORT=%s)", v)
}
v, exist := os.LookupEnv(deprecatedEnvReuseport)
if exist {
log.Warn("IPFS_REUSEPORT is deprecated, use LIBP2P_TCP_REUSEPORT instead")
if v == "false" || v == "f" || v == "0" {
envReuseportVal = false
log.Infof("REUSEPORT disabled (IPFS_REUSEPORT=%s)", v)
}
}
}

// reuseportIsAvailable returns whether reuseport is available to be used. This
// ReuseportIsAvailable returns whether reuseport is available to be used. This
// is here because we want to be able to turn reuseport on and off selectively.
// For now we use an ENV variable, as this handles our pressing need:
//
Expand Down