Skip to content

Commit de25eab

Browse files
committed
Express conflicts between socket and ip, port options via commander API
1 parent 12ff03c commit de25eab

File tree

2 files changed

+4
-13
lines changed

2 files changed

+4
-13
lines changed

bin/configurable-http-proxy

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//
88

99
import fs from "node:fs";
10-
import { Command } from "commander";
10+
import { Command, Option } from "commander";
1111

1212
import ConfigurableProxy from "../lib/configproxy.js";
1313
import { parseListenOptions } from "../lib/configproxy.js";
@@ -23,7 +23,7 @@ cli
2323
.version(pkg.version)
2424
.option("--ip <ip-address>", "Public-facing IP of the proxy")
2525
.option("--port <n> (defaults to 8000)", "Public-facing port of the proxy", parseInt)
26-
.option("--socket <path>", "Path to a UNIX domain socket for the proxy to listen on. Alternative to specifying IP and port.")
26+
.addOption(new Option("--socket <path>", "Path to a UNIX domain socket for the proxy to listen on. Alternative to specifying IP and port.").conflicts(['port', 'ip']))
2727
.option("--ssl-key <keyfile>", "SSL key to use, if any")
2828
.option("--ssl-cert <certfile>", "SSL certificate to use, if any")
2929
.option("--ssl-ca <ca-file>", "SSL certificate authority, if any")
@@ -42,7 +42,7 @@ cli
4242
"Inward-facing port for API requests (defaults to --port=value+1)",
4343
parseInt
4444
)
45-
.option("--api-socket <path>", "Path to a UNIX domain socket for the API server to listen on. Alternative to specifying API IP and port.")
45+
.addOption(new Option("--api-socket <path>", "Path to a UNIX domain socket for the API server to listen on. Alternative to specifying API IP and port.").conflicts(['api-port', 'api-ip']))
4646
.option("--api-ssl-key <keyfile>", "SSL key to use, if any, for API requests")
4747
.option("--api-ssl-cert <certfile>", "SSL certificate to use, if any, for API requests")
4848
.option("--api-ssl-ca <ca-file>", "SSL certificate authority, if any, for API requests")
@@ -97,7 +97,7 @@ cli
9797
.option("--host-routing", "Use host routing (host as first level of path)")
9898
.option("--metrics-ip <ip>", "IP for metrics server", "")
9999
.option("--metrics-port <n>", "Port of metrics server. Defaults to no metrics server")
100-
.option("--metrics-socket <path>", "Path to a UNIX domain socket for the metrics server to listen on. Alternative to specifying metrics IP and port.")
100+
.addOption(new Option("--metrics-socket <path>", "Path to a UNIX domain socket for the metrics server to listen on. Alternative to specifying metrics IP and port.").conflicts(['metrics-port', 'metrics-ip']))
101101
.option("--log-level <loglevel>", "Log level (debug, info, warn, error)", "info")
102102
.option(
103103
"--timeout <n>",

lib/configproxy.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ export function parseListenOptions(args, logger) {
2929

3030
if (args.socket) {
3131
listen.proxyTarget = [args.socket];
32-
logger.warn(
33-
"Proxy will listen on UNIX domain socket, --ip and --port options will be ignored."
34-
);
3532
} else {
3633
listen.port = parseInt(args.port) || 8000;
3734
if (args.ip === "*") {
@@ -47,19 +44,13 @@ export function parseListenOptions(args, logger) {
4744

4845
if (args.apiSocket) {
4946
listen.apiSocket = [args.apiSocket];
50-
logger.warn(
51-
"API server will listen on UNIX domain socket, --api-ip and --api-port options will be ignored."
52-
);
5347
} else {
5448
listen.apiPort = args.apiPort ? parseInt(args.apiPort) : listen.port ? listen.port + 1 : 8001;
5549
listen.apiTarget = [listen.apiPort, args.apiIp];
5650
}
5751

5852
if (args.metricsSocket) {
5953
listen.metricsSocket = [args.metricsSocket];
60-
logger.warn(
61-
"Metrics server will listen on UNIX domain socket, --metrics-ip and --metrics-port options will be ignored."
62-
);
6354
} else if (args.metricsPort) {
6455
listen.metricsTarget = [parseInt(args.metricsPort), args.metricsIp];
6556
}

0 commit comments

Comments
 (0)