Skip to content
This repository was archived by the owner on Jan 9, 2023. It is now read-only.

Conversation

@adipirro
Copy link
Contributor

Added a PUT whitelist for configuring which machines are allowed to write to the cache server: #37

Also added the ability to toggle IPv6 on/off (defaulting to off). This is to avoid confusion when dealing with hybrid Ipv4-Ipv6 sockets as they convert IPv4 addresses to Ipv4-mapped Ipv6 addresses.

Relevant net library docs: https://nodejs.org/dist/latest-v4.x/docs/api/net.html#net_server_listen_port_hostname_backlog_callback

@coveralls
Copy link

coveralls commented Jun 11, 2018

Coverage Status

Coverage decreased (-0.7%) to 89.669% when pulling 9f728b1 on adipirro:feature/putWhitelist into bf012ab on Unity-Technologies:master.

Copy link
Contributor

@stephen-palmer stephen-palmer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice additions .. just some minor changes requested.

README.md Outdated
`-w`, `--workers <n>` | The number of worker threads to spawn. The default is 0.
`-m`, `--mirror [host:port]` | Mirror transactions to another cache server. Repeat this option ofr multiple mirrors.
`-m`, `--monitor-parent-process <n>` | Monitor a parent process and exit if it dies.
`--allow-ipv6` | Allow IPv6 connections if available.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer if this were in the config file - we need to move toward less discrepancy between CLI options and config file options.

To do so, I think a new top level section called "Server" would be appropriate:

Server
   options:
      allowIpv6: true

options.mirror = [].concat(options.mirror);
this._mirrors = options.mirror.map(m => new TransactionMirror(m, cache));
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Convert tabs to spaces (there are a few other places as well)

* @private
*/
_isWhitelisted(ip) {
if(this._whitelistEmpty){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be simplified:

return this._whitelistEmpty || this._putWhitelist.indexOf(ip) != -1

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be simplified further and maybe a little easier to understand if you use includes over an indexOf check:

return this._whitelistEmpty || this._putWhitelist.includes(ip);

if(this.allowIpv6){
this._server.listen(this.port, () => resolve());
}
else{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leave a space before open braces

Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a couple ergonomic notes.


Was this helpful? Let us know!

return new Promise(resolve => {
this._server.listen(this.port, () => resolve());
if(this.allowIpv6){
this._server.listen(this.port, () => resolve());
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you are ignoring the resolution value of this promise, you can save an extra function call here and on line 96 by passing resolve by reference:

this._server.listen(this.port, resolve);
this._server.listen(this.port, "0.0.0.0", resolve);

Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


Was this helpful? Let us know!

Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


Was this helpful? Let us know!

@adipirro
Copy link
Contributor Author

Looks like Travis doesn't support IPv6, bummer.

I don't think there are any more tests I can reasonably add. Going to leave this as is unless you have any requests.

@stephen-palmer stephen-palmer merged commit 450e8e0 into Unity-Technologies:master Aug 8, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants