mirror of
https://github.com/soheilhy/cmux.git
synced 2026-08-22 05:00:47 +08:00
Modernize for current Go toolchains
The library already compiled and passed tests, but tooling and dependencies were stale. This brings everything up to current standards without changing public behavior. Library (go 1.23.0): - cmux_test.go: fix 8 `go vet` failures by sending writer-goroutine errors to the existing errCh (now buffered) instead of t.Fatal; ioutil.ReadAll -> io.ReadAll - matchers.go: io/ioutil -> io (io.Discard); gofmt -s doc comment - go.mod: go 1.11 -> 1.23.0; golang.org/x/net -> v0.42.0 (newest release that still permits a 1.23 directive) Example submodule: - golang.org/x/net/context -> stdlib context - grpc v1.27.0 -> v1.80, modern protobuf; helloworld now comes from the separate google.golang.org/grpc/examples module (requires go 1.25, isolated to this demo-only module) CI: - remove ancient .travis.yml (Go 1.6-1.8) - add .github/workflows/ci.yml: gofmt/vet/build/test -race for the library (Go 1.23 + 1.24 matrix) and the example Temporary() methods and TLS version defaults are intentionally unchanged: net.Error still requires Temporary(), and the TLS defaults are public-API behavior. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -18,7 +18,6 @@ import (
|
||||
"bufio"
|
||||
"crypto/tls"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
@@ -67,7 +66,8 @@ func HTTP1Fast(extMethods ...string) Matcher {
|
||||
//
|
||||
// By default, any TLS handshake packet is matched. An optional whitelist
|
||||
// of versions can be passed in to restrict the matcher, for example:
|
||||
// TLS(tls.VersionTLS11, tls.VersionTLS12)
|
||||
//
|
||||
// TLS(tls.VersionTLS11, tls.VersionTLS12)
|
||||
func TLS(versions ...int) Matcher {
|
||||
if len(versions) == 0 {
|
||||
versions = []int{
|
||||
@@ -148,7 +148,7 @@ func HTTP1HeaderFieldPrefix(name, valuePrefix string) Matcher {
|
||||
// headers frame.
|
||||
func HTTP2HeaderField(name, value string) Matcher {
|
||||
return func(r io.Reader) bool {
|
||||
return matchHTTP2Field(ioutil.Discard, r, name, func(gotValue string) bool {
|
||||
return matchHTTP2Field(io.Discard, r, name, func(gotValue string) bool {
|
||||
return gotValue == value
|
||||
})
|
||||
}
|
||||
@@ -159,7 +159,7 @@ func HTTP2HeaderField(name, value string) Matcher {
|
||||
// valuePrefix, this will match.
|
||||
func HTTP2HeaderFieldPrefix(name, valuePrefix string) Matcher {
|
||||
return func(r io.Reader) bool {
|
||||
return matchHTTP2Field(ioutil.Discard, r, name, func(gotValue string) bool {
|
||||
return matchHTTP2Field(io.Discard, r, name, func(gotValue string) bool {
|
||||
return strings.HasPrefix(gotValue, valuePrefix)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user