-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add support for HA Proxy Protocol TLV's #5972
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -23,6 +23,7 @@ | |||||||||
| import java.time.Duration; | ||||||||||
| import java.util.Arrays; | ||||||||||
| import java.util.List; | ||||||||||
| import java.util.Map; | ||||||||||
| import java.util.concurrent.TimeUnit; | ||||||||||
|
|
||||||||||
| /** | ||||||||||
|
|
@@ -298,4 +299,11 @@ default List<Certificate> peerCertificates() throws SSLPeerUnverifiedException { | |||||||||
| */ | ||||||||||
| String indicatedServerName(); | ||||||||||
|
|
||||||||||
| /** | ||||||||||
| * @return the type-length-values present in the TCP header as map where the key contains the TLV type and | ||||||||||
| * the value contains the TLV value, mainly used for HA Proxy Protocol v2 | ||||||||||
| */ | ||||||||||
| @GenIgnore() | ||||||||||
| Map<Buffer, Buffer> tlvs(); | ||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
|
||||||||||
| } | ||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,7 +18,6 @@ | |
| import io.vertx.codegen.annotations.VertxGen; | ||
| import io.vertx.core.Future; | ||
| import io.vertx.core.Handler; | ||
| import io.vertx.core.VertxException; | ||
| import io.vertx.core.buffer.Buffer; | ||
| import io.vertx.core.streams.ReadStream; | ||
| import io.vertx.core.streams.WriteStream; | ||
|
|
@@ -29,6 +28,7 @@ | |
| import java.time.Duration; | ||
| import java.util.Arrays; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| /** | ||
| * Represents a socket-like interface to a TCP connection on either the | ||
|
|
@@ -316,5 +316,12 @@ default List<Certificate> peerCertificates() throws SSLPeerUnverifiedException { | |
| */ | ||
| String applicationLayerProtocol(); | ||
|
|
||
| /** | ||
| * @return the type-length-values present in the TCP header as map where the key contains the TLV type and | ||
| * the value contains the TLV value, mainly used for HA Proxy Protocol v2 | ||
| */ | ||
| @GenIgnore() | ||
| Map<Buffer, Buffer> tlvs(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do we need that ? Quic does not yet support proxying at the moment and we are not sure it makes sense
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that seems at the moment to be a TCP concern only
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you see a better place to put this one ? The goal is to access TLV's in
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sorry, it is fine here, I meant actually on QuicConnection it should apply to. |
||
|
|
||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -18,6 +18,7 @@ | |||||
|
|
||||||
| import javax.net.ssl.SSLSession; | ||||||
| import java.time.Duration; | ||||||
| import java.util.Map; | ||||||
|
|
||||||
| /** | ||||||
| * <p>A Quic connection between a client and a server, providing support for handling or creating Quic {@link QuicStream streams}</p> | ||||||
|
|
@@ -176,4 +177,11 @@ default Future<Void> shutdown(Duration timeout) { | |||||
| */ | ||||||
| SocketAddress localAddress(); | ||||||
|
|
||||||
| /** | ||||||
| * @return the type-length-values present in the TCP header as map where the key contains the TLV type and | ||||||
|
Comment on lines
+180
to
+181
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| * the value contains the TLV value, mainly used for HA Proxy Protocol v2 | ||||||
| */ | ||||||
| @GenIgnore() | ||||||
| Map<Buffer, Buffer> tlvs(); | ||||||
|
|
||||||
| } | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| /* | ||
| * Copyright (c) 2011-2026 Contributors to the Eclipse Foundation | ||
| * | ||
| * This program and the accompanying materials are made available under the | ||
| * terms of the Eclipse Public License 2.0 which is available at | ||
| * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 | ||
| * which is available at https://www.apache.org/licenses/LICENSE-2.0. | ||
| * | ||
| * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 | ||
| */ | ||
| package io.vertx.core.net.impl; | ||
|
|
||
| import io.netty.buffer.ByteBufUtil; | ||
| import io.vertx.core.buffer.Buffer; | ||
| import io.vertx.core.net.TLV; | ||
|
|
||
| public class HAProxyTLV implements TLV { | ||
|
|
||
| private final Buffer type; | ||
| private final Buffer value; | ||
|
|
||
| public HAProxyTLV(Buffer type, Buffer value) { | ||
| this.type = type; | ||
| this.value = value; | ||
| } | ||
|
|
||
| public static TLV from(io.netty.handler.codec.haproxy.HAProxyTLV haProxyTLV) { | ||
| Buffer type = Buffer.buffer().appendByte(haProxyTLV.typeByteValue()); | ||
| Buffer value = Buffer.buffer(ByteBufUtil.getBytes(haProxyTLV.content())); | ||
| return new HAProxyTLV(type, value); | ||
| } | ||
|
|
||
| @Override | ||
| public Buffer type() { | ||
| return type; | ||
| } | ||
|
|
||
| @Override | ||
| public Buffer value() { | ||
| return value; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should return null when it does not apply, e.g. HTTP/3