Skip to content

Commit b4fae1f

Browse files
committed
Revert " Update go version & add verification/testing tools (#840)"
This reverts commit 666c197.
1 parent 09a6bab commit b4fae1f

39 files changed

+739
-1256
lines changed

.circleci/config.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
version: 2.1
2+
3+
jobs:
4+
"test":
5+
parameters:
6+
version:
7+
type: string
8+
default: "latest"
9+
golint:
10+
type: boolean
11+
default: true
12+
modules:
13+
type: boolean
14+
default: true
15+
goproxy:
16+
type: string
17+
default: ""
18+
docker:
19+
- image: "cimg/go:<< parameters.version >>"
20+
working_directory: /home/circleci/project/go/src/github.com/gorilla/websocket
21+
environment:
22+
GO111MODULE: "on"
23+
GOPROXY: "<< parameters.goproxy >>"
24+
steps:
25+
- checkout
26+
- run:
27+
name: "Print the Go version"
28+
command: >
29+
go version
30+
- run:
31+
name: "Fetch dependencies"
32+
command: >
33+
if [[ << parameters.modules >> = true ]]; then
34+
go mod download
35+
export GO111MODULE=on
36+
else
37+
go get -v ./...
38+
fi
39+
# Only run gofmt, vet & lint against the latest Go version
40+
- run:
41+
name: "Run golint"
42+
command: >
43+
if [ << parameters.version >> = "latest" ] && [ << parameters.golint >> = true ]; then
44+
go get -u golang.org/x/lint/golint
45+
golint ./...
46+
fi
47+
- run:
48+
name: "Run gofmt"
49+
command: >
50+
if [[ << parameters.version >> = "latest" ]]; then
51+
diff -u <(echo -n) <(gofmt -d -e .)
52+
fi
53+
- run:
54+
name: "Run go vet"
55+
command: >
56+
if [[ << parameters.version >> = "latest" ]]; then
57+
go vet -v ./...
58+
fi
59+
- run:
60+
name: "Run go test (+ race detector)"
61+
command: >
62+
go test -v -race ./...
63+
64+
workflows:
65+
tests:
66+
jobs:
67+
- test:
68+
matrix:
69+
parameters:
70+
version: ["1.18", "1.17", "1.16"]

.editorconfig

Lines changed: 0 additions & 20 deletions
This file was deleted.

.github/release-drafter.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Config for https://github.com/apps/release-drafter
2+
template: |
3+
4+
<summary of changes here>
5+
6+
## CHANGELOG
7+
$CHANGES

.gitignore

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,25 @@
1-
coverage.coverprofile
1+
# Compiled Object files, Static and Dynamic libs (Shared Objects)
2+
*.o
3+
*.a
4+
*.so
5+
6+
# Folders
7+
_obj
8+
_test
9+
10+
# Architecture specific extensions/prefixes
11+
*.[568vq]
12+
[568vq].out
13+
14+
*.cgo1.go
15+
*.cgo2.c
16+
_cgo_defun.c
17+
_cgo_gotypes.go
18+
_cgo_export.*
19+
20+
_testmain.go
21+
22+
*.exe
23+
24+
.idea/
25+
*.iml

