Skip to content

Commit

Permalink
fix compatibility with API breaking change in Go 1.21 (#4020)
Browse files Browse the repository at this point in the history
* add Go 1.21 compatibility

Signed-off-by: Eric Lagergren <elagergren@spideroak-inc.com>

* refactor for Go 1.20

Signed-off-by: Eric Lagergren <elagergren@spideroak-inc.com>

---------

Signed-off-by: Eric Lagergren <elagergren@spideroak-inc.com>
  • Loading branch information
elagergren-spideroak committed Aug 9, 2023
1 parent aab4d4e commit 571d3ad
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cross-compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jobs:
strategy:
fail-fast: false
matrix:
go: [ "1.20.x", "1.21.0-rc.3" ]
go: [ "1.20.x", "1.21.x" ]
runs-on: ${{ fromJSON(vars['CROSS_COMPILE_RUNNER_UBUNTU'] || '"ubuntu-latest"') }}
name: "Cross Compilation (Go ${{matrix.go}})"
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
strategy:
fail-fast: false
matrix:
go: [ "1.20.x", "1.21.0-rc.3" ]
go: [ "1.20.x", "1.21.x" ]
runs-on: ${{ fromJSON(vars['INTEGRATION_RUNNER_UBUNTU'] || '"ubuntu-latest"') }}
env:
DEBUG: false # set this to true to export qlogs and save them as artifacts
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
fail-fast: false
matrix:
os: [ "ubuntu", "windows", "macos" ]
go: [ "1.20.x", "1.21.0-rc.3" ]
go: [ "1.20.x", "1.21.x" ]
runs-on: ${{ fromJSON(vars[format('UNIT_RUNNER_{0}', matrix.os)] || format('"{0}-latest"', matrix.os)) }}
name: Unit tests (${{ matrix.os}}, Go ${{ matrix.go }})
steps:
Expand Down
2 changes: 1 addition & 1 deletion internal/handshake/crypto_setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ func (h *cryptoSetup) GetSessionTicket() ([]byte, error) {
if h.tlsConf.SessionTicketsDisabled {
return nil, nil
}
if err := h.conn.SendSessionTicket(h.allow0RTT); err != nil {
if err := qtls.SendSessionTicket(h.conn, h.allow0RTT); err != nil {
return nil, err
}
ev := h.conn.NextEvent()
Expand Down
4 changes: 4 additions & 0 deletions internal/qtls/go120.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,7 @@ func SetCipherSuite(id uint16) (reset func()) {
cipherSuitesModified = false
}
}

func SendSessionTicket(c *QUICConn, allow0RTT bool) error {
return c.SendSessionTicket(allow0RTT)
}
19 changes: 13 additions & 6 deletions internal/qtls/go121.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ import (
)

type (
QUICConn = tls.QUICConn
QUICConfig = tls.QUICConfig
QUICEvent = tls.QUICEvent
QUICEventKind = tls.QUICEventKind
QUICEncryptionLevel = tls.QUICEncryptionLevel
AlertError = tls.AlertError
QUICConn = tls.QUICConn
QUICConfig = tls.QUICConfig
QUICEvent = tls.QUICEvent
QUICEventKind = tls.QUICEventKind
QUICEncryptionLevel = tls.QUICEncryptionLevel
QUICSessionTicketOptions = tls.QUICSessionTicketOptions
AlertError = tls.AlertError
)

const (
Expand Down Expand Up @@ -152,3 +153,9 @@ func findExtraData(extras [][]byte) []byte {
}
return nil
}

func SendSessionTicket(c *QUICConn, allow0RTT bool) error {
return c.SendSessionTicket(tls.QUICSessionTicketOptions{
EarlyData: allow0RTT,
})
}

0 comments on commit 571d3ad

Please sign in to comment.