denisenkom / go-mssqldb

Microsoft SQL server driver written in go language
BSD 3-Clause "New" or "Revised" License
1.82k stars 500 forks source link

Add connection logging to help with debugging #626

Open wrosenuance opened 3 years ago

wrosenuance commented 3 years ago

While debugging connection problems it can be helpful to look at the TDS traffic, ideally the unencrypted traffic if encryption is enabled. This patch adds a connection logger that emits the encrypted and unencrypted packets as a hex dump, and also supports the TLS_LOG_KEY_FILE needed for TLS interception in tools like Wireshark.

Split out of #547 where it was first used/relevant.

wrosenuance commented 3 years ago

Hi @kardianos, this is the second piece of #547 - a self-contained patch around adding in connection logging.

kardianos commented 3 years ago

Great to see it, but I want to wait until the first one is settled a bit more.

codecov[bot] commented 3 years ago

Codecov Report

Merging #626 (768b5e3) into master (045585d) will decrease coverage by 0.05%. The diff coverage is 78.68%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #626      +/-   ##
==========================================
- Coverage   71.98%   71.92%   -0.06%     
==========================================
  Files          24       25       +1     
  Lines        5469     5529      +60     
==========================================
+ Hits         3937     3977      +40     
- Misses       1309     1322      +13     
- Partials      223      230       +7     
Impacted Files Coverage Δ
conn_str.go 99.18% <25.00%> (-0.82%) :arrow_down:
tds.go 66.54% <33.33%> (-1.06%) :arrow_down:
log_conn.go 100.00% <100.00%> (ø)
token.go 60.28% <0.00%> (-0.64%) :arrow_down:

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 045585d...768b5e3. Read the comment docs.