AUTHORS

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# This is the official list of Gorilla WebSocket authors for copyright
2+
# purposes.
3+
#
4+
# Please keep the list sorted.
5+
6+
Gary Burd <[email protected]>
7+
Google LLC (https://opensource.google.com/)
8+
Joachim Bauch <[email protected]>
9+

LICENSE

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,22 @@
1-
Copyright (c) 2023 The Gorilla Authors. All rights reserved.
1+
Copyright (c) 2013 The Gorilla WebSocket Authors. All rights reserved.
22

33
Redistribution and use in source and binary forms, with or without
4-
modification, are permitted provided that the following conditions are
5-
met:
4+
modification, are permitted provided that the following conditions are met:
65

7-
* Redistributions of source code must retain the above copyright
8-
notice, this list of conditions and the following disclaimer.
9-
* Redistributions in binary form must reproduce the above
10-
copyright notice, this list of conditions and the following disclaimer
11-
in the documentation and/or other materials provided with the
12-
distribution.
13-
* Neither the name of Google Inc. nor the names of its
14-
contributors may be used to endorse or promote products derived from
15-
this software without specific prior written permission.
6+
Redistributions of source code must retain the above copyright notice, this
7+
list of conditions and the following disclaimer.
168

17-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18-
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19-
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20-
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21-
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22-
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24-
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25-
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
9+
Redistributions in binary form must reproduce the above copyright notice,
10+
this list of conditions and the following disclaimer in the documentation
11+
and/or other materials provided with the distribution.
12+
13+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
14+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
17+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
20+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
21+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2722
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Makefile

Lines changed: 0 additions & 34 deletions
This file was deleted.

README.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
# gorilla/websocket
1+
# Gorilla WebSocket
22

3-
![testing](https://github.com/gorilla/websocket/actions/workflows/test.yml/badge.svg)
4-
[![codecov](https://codecov.io/github/gorilla/websocket/branch/main/graph/badge.svg)](https://codecov.io/github/gorilla/websocket)
5-
[![godoc](https://godoc.org/github.com/gorilla/websocket?status.svg)](https://godoc.org/github.com/gorilla/websocket)
6-
[![sourcegraph](https://sourcegraph.com/github.com/gorilla/websocket/-/badge.svg)](https://sourcegraph.com/github.com/gorilla/websocket?badge)
3+
[![GoDoc](https://godoc.org/github.com/gorilla/websocket?status.svg)](https://godoc.org/github.com/gorilla/websocket)
4+
[![CircleCI](https://circleci.com/gh/gorilla/websocket.svg?style=svg)](https://circleci.com/gh/gorilla/websocket)
75

8-
Gorilla WebSocket is a [Go](http://golang.org/) implementation of the [WebSocket](http://www.rfc-editor.org/rfc/rfc6455.txt) protocol.
9-
10-
![Gorilla Logo](https://github.com/gorilla/.github/assets/53367916/d92caabf-98e0-473e-bfbf-ab554ba435e5)
6+
Gorilla WebSocket is a [Go](http://golang.org/) implementation of the
7+
[WebSocket](http://www.rfc-editor.org/rfc/rfc6455.txt) protocol.
118

129

1310
### Documentation

client.go

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,13 @@ import (
1111
"errors"
1212
"fmt"
1313
"io"
14-
14+
"io/ioutil"
1515
"net"
1616
"net/http"
1717
"net/http/httptrace"
1818
"net/url"
1919
"strings"
2020
"time"
21-
22-
"golang.org/x/net/proxy"
2321
)
2422

2523
// ErrBadHandshake is returned when the server response to opening handshake is
@@ -227,7 +225,6 @@ func (d *Dialer) DialContext(ctx context.Context, urlStr string, requestHeader h
227225
k == "Connection" ||
228226
k == "Sec-Websocket-Key" ||
229227
k == "Sec-Websocket-Version" ||
230-
//#nosec G101 (CWE-798): Potential HTTP request smuggling via parameter pollution
231228
k == "Sec-Websocket-Extensions" ||
232229
(k == "Sec-Websocket-Protocol" && len(d.Subprotocols) > 0):
233230
return nil, nil, errors.New("websocket: duplicate header not allowed: " + k)
@@ -293,7 +290,7 @@ func (d *Dialer) DialContext(ctx context.Context, urlStr string, requestHeader h
293290
}
294291
err = c.SetDeadline(deadline)
295292
if err != nil {
296-
c.Close() //#nosec G104 (CWE-703): Errors unhandled
293+
c.Close()
297294
return nil, err
298295
}
299296
return c, nil
@@ -307,7 +304,7 @@ func (d *Dialer) DialContext(ctx context.Context, urlStr string, requestHeader h
307304
return nil, nil, err
308305
}
309306
if proxyURL != nil {
310-
dialer, err := proxy.FromURL(proxyURL, netDialerFunc(netDial))
307+
dialer, err := proxy_FromURL(proxyURL, netDialerFunc(netDial))
311308
if err != nil {
312309
return nil, nil, err
313310
}
@@ -333,9 +330,7 @@ func (d *Dialer) DialContext(ctx context.Context, urlStr string, requestHeader h
333330

334331
defer func() {
335332
if netConn != nil {
336-
// As mentioned in https://github.com/gorilla/websocket/pull/897#issuecomment-1947108098:
337-
// It's safe to ignore the errors for netconn.Close()
338-
netConn.Close() //#nosec G104 (CWE-703): Errors unhandled
333+
netConn.Close()
339334
}
340335
}()
341336

@@ -405,7 +400,7 @@ func (d *Dialer) DialContext(ctx context.Context, urlStr string, requestHeader h
405400
// debugging.
406401
buf := make([]byte, 1024)
407402
n, _ := io.ReadFull(resp.Body, buf)
408-
resp.Body = io.NopCloser(bytes.NewReader(buf[:n]))
403+
resp.Body = ioutil.NopCloser(bytes.NewReader(buf[:n]))
409404
return nil, resp, ErrBadHandshake
410405
}
411406

@@ -423,17 +418,17 @@ func (d *Dialer) DialContext(ctx context.Context, urlStr string, requestHeader h
423418
break
424419
}
425420

426-
resp.Body = io.NopCloser(bytes.NewReader([]byte{}))
421+
resp.Body = ioutil.NopCloser(bytes.NewReader([]byte{}))
427422
conn.subprotocol = resp.Header.Get("Sec-Websocket-Protocol")
428423

429-
netConn.SetDeadline(time.Time{}) //#nosec G104 (CWE-703): Errors unhandled
430-
netConn = nil // to avoid close in defer.
424+
netConn.SetDeadline(time.Time{})
425+
netConn = nil // to avoid close in defer.
431426
return conn, resp, nil
432427
}
433428

434429
func cloneTLSConfig(cfg *tls.Config) *tls.Config {
435430
if cfg == nil {
436-
return &tls.Config{MinVersion: tls.VersionTLS12}
431+
return &tls.Config{}
437432
}
438433
return cfg.Clone()
439434
}

client_server_test.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"errors"
1515
"fmt"
1616
"io"
17+
"io/ioutil"
1718
"log"
1819
"net"
1920
"net/http"
@@ -49,6 +50,7 @@ type cstHandler struct{ *testing.T }
4950
type cstServer struct {
5051
*httptest.Server
5152
URL string
53+
t *testing.T
5254
}
5355

5456
const (
@@ -113,7 +115,7 @@ func (t cstHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
113115
return
114116
}
115117
if _, err = io.Copy(wr, rd); err != nil {
116-
t.Logf("Copy: %v", err)
118+
t.Logf("NextWriter: %v", err)
117119
return
118120
}
119121
if err := wr.Close(); err != nil {
@@ -544,7 +546,7 @@ func TestRespOnBadHandshake(t *testing.T) {
544546

545547
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
546548
w.WriteHeader(expectedStatus)
547-
io.WriteString(w, expectedBody) // nolint:errcheck
549+
io.WriteString(w, expectedBody)
548550
}))
549551
defer s.Close()
550552

@@ -562,7 +564,7 @@ func TestRespOnBadHandshake(t *testing.T) {
562564
t.Errorf("resp.StatusCode=%d, want %d", resp.StatusCode, expectedStatus)
563565
}
564566

565-
p, err := io.ReadAll(resp.Body)
567+
p, err := ioutil.ReadAll(resp.Body)
566568
if err != nil {
567569
t.Fatalf("ReadFull(resp.Body) returned error %v", err)
568570
}
@@ -797,7 +799,7 @@ func TestSocksProxyDial(t *testing.T) {
797799
}
798800
defer c1.Close()
799801

800-
c1.SetDeadline(time.Now().Add(30 * time.Second)) // nolint:errcheck
802+
c1.SetDeadline(time.Now().Add(30 * time.Second))
801803

802804
buf := make([]byte, 32)
803805
if _, err := io.ReadFull(c1, buf[:3]); err != nil {
@@ -836,10 +838,10 @@ func TestSocksProxyDial(t *testing.T) {
836838
defer c2.Close()
837839
done := make(chan struct{})
838840
go func() {
839-
io.Copy(c1, c2) // nolint:errcheck
841+
io.Copy(c1, c2)
840842
close(done)
841843
}()
842-
io.Copy(c2, c1) // nolint:errcheck
844+
io.Copy(c2, c1)
843845
<-done
844846
}()
845847

0 commit comments

Comments
 (0)