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

Add support for custom UDP connection identifiers #252

Closed
wants to merge 3 commits into from

Conversation

hasheddan
Copy link
Contributor

@hasheddan hasheddan commented Jul 3, 2023

Description

Adds support for custom UDP connection identifiers. If a ConnIDFn is
provided, the result will be used as the identifier of a connection
rather then the remote address. If a connection already exists for the
remote address, its identifier will be updated to the connection ID. If
the remote address for packets associated with a connection identifier
changes, the remote address of the connection will also be updated.

Signed-off-by: Daniel Mangum [email protected]

Adds unit testing to ensure that a custom UDP connection identifier
results in expected behavior. Testing adheres to the following steps:

  1. Initiate 5 connections using remote address as identifier.
  2. Send message on each connection that results in migration from remote
    address identifier to custom identifier.
  3. Spawn 20 clients, each assigned to send one message on one of the
    connections (total of 4 messages on each connection).
  4. Spawn 5 servers and ensure that each receives the first initiation
    and set messages, then 4 messages, each originating from a different
    remote address.

Signed-off-by: Daniel Mangum [email protected]

Reference issue

Part of pion/dtls#256

@codecov
Copy link

codecov bot commented Jul 3, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.27 🎉

Comparison is base (30cd328) 82.22% compared to head (61d42f9) 82.50%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #252      +/-   ##
==========================================
+ Coverage   82.22%   82.50%   +0.27%     
==========================================
  Files          34       34              
  Lines        3010     3023      +13     
==========================================
+ Hits         2475     2494      +19     
+ Misses        423      419       -4     
+ Partials      112      110       -2     
Flag Coverage Δ
go 82.33% <100.00%> (+0.38%) ⬆️
wasm 74.16% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
udp/conn.go 85.39% <100.00%> (+2.36%) ⬆️

... and 3 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Adds support for custom UDP connection identifiers. If a ConnIDFn is
provided, the result will be used as the identifier of a connection
rather then the remote address. If a connection already exists for the
remote address, its identifier will be updated to the connection ID. If
the remote address for packets associated with a connection identifier
changes, the remote address of the connection will also be updated.

Signed-off-by: Daniel Mangum <[email protected]>
@hasheddan hasheddan force-pushed the udp-custom-keyfunc branch 5 times, most recently from d7c00f7 to 9ed8a05 Compare July 3, 2023 21:40
Adds unit testing to ensure that a custom UDP connection identifier
results in expected behavior. Testing adheres to the following steps:

1. Initiate 5 connections using remote address as identifier.
2. Send message on each connection that results in migration from remote
   address identifier to custom identifier.
3. Spawn 20 clients, each assigned to send one message on one of the
   connections (total of 4 messages on each connection).
4. Spawn 5 servers and ensure that each receives the first initiation
   and set messages, then 4 messages, each originating from a different
   remote address.

Signed-off-by: Daniel Mangum <[email protected]>
Adds Dan Mangum to AUTHORS.txt.

Signed-off-by: Daniel Mangum <[email protected]>
Comment on lines +208 to +212
// If we have a connection associated with this connection ID,
// make sure that the remote address matches.
if conn, ok := l.conns[connID]; ok && conn.RemoteAddr() != raddr {
conn.rAddr = raddr
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am removing this as we should defer updating the remote address of the connection to the conn itself to allow for necessary checks, such as those required for peer address update in the DTLS Connection ID RFC: https://datatracker.ietf.org/doc/html/rfc9146#peer-address-update

However, this is tricky to do today because listener.Accept() just gives us back a net.Conn, which doesn't allow for modifying the internal state of the udp.Conn.

@hasheddan hasheddan marked this pull request as draft July 5, 2023 21:57
Copy link
Contributor Author

@hasheddan hasheddan left a comment

Choose a reason for hiding this comment

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

Converting this to draft for now after chat with @Sean-Der -- most of this functionality will be implemented in pion/dtls.

@stv0g
Copy link
Member

stv0g commented Jul 10, 2023

I agree with @Sean-Der here. Thats a functionality which is better implememented in pion/dtls in my opinion.

@stv0g
Copy link
Member

stv0g commented Aug 2, 2023

@hasheddan Can we close this PR?

@hasheddan
Copy link
Contributor Author

@stv0g sure 👍🏻

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

Successfully merging this pull request may close these issues.

2 participants