geforkt von Mirrors/Velocity
Add -haproxy-protocol startup parameter (#1136)
Dieser Commit ist enthalten in:
Ursprung
283005c8bc
Commit
363e3a7f94
@ -34,6 +34,7 @@ public final class ProxyOptions {
|
|||||||
private static final Logger logger = LogManager.getLogger(ProxyOptions.class);
|
private static final Logger logger = LogManager.getLogger(ProxyOptions.class);
|
||||||
private final boolean help;
|
private final boolean help;
|
||||||
private final @Nullable Integer port;
|
private final @Nullable Integer port;
|
||||||
|
private final @Nullable Boolean haproxy;
|
||||||
|
|
||||||
ProxyOptions(final String[] args) {
|
ProxyOptions(final String[] args) {
|
||||||
final OptionParser parser = new OptionParser();
|
final OptionParser parser = new OptionParser();
|
||||||
@ -43,10 +44,16 @@ public final class ProxyOptions {
|
|||||||
final OptionSpec<Integer> port = parser.acceptsAll(Arrays.asList("p", "port"),
|
final OptionSpec<Integer> port = parser.acceptsAll(Arrays.asList("p", "port"),
|
||||||
"Specify the bind port to be used. The configuration bind port will be ignored.")
|
"Specify the bind port to be used. The configuration bind port will be ignored.")
|
||||||
.withRequiredArg().ofType(Integer.class);
|
.withRequiredArg().ofType(Integer.class);
|
||||||
|
final OptionSpec<Boolean> haproxy = parser.acceptsAll(
|
||||||
|
Arrays.asList("haproxy", "haproxy-protocol"),
|
||||||
|
"Choose whether to enable haproxy protocol. "
|
||||||
|
+ "The configuration haproxy protocol will be ignored.")
|
||||||
|
.withRequiredArg().ofType(Boolean.class).defaultsTo(null);
|
||||||
final OptionSet set = parser.parse(args);
|
final OptionSet set = parser.parse(args);
|
||||||
|
|
||||||
this.help = set.has(help);
|
this.help = set.has(help);
|
||||||
this.port = port.value(set);
|
this.port = port.value(set);
|
||||||
|
this.haproxy = haproxy.value(set);
|
||||||
|
|
||||||
if (this.help) {
|
if (this.help) {
|
||||||
try {
|
try {
|
||||||
@ -64,4 +71,8 @@ public final class ProxyOptions {
|
|||||||
public @Nullable Integer getPort() {
|
public @Nullable Integer getPort() {
|
||||||
return this.port;
|
return this.port;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public @Nullable Boolean isHaproxy() {
|
||||||
|
return this.haproxy;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -257,6 +257,12 @@ public class VelocityServer implements ProxyServer, ForwardingAudience {
|
|||||||
this.cm.bind(configuration.getBind());
|
this.cm.bind(configuration.getBind());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final Boolean haproxy = this.options.isHaproxy();
|
||||||
|
if (haproxy != null) {
|
||||||
|
logger.debug("Overriding HAProxy protocol to {} from command line option", haproxy);
|
||||||
|
configuration.setProxyProtocol(haproxy);
|
||||||
|
}
|
||||||
|
|
||||||
if (configuration.isQueryEnabled()) {
|
if (configuration.isQueryEnabled()) {
|
||||||
this.cm.queryBind(configuration.getBind().getHostString(), configuration.getQueryPort());
|
this.cm.queryBind(configuration.getBind().getHostString(), configuration.getQueryPort());
|
||||||
}
|
}
|
||||||
|
@ -354,6 +354,10 @@ public class VelocityConfiguration implements ProxyConfig {
|
|||||||
return advanced.isProxyProtocol();
|
return advanced.isProxyProtocol();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setProxyProtocol(boolean proxyProtocol) {
|
||||||
|
advanced.setProxyProtocol(proxyProtocol);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean useTcpFastOpen() {
|
public boolean useTcpFastOpen() {
|
||||||
return advanced.isTcpFastOpen();
|
return advanced.isTcpFastOpen();
|
||||||
}
|
}
|
||||||
@ -755,6 +759,10 @@ public class VelocityConfiguration implements ProxyConfig {
|
|||||||
return proxyProtocol;
|
return proxyProtocol;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setProxyProtocol(boolean proxyProtocol) {
|
||||||
|
this.proxyProtocol = proxyProtocol;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isTcpFastOpen() {
|
public boolean isTcpFastOpen() {
|
||||||
return tcpFastOpen;
|
return tcpFastOpen;
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren