Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix to flags configuring ip addresses for ipv4+ipv6 compatebility #333

Merged
merged 2 commits into from
Jul 18, 2021

Conversation

consideRatio
Copy link
Member

@consideRatio consideRatio commented Jul 17, 2021

Small changes to help z2jh avoid IPv4 and/or IPv6 issues by not specifying either :: or 0.0.0.0 but instead a blank string when we want to listen far and wide as we do in a z2jh container.

Review notes

I'd love to have this merged soon and cut a release of CHP to bump if for z2jh 1.1.0 that I'd like to make next week.

Related

Comment on lines -320 to +322
listen.apiIp = args.apiIp || "localhost";
listen.apiIp = args.apiIp;
listen.apiPort = args.apiPort || listen.port + 1;
listen.metricsIp = args.metricsIp || "0.0.0.0";
listen.metricsIp = args.metricsIp;
Copy link
Member Author

Choose a reason for hiding this comment

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

Note that these were defaults that were set above during CLI parsing anyhow. By changing this, the actual change in logic outcomes are when we pass a blank string and args.apiIp || "localhost" no longer overrides the falsy blank string.

.option("--metrics-ip <ip>", "IP for metrics server", "0.0.0.0")
.option("--metrics-ip <ip>", "IP for metrics server", "")
Copy link
Member Author

@consideRatio consideRatio Jul 17, 2021

Choose a reason for hiding this comment

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

I've verified that CHP became accessible when configured with a blank string just as if it would have been configured with 0.0.0.0 via Z2JH's test suite, but I think using a blank string, we also acquire the sensible IPv4 and/or IPv6 compatibility we want.

@consideRatio
Copy link
Member Author

consideRatio commented Jul 17, 2021

Script to validate CLI parsing logic relevant to this PR

#!/usr/bin/env node

var cli = require("commander");
var log = require("../lib/log.js").defaultLogger();

var args = cli
  .option("--ip <ip-address>", "description...")
  .option("--api-ip <ip-address>", "description...", "localhost")
  .option("--metrics-ip <ip-address>", "description...", "")
  .parse(process.argv)
  .opts();

if (args.ip == "") {
    log.error("--ip was a blank string");
} else {
    log.error("--ip was: " + args.ip);
}

if (args.apiIp == "") {
    log.error("--api-ip was a blank string");
} else {
    log.error("--api-ip was: " + args.apiIp);
}

if (args.metricsIp == "") {
    log.error("--metrics-ip was a blank string");
} else {
    log.error("--metrics-ip was: " + args.metricsIp);
}

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants