Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: coder/websocket
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.8.5
Choose a base ref
...
head repository: coder/websocket
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Loading
Showing with 4,382 additions and 2,091 deletions.
  1. +0 −1 .github/CODEOWNERS
  2. +0 −1 .github/FUNDING.yml
  3. +24 −0 .github/dependabot.yml
  4. +59 −0 .github/workflows/ci.yml
  5. +66 −0 .github/workflows/daily.yml
  6. +52 −0 .github/workflows/static.yml
  7. +0 −1 .gitignore
  8. +0 −40 .travis.yml
  9. +13 −21 LICENSE.txt
  10. +15 −4 Makefile
  11. +57 −27 README.md
  12. +92 −83 accept.go
  13. +0 −20 accept_js.go
  14. +219 −53 accept_test.go
  15. +99 −24 autobahn_test.go
  16. +20 −0 ci/bench.sh
  17. +0 −23 ci/ensure_fmt.sh
  18. +0 −22 ci/fmt.mk
  19. +25 −0 ci/fmt.sh
  20. +0 −16 ci/lint.mk
  21. +36 −0 ci/lint.sh
  22. +0 −17 ci/test.mk
  23. +36 −0 ci/test.sh
  24. +266 −0 close.go
  25. +0 −211 close_notjs.go
  26. +2 −1 close_test.go
  27. +219 −25 compress.go
  28. +0 −181 compress_notjs.go
  29. +30 −2 compress_test.go
  30. +294 −0 conn.go
  31. +0 −265 conn_notjs.go
  32. +434 −80 conn_test.go
  33. +86 −25 dial.go
  34. +204 −28 dial_test.go
  35. +10 −8 doc.go
  36. +32 −59 example_test.go
  37. +0 −18 examples/chat/go.sum
  38. +0 −160 examples/echo/main.go
  39. +18 −2 export_test.go
  40. +3 −124 frame.go
  41. +7 −92 frame_test.go
  42. +2 −13 go.mod
  43. +0 −18 go.sum
  44. +33 −0 hijack.go
  45. +38 −0 hijack_go120_test.go
  46. +5 −4 internal/bpool/bpool.go
  47. 0 { → internal}/examples/README.md
  48. +6 −4 { → internal}/examples/chat/README.md
  49. +30 −15 { → internal}/examples/chat/chat.go
  50. +2 −4 { → internal}/examples/chat/chat_test.go
  51. +4 −4 { → internal}/examples/chat/index.css
  52. +2 −2 { → internal}/examples/chat/index.html
  53. +18 −18 { → internal}/examples/chat/index.js
  54. +2 −2 { → internal}/examples/chat/main.go
  55. +21 −0 internal/examples/echo/README.md
  56. +61 −0 internal/examples/echo/main.go
  57. +80 −0 internal/examples/echo/server.go
  58. +54 −0 internal/examples/echo/server_test.go
  59. +10 −0 internal/examples/go.mod
  60. +2 −0 internal/examples/go.sum
  61. +13 −14 internal/test/assert/assert.go
  62. +5 −6 internal/test/wstest/echo.go
  63. +4 −2 internal/test/wstest/pipe.go
  64. +6 −0 internal/test/xrand/xrand.go
  65. +2 −0 internal/thirdparty/doc.go
  66. +134 −0 internal/thirdparty/frame_test.go
  67. +75 −0 internal/thirdparty/gin_test.go
  68. +45 −0 internal/thirdparty/go.mod
  69. +110 −0 internal/thirdparty/go.sum
  70. +15 −0 internal/util/util.go
  71. +1 −2 internal/wsjs/wsjs_js.go
  72. +2 −1 internal/xsync/go.go
  73. +1 −1 internal/xsync/go_test.go
  74. +0 −23 internal/xsync/int64.go
  75. +30 −0 main_test.go
  76. +128 −0 mask.go
  77. +127 −0 mask_amd64.s
  78. +72 −0 mask_arm64.s
  79. +26 −0 mask_asm.go
  80. +11 −0 mask_asm_test.go
  81. +7 −0 mask_go.go
  82. +73 −0 mask_test.go
  83. +119 −51 netconn.go
  84. +11 −0 netconn_js.go
  85. +20 −0 netconn_notjs.go
  86. +140 −73 read.go
  87. +89 −83 write.go
  88. +242 −23 ws_js.go
  89. +19 −3 ws_js_test.go
  90. +14 −18 wsjson/wsjson.go
  91. +53 −0 wsjson/wsjson_test.go
  92. +0 −73 wspb/wspb.go
1 change: 0 additions & 1 deletion .github/CODEOWNERS

This file was deleted.

1 change: 0 additions & 1 deletion .github/FUNDING.yml

This file was deleted.

24 changes: 24 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: 2
updates:
# Track in case we ever add dependencies.
- package-ecosystem: 'gomod'
directory: '/'
schedule:
interval: 'weekly'
commit-message:
prefix: 'chore'

# Keep example and test/benchmark deps up-to-date.
- package-ecosystem: 'gomod'
directories:
- '/internal/examples'
- '/internal/thirdparty'
schedule:
interval: 'monthly'
commit-message:
prefix: 'chore'
labels: []
groups:
internal-deps:
patterns:
- '*'
59 changes: 59 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: ci
on:
push:
branches:
- master
pull_request:
branches:
- master
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true

jobs:
fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: ./go.mod
- run: make fmt

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: go version
- uses: actions/setup-go@v5
with:
go-version-file: ./go.mod
- run: make lint

test:
runs-on: ubuntu-latest
steps:
- name: Disable AppArmor
if: runner.os == 'Linux'
run: |
# Disable AppArmor for Ubuntu 23.10+.
# https://chromium.googlesource.com/chromium/src/+/main/docs/security/apparmor-userns-restrictions.md
echo 0 | sudo tee /proc/sys/kernel/apparmor_restrict_unprivileged_userns
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: ./go.mod
- run: make test
- uses: actions/upload-artifact@v4
with:
name: coverage.html
path: ./ci/out/coverage.html

bench:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: ./go.mod
- run: make bench
66 changes: 66 additions & 0 deletions .github/workflows/daily.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: daily
on:
workflow_dispatch:
schedule:
- cron: '42 0 * * *' # daily at 00:42
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true

jobs:
bench:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: ./go.mod
- run: AUTOBAHN=1 make bench
test:
runs-on: ubuntu-latest
steps:
- name: Disable AppArmor
if: runner.os == 'Linux'
run: |
# Disable AppArmor for Ubuntu 23.10+.
# https://chromium.googlesource.com/chromium/src/+/main/docs/security/apparmor-userns-restrictions.md
echo 0 | sudo tee /proc/sys/kernel/apparmor_restrict_unprivileged_userns
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: ./go.mod
- run: AUTOBAHN=1 make test
- uses: actions/upload-artifact@v4
with:
name: coverage.html
path: ./ci/out/coverage.html
bench-dev:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: dev
- uses: actions/setup-go@v5
with:
go-version-file: ./go.mod
- run: AUTOBAHN=1 make bench
test-dev:
runs-on: ubuntu-latest
steps:
- name: Disable AppArmor
if: runner.os == 'Linux'
run: |
# Disable AppArmor for Ubuntu 23.10+.
# https://chromium.googlesource.com/chromium/src/+/main/docs/security/apparmor-userns-restrictions.md
echo 0 | sudo tee /proc/sys/kernel/apparmor_restrict_unprivileged_userns
- uses: actions/checkout@v4
with:
ref: dev
- uses: actions/setup-go@v5
with:
go-version-file: ./go.mod
- run: AUTOBAHN=1 make test
- uses: actions/upload-artifact@v4
with:
name: coverage-dev.html
path: ./ci/out/coverage.html
52 changes: 52 additions & 0 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: static

on:
push:
branches: ['master']
workflow_dispatch:

# Set permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages.
permissions:
contents: read
pages: write
id-token: write

concurrency:
group: pages
cancel-in-progress: true

jobs:
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Disable AppArmor
if: runner.os == 'Linux'
run: |
# Disable AppArmor for Ubuntu 23.10+.
# https://chromium.googlesource.com/chromium/src/+/main/docs/security/apparmor-userns-restrictions.md
echo 0 | sudo tee /proc/sys/kernel/apparmor_restrict_unprivileged_userns
- name: Checkout
uses: actions/checkout@v4
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: ./go.mod
- name: Generate coverage and badge
run: |
make test
mkdir -p ./ci/out/static
cp ./ci/out/coverage.html ./ci/out/static/coverage.html
percent=$(go tool cover -func ./ci/out/coverage.prof | tail -n1 | awk '{print $3}' | tr -d '%')
wget -O ./ci/out/static/coverage.svg "https://img.shields.io/badge/coverage-${percent}%25-success"
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./ci/out/static/
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
1 change: 0 additions & 1 deletion .gitignore

This file was deleted.

40 changes: 0 additions & 40 deletions .travis.yml

This file was deleted.

34 changes: 13 additions & 21 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
MIT License

Copyright (c) 2018 Anmol Sethi

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Copyright (c) 2025 Coder

Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 changes: 15 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
.PHONY: all
all: fmt lint test

.SILENT:
.PHONY: fmt
fmt:
./ci/fmt.sh

include ci/fmt.mk
include ci/lint.mk
include ci/test.mk
.PHONY: lint
lint:
./ci/lint.sh

.PHONY: test
test:
./ci/test.sh

.PHONY: bench
bench:
./ci/bench.sh
Loading