wohali commented on a change in pull request #1774: Support for more than 3
nodes dev cluster
URL: https://github.com/apache/couchdb/pull/1774#discussion_r240322037
##########
File path: dev/run
##########
@@ -217,9 +249,42 @@ def apply_config_overrides(ctx, content):
return content
-def get_ports(idnode):
+def get_ports(ctx, idnode):
assert idnode
- return ((10000 * idnode) + 5984, (10000 * idnode) + 5986)
+ if idnode <= 5 and not ctx['random_ports']:
+ return ((10000 * idnode) + 5984, (10000 * idnode) + 5986)
+ else:
+ return tuple(get_random_ports(2))
+
+
+def get_random_ports(num):
+ ports = []
+ while len(ports) < num:
+ with contextlib.closing(socket.socket(socket.AF_INET,
socket.SOCK_STREAM)) as soc:
Review comment:
Sequential binding isn't necessarily standard anymore. Randomization was
introduced to reduce attack vectors, especially in UDP requests.
https://www.cymru.com/jtk/misc/ephemeralports.html
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services