mirror of
https://github.com/status-im/go-waku.git
synced 2025-02-05 02:15:00 +00:00
feat: force reachability (#778)
This commit is contained in:
parent
7f466c1d99
commit
88d69ebccd
@ -177,13 +177,13 @@ var (
|
|||||||
Destination: &options.CircuitRelay,
|
Destination: &options.CircuitRelay,
|
||||||
EnvVars: []string{"WAKUNODE2_CIRCUIT_RELAY"},
|
EnvVars: []string{"WAKUNODE2_CIRCUIT_RELAY"},
|
||||||
})
|
})
|
||||||
ForceUnreachable = altsrc.NewBoolFlag(&cli.BoolFlag{
|
ForceReachability = altsrc.NewStringFlag(&cli.StringFlag{
|
||||||
Name: "unreachable",
|
Name: "force-reachability",
|
||||||
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",
|
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: false,
|
Value: "",
|
||||||
Hidden: true,
|
Hidden: true,
|
||||||
Destination: &options.ForceUnreachable,
|
Destination: &options.ForceReachability,
|
||||||
EnvVars: []string{"WAKUNODE2_UNREACHABLE"},
|
EnvVars: []string{"WAKUNODE2_REACHABILITY"},
|
||||||
})
|
})
|
||||||
ResourceScalingMemoryPercent = altsrc.NewFloat64Flag(&cli.Float64Flag{
|
ResourceScalingMemoryPercent = altsrc.NewFloat64Flag(&cli.Float64Flag{
|
||||||
Name: "resource-scaling-memory-percentage",
|
Name: "resource-scaling-memory-percentage",
|
||||||
|
@ -42,7 +42,7 @@ func main() {
|
|||||||
ExtMultiaddresses,
|
ExtMultiaddresses,
|
||||||
ShowAddresses,
|
ShowAddresses,
|
||||||
CircuitRelay,
|
CircuitRelay,
|
||||||
ForceUnreachable,
|
ForceReachability,
|
||||||
ResourceScalingMemoryPercent,
|
ResourceScalingMemoryPercent,
|
||||||
ResourceScalingFDPercent,
|
ResourceScalingFDPercent,
|
||||||
LogLevel,
|
LogLevel,
|
||||||
|
@ -170,10 +170,18 @@ func Execute(options NodeOptions) {
|
|||||||
libp2pOpts = append(libp2pOpts, libp2p.EnableRelayService())
|
libp2pOpts = append(libp2pOpts, libp2p.EnableRelayService())
|
||||||
}
|
}
|
||||||
|
|
||||||
if options.ForceUnreachable {
|
if options.ForceReachability != "" {
|
||||||
logger.Warn("node forced to be unreachable!")
|
libp2pOpts = append(libp2pOpts, libp2p.EnableRelay())
|
||||||
libp2pOpts = append(libp2pOpts, libp2p.EnableRelay(), libp2p.ForceReachabilityPrivate())
|
|
||||||
nodeOpts = append(nodeOpts, node.WithCircuitRelayParams(2*time.Second, 2*time.Second))
|
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 != "" {
|
if options.UserAgent != "" {
|
||||||
|
@ -157,7 +157,7 @@ type NodeOptions struct {
|
|||||||
AdvertiseAddresses []multiaddr.Multiaddr
|
AdvertiseAddresses []multiaddr.Multiaddr
|
||||||
ShowAddresses bool
|
ShowAddresses bool
|
||||||
CircuitRelay bool
|
CircuitRelay bool
|
||||||
ForceUnreachable bool
|
ForceReachability string
|
||||||
ResourceScalingMemoryPercent float64
|
ResourceScalingMemoryPercent float64
|
||||||
ResourceScalingFDPercent float64
|
ResourceScalingFDPercent float64
|
||||||
LogLevel string
|
LogLevel string
|
||||||
|
Loading…
x
Reference in New Issue
Block a user