Open rishabh78 opened 1 day ago
@DavidSchinazi
Adding @danzh2010 for any insights
The request has some invalid HTTP header. Can you share the requests you are sending?
''' h3 = protocol.h3_connection
# Create a new stream
stream_id = quic.get_next_available_stream_id()
# Send CONNECT-UDP request headers
target_host = "127.0.0.1"
target_port = 10002
h3.send_headers(
stream_id=stream_id,
headers=[
(b":method", b"CONNECT-UDP"),
(b":authority", f"{target_host}:{target_port}".encode()),
],
)
'''
''' h3 = protocol.h3_connection
# Create a new stream stream_id = quic.get_next_available_stream_id() # Send CONNECT-UDP request headers target_host = "127.0.0.1" target_port = 10002 h3.send_headers( stream_id=stream_id, headers=[ (b":method", b"CONNECT-UDP"), (b":authority", f"{target_host}:{target_port}".encode()), ], )
'''
@DavidSchinazi Is this how CONNECT-UDP header should be like?
I am using this clinet
# connect_udp_client.py
import asyncio
from aioquic.asyncio import connect
from aioquic.quic.configuration import QuicConfiguration
from aioquic.h3.connection import H3_ALPN, H3Connection
from aioquic.h3.events import HeadersReceived, DataReceived, H3Event
from aioquic.asyncio.protocol import QuicConnectionProtocol
class CustomQuicClient(QuicConnectionProtocol):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.h3_connection = H3Connection(self._quic)
self.events = []
def quic_event_received(self, event):
for http_event in self.h3_connection.handle_event(event):
self.events.append(http_event)
async def main():
# Configure QUIC client
configuration = QuicConfiguration(is_client=True)
configuration.alpn_protocols = H3_ALPN
configuration.verify_mode = False # Disable verification for local testing
configuration.server_name = "localhost" # Set the appropriate SNI
async with connect("127.0.0.1", 10001, configuration=configuration, create_protocol=CustomQuicClient) as protocol:
quic = protocol._quic
h3 = protocol.h3_connection
# Create a new stream
stream_id = quic.get_next_available_stream_id()
# Send CONNECT-UDP request headers
target_host = "127.0.0.1"
target_port = 10002
h3.send_headers(
stream_id=stream_id,
headers=[
(b":method", b"CONNECT-UDP"),
(b":authority", f"{target_host}:{target_port}".encode()),
],
)
# Send some data over the UDP connection
message = b"Hello from CONNECT-UDP client"
h3.send_data(stream_id, message, end_stream=False)
# Handle incoming events
await asyncio.sleep(1)
for event in protocol.events:
if isinstance(event, HeadersReceived):
print(f"Received headers: {event.headers}")
elif isinstance(event, DataReceived):
print(f"Received data: {event.data.decode()}")
if __name__ == "__main__":
asyncio.run(main())
Please feel free to suggest any other library / option of testing this envoy config @DavidSchinazi @danzh2010 . Can I warp CONNECT-UDP with http3 curl ?
@danzh2010 @DavidSchinazi I tried using masque_client too
./bazel-bin/quiche/masque_client --disable_certificate_verification 127.0.0.1:10001 127.0.0.1:10002
E1116 01:03:07.662913 453146 masque_client.cc:128] Failed to connect. Error: QUIC_NETWORK_IDLE_TIMEOUT
E1116 01:03:07.663169 453146 masque_client_tools.cc:116] Failed to prepare MasqueEncapsulatedClient for 127.0.0.1:10002
envoy error logs
[2024-11-16 01:03:03.655][453085][info][quic] [external/com_github_google_quiche/quiche/quic/core/tls_server_handshaker.cc:982] No hostname indicated in SNI
[2024-11-16 01:03:03.662][453085][debug][http] [source/common/http/conn_manager_impl.cc:393] [Tags: "ConnectionId":"14877056478440268800"] new stream
[2024-11-16 01:03:03.662][453085][debug][quic_stream] [source/common/quic/envoy_quic_server_stream.cc:165] [Tags: "ConnectionId":"14877056478440268800","StreamId":"0"] Received headers: { :method=CONNECT, :protocol=connect-udp, :scheme=https, :authority=127.0.0.1:10001, :path=/.well-known/masque/udp//0/, }.
[2024-11-16 01:03:03.662][453085][debug][http] [source/common/http/conn_manager_impl.cc:1183] [Tags: "ConnectionId":"14877056478440268800","StreamId":"17777896718110749399"] request headers complete (end_stream=false):
':method', 'GET'
':scheme', 'https'
':authority', '127.0.0.1:10001'
':path', '/.well-known/masque/udp//0/'
'upgrade', 'connect-udp'
'connection', 'upgrade'
[2024-11-16 01:03:03.662][453085][warning][misc] [source/common/http/header_utility.cc:383] CONNECT-UDP request with a malformed URI template in the path /.well-known/masque/udp//0/
[2024-11-16 01:03:03.662][453085][debug][http] [source/common/http/filter_manager.cc:1084] [Tags: "ConnectionId":"14877056478440268800","StreamId":"17777896718110749399"] Sending local reply with details invalid_path
[2024-11-16 01:03:03.662][453085][debug][http] [source/common/http/conn_manager_impl.cc:1878] [Tags: "ConnectionId":"14877056478440268800","StreamId":"17777896718110749399"] encoding headers via codec (end_stream=false):
':status', '404'
'content-length', '37'
'content-type', 'text/plain'
'date', 'Sat, 16 Nov 2024 01:03:03 GMT'
'server', 'envoy'
[2024-11-16 01:03:03.662][453085][debug][quic_stream] [source/common/quic/envoy_quic_server_stream.cc:55] [Tags: "ConnectionId":"14877056478440268800","StreamId":"0"] encodeHeaders (end_stream=false) ':status', '404'
'content-length', '37'
'content-type', 'text/plain'
'date', 'Sat, 16 Nov 2024 01:03:03 GMT'
'server', 'envoy'
.
[2024-11-16 01:03:03.662][453085][debug][quic_stream] [source/common/quic/envoy_quic_stream.cc:14] [Tags: "ConnectionId":"14877056478440268800","StreamId":"0"] encodeData (end_stream=true) of 37 bytes.
[2024-11-16 01:03:03.662][453085][debug][http] [source/common/http/conn_manager_impl.cc:1993] [Tags: "ConnectionId":"14877056478440268800","StreamId":"17777896718110749399"] Codec completed encoding stream.
[2024-11-16 01:03:03.662][453085][debug][http] [source/common/http/conn_manager_impl.cc:257] [Tags: "ConnectionId":"14877056478440268800","StreamId":"17777896718110749399"] doEndStream() resetting stream
[2024-11-16 01:03:03.662][453085][debug][http] [source/common/http/conn_manager_impl.cc:1950] [Tags: "ConnectionId":"14877056478440268800","StreamId":"17777896718110749399"] stream reset: reset reason: local reset, response details: -
[2024-11-16 01:03:04.972][453078][debug][main] [source/server/server.cc:237] flushing stats
[2024-11-16 01:03:07.662][453085][debug][quic_stream] [source/common/quic/envoy_quic_server_stream.cc:325] [Tags: "ConnectionId":"14877056478440268800","StreamId":"0"] received STOP_SENDING with reset code=6
[2024-11-16 01:03:07.662][453085][debug][quic_stream] [source/common/quic/envoy_quic_server_stream.cc:352] [Tags: "ConnectionId":"14877056478440268800","StreamId":"0"] received RESET_STREAM with reset code=6
[2024-11-16 01:03:09.973][453078][debug][main] [source/server/server.cc:237] flushing stats
[2024-11-16 01:03:14.974][453078][debug][main] [source/server/server.cc
If you are reporting any crash or any potential security issue, do not open an issue in this repo. Please report the issue via emailing envoy-security@googlegroups.com where the issue will be triaged appropriately.
Title: One line description I have client which sends CONNECT-UDP traffic through an Envoy proxy, which forwards it to an upstream UDP server.
Description:
Envoy configuration
UDP server
Client
Envoy logs