Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions dialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,34 @@ func (d *customDialer) writeWARCFromConnection(reqPipe, respPipe *io.PipeReader,
slices.Reverse(batch.Records)
}

var selectedCipherSuite string
var selectedProtocol string

if cc, ok := conn.(*tls.UConn); ok {
state := cc.ConnectionState()
for _, cipherSuite := range tls.CipherSuites() {
// List based on https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml
// example: WARC-Cipher-Suite: TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
if cipherSuite.ID == state.CipherSuite {
selectedCipherSuite = cipherSuite.Name
Comment thread
NGTmeaty marked this conversation as resolved.
Outdated
}
Comment thread
NGTmeaty marked this conversation as resolved.
Outdated
}
// Add the negotiated protocol version
// Values as defined in WARC proposal https://github.com/iipc/warc-specifications/issues/42
switch state.Version {
case tls.VersionSSL30:
selectedProtocol = "ssl/3"
case tls.VersionTLS10:
selectedProtocol = "tls/1.0"
case tls.VersionTLS11:
selectedProtocol = "tls/1.1"
case tls.VersionTLS12:
selectedProtocol = "tls/1.2"
case tls.VersionTLS13:
selectedProtocol = "tls/1.3"
}
Comment on lines +507 to +518
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

In addition to writing a WARC-Protocol value for the encryption used, it could be nice to add support for which HTTP verison was archived to have feature parity with wget-lua:

- http/0.9
- http/1.0
- http/1.1

Not a request for right now, but noted all the same

}

// Get the WARC-Target-URI value
var warcTargetURI = <-warcTargetURIChannel

Expand All @@ -288,6 +316,14 @@ func (d *customDialer) writeWARCFromConnection(reqPipe, respPipe *io.PipeReader,
// Set WARC-Record-ID and WARC-Concurrent-To
r.Header.Set("WARC-Record-ID", "<urn:uuid:"+recordIDs[i]+">")

if selectedCipherSuite != "" {
r.Header.Set("WARC-Cipher-Suite", selectedCipherSuite)
}

if selectedProtocol != "" {
r.Header.Set("WARC-Protocol", selectedProtocol)
}

if i == len(recordIDs)-1 {
r.Header.Set("WARC-Concurrent-To", "<urn:uuid:"+recordIDs[0]+">")
} else {
Expand Down