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

Perform handshake on first read/write #649

Merged
merged 1 commit into from
Jul 21, 2024
Merged

Perform handshake on first read/write #649

merged 1 commit into from
Jul 21, 2024

Conversation

kevmo314
Copy link
Contributor

@kevmo314 kevmo314 commented Jul 16, 2024

Description

Updates the connection to perform a handshake on first read/write instead of on accept.

Reference issue

#279

@Sean-Der
Copy link
Member

PR looks beautiful to me! Matches Upstream and fixes biggest issue with lib at the moment :)

Copy link

codecov bot commented Jul 19, 2024

Codecov Report

Attention: Patch coverage is 90.56604% with 5 lines in your changes missing coverage. Please review.

Project coverage is 80.08%. Comparing base (bc3159a) to head (3e504d0).

Files Patch % Lines
conn.go 90.38% 3 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #649      +/-   ##
==========================================
- Coverage   80.19%   80.08%   -0.11%     
==========================================
  Files         101      101              
  Lines        5336     5313      -23     
==========================================
- Hits         4279     4255      -24     
- Misses        687      689       +2     
+ Partials      370      369       -1     
Flag Coverage Δ
go 80.11% <90.56%> (-0.11%) ⬇️
wasm 63.88% <84.90%> (-0.01%) ⬇️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@kevmo314 kevmo314 force-pushed the extract-handshake branch 3 times, most recently from 76eb05f to d4b2f07 Compare July 20, 2024 01:03
@kevmo314 kevmo314 marked this pull request as ready for review July 20, 2024 01:07
@kevmo314 kevmo314 requested a review from Sean-Der July 20, 2024 01:07
config.go Outdated Show resolved Hide resolved
conn.go Outdated Show resolved Hide resolved
CipherSuites: []dtls.CipherSuiteID{dtls.TLS_PSK_WITH_AES_128_CCM_8},
ExtendedMasterSecret: dtls.RequireExtendedMasterSecret,
// Create timeout context for accepted connection.
ConnectContextMaker: func() (context.Context, func()) {
Copy link
Member

Choose a reason for hiding this comment

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

Is it easy/possible to do 30 second timeout still with new APIs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, you would essentially call conn.HandshakeContext(<30 second timeout context>) manually before the first read/write. In other words, the sequence of calls would be something like:

for {
  conn := lis.Accept()
  go func() {
    if err := conn.Handshake(<30 second timeout context>); err != nil {
      ...
    }
    // regular read/write stuff
  }()
}

@Sean-Der
Copy link
Member

Damn @kevmo314 really exceptional PR, I am so grateful for your help.

If you are in support I say we delete/break as much as we can now. Since we are doing a major release try to go with zero baggage.

Also would be nice to have zero functionally change in examples. Users can reference them when updating their code.

@kevmo314
Copy link
Contributor Author

Also would be nice to have zero functionally change in examples. Users can reference them when updating their code.

Sounds good, I'll update them to include the timeout context.

@kevmo314 kevmo314 force-pushed the extract-handshake branch from d4b2f07 to f99cd6a Compare July 20, 2024 04:35
Updates the connection to perform a handshake on first read/write
instead of on accept.

Closes #279.
@kevmo314 kevmo314 force-pushed the extract-handshake branch from f99cd6a to 3e504d0 Compare July 20, 2024 04:37
@kevmo314 kevmo314 requested a review from Sean-Der July 20, 2024 04:40
@Sean-Der Sean-Der merged commit e406468 into master Jul 21, 2024
15 of 16 checks passed
@Sean-Der Sean-Der deleted the extract-handshake branch July 21, 2024 02:33
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