diff --git a/tools/mix/mix_relay_dht.nim b/tools/mix/mix_relay_dht.nim index f9fc493e..0f20f933 100644 --- a/tools/mix/mix_relay_dht.nim +++ b/tools/mix/mix_relay_dht.nim @@ -228,6 +228,7 @@ type Conf = object generate: bool noDhtProxy: bool maxInFlight: int + maxConnections: int proc usage(): string = """ @@ -239,20 +240,21 @@ Usage: [--bootstrap-node= ...] [--log-level=] [--generate] Options: - --data-dir= Directory holding identity files (key + mix-identity). - --listen-ip= Public IPv4 to bind/announce for libp2p TCP. - --listen-port= libp2p TCP port (Mix relay + DHT proxy share this). - --disc-port= discv5 UDP port. + --data-dir= Directory holding identity files (key + mix-identity). + --listen-ip= Public IPv4 to bind/announce for libp2p TCP. + --listen-port= libp2p TCP port (Mix relay + DHT proxy share this). + --disc-port= discv5 UDP port. --bootstrap-node= Repeatable. SPR of a discv5 bootstrap peer. - --log-level= TRACE | DEBUG | INFO | NOTICE | WARN | ERROR | FATAL | NONE - (default: INFO) - --log-file= Write logs to instead of stdout. - --generate Generate fresh identity files if data-dir is empty. - --no-dht-proxy Run as a pure Mix relay. - Conflicts with --disc-port and --bootstrap-node. - --max-inflight= Max concurrent DHT proxy lookups (default: 100). - -h, --help Show this help. - -v, --version Show version and revision. + --log-level= TRACE | DEBUG | INFO | NOTICE | WARN | ERROR | FATAL | NONE + (default: INFO) + --log-file= Write logs to instead of stdout. + --generate Generate fresh identity files if data-dir is empty. + --no-dht-proxy Run as a pure Mix relay. + Conflicts with --disc-port and --bootstrap-node. + --max-inflight= Max concurrent DHT proxy lookups (default: 100). + --max-connections= Max libp2p connections (in + out) (default: 160). + -h, --help Show this help. + -v, --version Show version and revision. """ proc parseSpr(raw: string): SignedPeerRecord = @@ -273,6 +275,7 @@ proc parseConf(): Conf = generate: false, noDhtProxy: false, maxInFlight: DefaultMaxInFlightLookups, + maxConnections: 160, ) var p = initOptParser(commandLineParams()) while true: @@ -324,6 +327,13 @@ proc parseConf(): Conf = fail "--max-inflight must be an integer, got: " & p.val if result.maxInFlight < 1: fail "--max-inflight must be >= 1, got: " & $result.maxInFlight + of "max-connections": + try: + result.maxConnections = parseInt(p.val) + except ValueError: + fail "--max-connections must be an integer, got: " & p.val + if result.maxConnections < 1: + fail "--max-connections must be >= 1, got: " & $result.maxConnections else: fail "Unknown flag: --" & p.key of cmdArgument: @@ -557,6 +567,7 @@ proc run(conf: Conf) {.async: (raises: [CatchableError]).} = .withRng(newRng()) .withNoise() .withYamux() + .withMaxConnections(conf.maxConnections) .withTcpTransport({ServerFlags.ReuseAddr, ServerFlags.TcpNoDelay}) .build()