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

Commit aef8e11

Browse files
adipirroAnthony DiPirro
authored andcommitted
Add ability to toggle ipv6 on/off, default off
Useful when dealing with whitelist
1 parent aaea367 commit aef8e11

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ Command | Description
6262
`-w`, `--workers <n>` | The number of worker threads to spawn. The default is 0.
6363
`-m`, `--mirror [host:port]` | Mirror transactions to another cache server. Repeat this option ofr multiple mirrors.
6464
`-m`, `--monitor-parent-process <n>` | Monitor a parent process and exit if it dies.
65+
`--allow-ipv6` | Allow IPv6 connections if available.
6566
`--dump-config` | Write the active configuration to the console.
6667
`--save-config [path]` | Write the active configuration to the specified file and exit. Defaults to `./default.yml`.
6768
`--NODE_CONFIG_DIR=<path>` | The directory to search for config files. This is equivalent to setting the `NODE_CONFIG_DIR` environment variable. If not specified, the built-in configuration is used.

lib/server/server.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ class CacheServer {
2525
if(options.mirror) {
2626
options.mirror = [].concat(options.mirror);
2727
this._mirrors = options.mirror.map(m => new TransactionMirror(m, cache));
28-
}
28+
}
29+
30+
this.allowIpv6 = options.allowIpv6;
2931
}
3032

3133
/**
@@ -87,7 +89,13 @@ class CacheServer {
8789
});
8890

8991
return new Promise(resolve => {
90-
this._server.listen(this.port, () => resolve());
92+
if(this.allowIpv6){
93+
this._server.listen(this.port, () => resolve());
94+
}
95+
else{
96+
this._server.listen(this.port, "0.0.0.0", () => resolve());
97+
}
98+
9199
});
92100
};
93101

main.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,13 @@ if(Array.isArray(processorOptions.putWhitelist) && processorOptions.putWhitelist
3636
program.description("Unity Cache Server")
3737
.version(VERSION)
3838
.allowUnknownOption(true)
39-
.option('-p, --port <n>', 'Specify the server port, only apply to new cache server', myParseInt, consts.DEFAULT_PORT)
39+
.option('-p, --port <n>', 'Specify the server port, only apply to new cache server', myParseInt, consts.DEFAULT_PORT)
4040
.option('-c --cache-module [path]', 'Use cache module at specified path', defaultCacheModule)
4141
.option('-P, --cache-path [path]', 'Specify the path of the cache directory')
4242
.option('-l, --log-level <n>', 'Specify the level of log verbosity. Valid values are 0 (silent) through 5 (debug)', myParseInt, consts.DEFAULT_LOG_LEVEL)
4343
.option('-w, --workers <n>', 'Number of worker threads to spawn', zeroOrMore, consts.DEFAULT_WORKERS)
44-
.option('-m --mirror [host:port]', 'Mirror transactions to another cache server. Can be repeated for multiple mirrors', collect, [])
44+
.option('-m --mirror [host:port]', 'Mirror transactions to another cache server. Can be repeated for multiple mirrors', collect, [])
45+
.option('--allow-ipv6', 'Allow IPv6 connections if available')
4546
.option('--dump-config', 'Write the active configuration to the console')
4647
.option('--save-config [path]', 'Write the active configuration to the specified file and exit. Defaults to ./default.yml')
4748
.option('--NODE_CONFIG_DIR=<path>', 'Specify the directory to search for config files. This is equivalent to setting the NODE_CONFIG_DIR environment variable. Without this option, the built-in configuration is used.');
@@ -119,7 +120,8 @@ Cache.init(cacheOpts)
119120
.then(mirrors => {
120121
const opts = {
121122
port: program.port,
122-
mirror: mirrors
123+
mirror: mirrors,
124+
allowIpv6: program.allowIpv6
123125
};
124126

125127
server = new Server(Cache, opts);

0 commit comments

Comments
 (0)