Skip to content

Commit

Permalink
Merge pull request #27 from cannium/master
Browse files Browse the repository at this point in the history
Deprecate IPFS_REUSEPORT, use LIBP2P_TCP_REUSEPORT
  • Loading branch information
Stebalien committed Oct 30, 2018
2 parents bd1a6b0 + e8b9e0d commit a2176a3
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions p2p/transport/tcp/reuseport.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import (

// envReuseport is the env variable name used to turn off reuse port.
// It default to true.
const envReuseport = "IPFS_REUSEPORT"
const envReuseport = "LIBP2P_TCP_REUSEPORT"
const deprecatedEnvReuseport = "IPFS_REUSEPORT"

// envReuseportVal stores the value of envReuseport. defaults to true.
var envReuseportVal = true
Expand All @@ -18,15 +19,23 @@ func init() {
v := strings.ToLower(os.Getenv(envReuseport))
if v == "false" || v == "f" || v == "0" {
envReuseportVal = false
log.Infof("REUSEPORT disabled (IPFS_REUSEPORT=%s)", v)
log.Infof("REUSEPORT disabled (LIBP2P_TCP_REUSEPORT=%s)", v)
}
v, exist := os.LookupEnv(deprecatedEnvReuseport)
if exist {
log.Warning("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
// 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:
//
// IPFS_REUSEPORT=false ipfs daemon
// LIBP2P_TCP_REUSEPORT=false ipfs daemon
//
// If this becomes a sought after feature, we could add this to the config.
// In the end, reuseport is a stop-gap.
Expand Down

0 comments on commit a2176a3

Please sign in to comment.