yarpc / yarpc-go

A message passing platform for Go
MIT License
401 stars 101 forks source link

[2/n] tlsmux: add TLS client hello detector #2132

Closed jronak closed 2 years ago

jronak commented 2 years ago

This pull request adds a method for identifying when the reader (net.Conn) contains a TLS client hello header record in the initial bytes. Refer (TLS spec)[https://datatracker.ietf.org/doc/html/rfc8446#section-5.1] for detection logic. In simple words: 1) read 5 bytes (TLS record header length) 2) assert the first byte is handshake type = 22 3) assert the second byte is major version = 3 (TLS) 4) assert the third byte is minor version >= 1 (TLS 1.0= 1, ... TLS 1.3 = 4)

codecov[bot] commented 2 years ago

Codecov Report

Merging #2132 (d8d9f1b) into dev (859a3e7) will increase coverage by 0.02%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##              dev    #2132      +/-   ##
==========================================
+ Coverage   87.68%   87.70%   +0.02%     
==========================================
  Files         250      251       +1     
  Lines       14031    14041      +10     
==========================================
+ Hits        12303    12315      +12     
+ Misses       1338     1337       -1     
+ Partials      390      389       -1     
Impacted Files Coverage Δ
transport/internal/tlsmux/tls_checker.go 100.00% <100.00%> (ø)
peer/hashring32/internal/hashring32/hashring32.go 97.29% <0.00%> (+1.08%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 859a3e7...d8d9f1b. Read the comment docs.

jkanywhere commented 2 years ago

Looks good. Thanks for correcting. Two minor comments about the test.