mirror of
https://github.com/status-im/go-waku.git
synced 2025-01-26 21:49:26 +00:00
feat: force reachability (#778)
This commit is contained in:
parent
7f466c1d99
commit
88d69ebccd
@ -177,13 +177,13 @@ var (
|
||||
Destination: &options.CircuitRelay,
|
||||
EnvVars: []string{"WAKUNODE2_CIRCUIT_RELAY"},
|
||||
})
|
||||
ForceUnreachable = altsrc.NewBoolFlag(&cli.BoolFlag{
|
||||
Name: "unreachable",
|
||||
Usage: "Force the node to be unreachable. WARNING: This flag is created for testing circuit relay and is not meant to be used in production",
|
||||
Value: false,
|
||||
ForceReachability = altsrc.NewStringFlag(&cli.StringFlag{
|
||||
Name: "force-reachability",
|
||||
Usage: "Force the node reachability. WARNING: This flag is created for testing circuit relay and is not meant to be used in production. Use 'public' or 'private'",
|
||||
Value: "",
|
||||
Hidden: true,
|
||||
Destination: &options.ForceUnreachable,
|
||||
EnvVars: []string{"WAKUNODE2_UNREACHABLE"},
|
||||
Destination: &options.ForceReachability,
|
||||
EnvVars: []string{"WAKUNODE2_REACHABILITY"},
|
||||
})
|
||||
ResourceScalingMemoryPercent = altsrc.NewFloat64Flag(&cli.Float64Flag{
|
||||
Name: "resource-scaling-memory-percentage",
|
||||
|
@ -42,7 +42,7 @@ func main() {
|
||||
ExtMultiaddresses,
|
||||
ShowAddresses,
|
||||
CircuitRelay,
|
||||
ForceUnreachable,
|
||||
ForceReachability,
|
||||
ResourceScalingMemoryPercent,
|
||||
ResourceScalingFDPercent,
|
||||
LogLevel,
|
||||
|
@ -170,10 +170,18 @@ func Execute(options NodeOptions) {
|
||||
libp2pOpts = append(libp2pOpts, libp2p.EnableRelayService())
|
||||
}
|
||||
|
||||
if options.ForceUnreachable {
|
||||
logger.Warn("node forced to be unreachable!")
|
||||
libp2pOpts = append(libp2pOpts, libp2p.EnableRelay(), libp2p.ForceReachabilityPrivate())
|
||||
if options.ForceReachability != "" {
|
||||
libp2pOpts = append(libp2pOpts, libp2p.EnableRelay())
|
||||
nodeOpts = append(nodeOpts, node.WithCircuitRelayParams(2*time.Second, 2*time.Second))
|
||||
if options.ForceReachability == "private" {
|
||||
logger.Warn("node forced to be unreachable!")
|
||||
libp2pOpts = append(libp2pOpts, libp2p.ForceReachabilityPrivate())
|
||||
} else if options.ForceReachability == "public" {
|
||||
logger.Warn("node forced to be publicly reachable!")
|
||||
libp2pOpts = append(libp2pOpts, libp2p.ForceReachabilityPublic())
|
||||
} else {
|
||||
failOnErr(errors.New("invalid reachability value"), "Reachability")
|
||||
}
|
||||
}
|
||||
|
||||
if options.UserAgent != "" {
|
||||
|
@ -157,7 +157,7 @@ type NodeOptions struct {
|
||||
AdvertiseAddresses []multiaddr.Multiaddr
|
||||
ShowAddresses bool
|
||||
CircuitRelay bool
|
||||
ForceUnreachable bool
|
||||
ForceReachability string
|
||||
ResourceScalingMemoryPercent float64
|
||||
ResourceScalingFDPercent float64
|
||||
LogLevel string
|
||||
|
Loading…
x
Reference in New Issue
Block a user