Skip to content

Commit ba6c24e

Browse files
committed
add MQTT 5.0 subprotocol with enhanced authentication
1 parent 9289320 commit ba6c24e

File tree

1,073 files changed

+119719
-104418
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,073 files changed

+119719
-104418
lines changed

.github/workflows/ci.yml

Lines changed: 509 additions & 0 deletions
Large diffs are not rendered by default.

.github/workflows/release.yml

Lines changed: 281 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,281 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*'
7+
workflow_dispatch:
8+
inputs:
9+
version:
10+
description: 'Release version (e.g., v2.0.0)'
11+
required: true
12+
13+
env:
14+
CFLAGS: "-fcommon"
15+
16+
jobs:
17+
# ===========================================================================
18+
# Create Release
19+
# ===========================================================================
20+
create-release:
21+
name: Create Release
22+
runs-on: ubuntu-latest
23+
outputs:
24+
upload_url: ${{ steps.create_release.outputs.upload_url }}
25+
version: ${{ steps.get_version.outputs.version }}
26+
27+
steps:
28+
- name: Checkout code
29+
uses: actions/checkout@v4
30+
with:
31+
fetch-depth: 0
32+
33+
- name: Get version
34+
id: get_version
35+
run: |
36+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
37+
VERSION="${{ github.event.inputs.version }}"
38+
else
39+
VERSION=${GITHUB_REF#refs/tags/}
40+
fi
41+
echo "version=$VERSION" >> $GITHUB_OUTPUT
42+
echo "Version: $VERSION"
43+
44+
- name: Generate changelog
45+
id: changelog
46+
run: |
47+
# Generate changelog from git log
48+
if [ -f CHANGELOG.md ]; then
49+
# Extract the latest version section
50+
CHANGELOG=$(sed -n "/## \[${VERSION}\]/,/## \[/p" CHANGELOG.md | sed '$d')
51+
else
52+
# Generate from git commits
53+
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
54+
if [ -z "$PREV_TAG" ]; then
55+
CHANGELOG=$(git log --pretty=format:"- %s (%h)" --no-merges)
56+
else
57+
CHANGELOG=$(git log --pretty=format:"- %s (%h)" --no-merges $PREV_TAG..HEAD)
58+
fi
59+
fi
60+
61+
# Save to file for multiline output
62+
echo "$CHANGELOG" > changelog.txt
63+
echo "Changelog generated"
64+
env:
65+
VERSION: ${{ steps.get_version.outputs.version }}
66+
67+
- name: Create Release
68+
id: create_release
69+
uses: actions/create-release@v1
70+
env:
71+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
72+
with:
73+
tag_name: ${{ steps.get_version.outputs.version }}
74+
release_name: Release ${{ steps.get_version.outputs.version }}
75+
body_path: changelog.txt
76+
draft: false
77+
prerelease: false
78+
79+
# ===========================================================================
80+
# Build Release Binaries - Ubuntu
81+
# ===========================================================================
82+
build-ubuntu-release:
83+
name: Build Ubuntu Release
84+
runs-on: ubuntu-latest
85+
needs: create-release
86+
87+
steps:
88+
- name: Checkout code
89+
uses: actions/checkout@v4
90+
91+
- name: Install dependencies
92+
run: |
93+
sudo apt-get update
94+
sudo apt-get install -y \
95+
build-essential \
96+
autoconf \
97+
automake \
98+
libtool \
99+
pkg-config \
100+
libssl-dev \
101+
libev-dev \
102+
zlib1g-dev
103+
104+
- name: Generate build system
105+
run: ./autogen.sh
106+
107+
- name: Configure
108+
run: ./configure
109+
110+
- name: Build
111+
run: make -j$(nproc)
112+
113+
- name: Run tests
114+
run: ./tests-unit
115+
116+
- name: Create release tarball
117+
run: |
118+
VERSION=${{ needs.create-release.outputs.version }}
119+
TARBALL="cwebsocket-${VERSION}-linux-x86_64.tar.gz"
120+
mkdir -p release-package
121+
cp websocket-client websocket-testsuite stomp-client libwsclient.a release-package/
122+
cp README.md LICENSE release-package/ 2>/dev/null || true
123+
tar -czf $TARBALL -C release-package .
124+
echo "TARBALL=$TARBALL" >> $GITHUB_ENV
125+
126+
- name: Upload Release Asset
127+
uses: actions/upload-release-asset@v1
128+
env:
129+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
130+
with:
131+
upload_url: ${{ needs.create-release.outputs.upload_url }}
132+
asset_path: ./${{ env.TARBALL }}
133+
asset_name: ${{ env.TARBALL }}
134+
asset_content_type: application/gzip
135+
136+
# ===========================================================================
137+
# Build Release Binaries - macOS
138+
# ===========================================================================
139+
build-macos-release:
140+
name: Build macOS Release
141+
runs-on: macos-latest
142+
needs: create-release
143+
144+
steps:
145+
- name: Checkout code
146+
uses: actions/checkout@v4
147+
148+
- name: Install dependencies
149+
run: |
150+
brew update || true
151+
brew install \
152+
autoconf \
153+
automake \
154+
libtool \
155+
pkg-config \
156+
openssl@3 \
157+
libev \
158+
zlib
159+
160+
- name: Generate build system
161+
run: ./autogen.sh
162+
163+
- name: Configure
164+
run: |
165+
export PKG_CONFIG_PATH="/usr/local/opt/openssl@3/lib/pkgconfig:$PKG_CONFIG_PATH"
166+
./configure
167+
168+
- name: Build
169+
run: make -j$(sysctl -n hw.ncpu)
170+
171+
- name: Run tests
172+
run: ./tests-unit
173+
174+
- name: Create release tarball
175+
run: |
176+
VERSION=${{ needs.create-release.outputs.version }}
177+
TARBALL="cwebsocket-${VERSION}-macos-x86_64.tar.gz"
178+
mkdir -p release-package
179+
cp websocket-client websocket-testsuite stomp-client libwsclient.a release-package/
180+
cp README.md LICENSE release-package/ 2>/dev/null || true
181+
tar -czf $TARBALL -C release-package .
182+
echo "TARBALL=$TARBALL" >> $GITHUB_ENV
183+
184+
- name: Upload Release Asset
185+
uses: actions/upload-release-asset@v1
186+
env:
187+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
188+
with:
189+
upload_url: ${{ needs.create-release.outputs.upload_url }}
190+
asset_path: ./${{ env.TARBALL }}
191+
asset_name: ${{ env.TARBALL }}
192+
asset_content_type: application/gzip
193+
194+
# ===========================================================================
195+
# Build Docker Image
196+
# ===========================================================================
197+
build-docker-release:
198+
name: Build Docker Release Image
199+
runs-on: ubuntu-latest
200+
needs: create-release
201+
202+
steps:
203+
- name: Checkout code
204+
uses: actions/checkout@v4
205+
206+
- name: Set up Docker Buildx
207+
uses: docker/setup-buildx-action@v3
208+
209+
- name: Login to Docker Hub
210+
if: github.event_name != 'workflow_dispatch'
211+
uses: docker/login-action@v3
212+
with:
213+
username: ${{ secrets.DOCKER_USERNAME }}
214+
password: ${{ secrets.DOCKER_PASSWORD }}
215+
216+
- name: Build and push Docker image
217+
if: github.event_name != 'workflow_dispatch'
218+
uses: docker/build-push-action@v5
219+
with:
220+
context: .
221+
push: true
222+
tags: |
223+
${{ secrets.DOCKER_USERNAME }}/cwebsocket:${{ needs.create-release.outputs.version }}
224+
${{ secrets.DOCKER_USERNAME }}/cwebsocket:latest
225+
226+
# ===========================================================================
227+
# Generate and Upload Documentation
228+
# ===========================================================================
229+
generate-docs:
230+
name: Generate Documentation
231+
runs-on: ubuntu-latest
232+
needs: create-release
233+
234+
steps:
235+
- name: Checkout code
236+
uses: actions/checkout@v4
237+
238+
- name: Create documentation package
239+
run: |
240+
VERSION=${{ needs.create-release.outputs.version }}
241+
mkdir -p docs-package
242+
243+
# Copy all markdown documentation
244+
cp *.md docs-package/ 2>/dev/null || true
245+
246+
# Copy test documentation
247+
cp test/mqtt/*.md docs-package/ 2>/dev/null || true
248+
249+
# Create README for the docs package
250+
cat > docs-package/INDEX.md << 'EOF'
251+
# cwebsocket Documentation
252+
253+
This package contains the complete documentation for cwebsocket.
254+
255+
## Main Documentation
256+
- README.md - Project overview
257+
- CONTRIBUTING.md - Contribution guidelines
258+
- CHANGELOG.md - Version history
259+
260+
## MQTT Documentation
261+
- MQTT_COMPLIANCE.md - MQTT 5.0 compliance status
262+
- MQTT_STATUS.md - Current MQTT implementation status
263+
264+
## Testing Documentation
265+
- Test-specific documentation in test/ directories
266+
EOF
267+
268+
# Create tarball
269+
DOCS_TARBALL="cwebsocket-docs-${VERSION}.tar.gz"
270+
tar -czf $DOCS_TARBALL -C docs-package .
271+
echo "DOCS_TARBALL=$DOCS_TARBALL" >> $GITHUB_ENV
272+
273+
- name: Upload Documentation Asset
274+
uses: actions/upload-release-asset@v1
275+
env:
276+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
277+
with:
278+
upload_url: ${{ needs.create-release.outputs.upload_url }}
279+
asset_path: ./${{ env.DOCS_TARBALL }}
280+
asset_name: ${{ env.DOCS_TARBALL }}
281+
asset_content_type: application/gzip

.pre-commit-config.yaml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Pre-commit hooks configuration
2+
# Install pre-commit: pip install pre-commit
3+
# Install hooks: pre-commit install
4+
5+
repos:
6+
# Basic file checks
7+
- repo: https://github.com/pre-commit/pre-commit-hooks
8+
rev: v4.5.0
9+
hooks:
10+
- id: trailing-whitespace
11+
exclude: '\.patch$'
12+
- id: end-of-file-fixer
13+
exclude: '\.patch$'
14+
- id: check-yaml
15+
- id: check-added-large-files
16+
args: ['--maxkb=1000']
17+
- id: check-merge-conflict
18+
- id: check-case-conflict
19+
- id: mixed-line-ending
20+
21+
# C/C++ formatting with clang-format
22+
- repo: https://github.com/pre-commit/mirrors-clang-format
23+
rev: v17.0.6
24+
hooks:
25+
- id: clang-format
26+
files: \.(c|h)$
27+
exclude: '^(test/|autobahn-reports/)'
28+
29+
# Local hooks for project-specific checks
30+
- repo: local
31+
hooks:
32+
# Build check
33+
- id: build-check
34+
name: Build Check
35+
entry: bash -c 'make clean && ./autogen.sh && ./configure && make -j$(nproc 2>/dev/null || echo 1)'
36+
language: system
37+
pass_filenames: false
38+
stages: [pre-push]
39+
40+
# Unit tests
41+
- id: unit-tests
42+
name: Unit Tests
43+
entry: bash -c 'make tests-unit && ./tests-unit'
44+
language: system
45+
pass_filenames: false
46+
stages: [pre-commit]
47+
48+
# Static analysis with cppcheck
49+
- id: cppcheck
50+
name: Cppcheck Static Analysis
51+
entry: bash -c 'cppcheck --enable=warning --std=c99 --suppress=missingIncludeSystem --error-exitcode=1 -I src/cwebsocket src/cwebsocket/*.c src/*.c 2>&1'
52+
language: system
53+
pass_filenames: false
54+
stages: [pre-commit]
55+
56+
# Security scan with flawfinder
57+
- id: flawfinder
58+
name: Flawfinder Security Scan
59+
entry: bash -c 'flawfinder --quiet --minlevel=2 src/cwebsocket/*.c src/*.c'
60+
language: system
61+
pass_filenames: false
62+
stages: [pre-commit]
63+
64+
# Memory leak check (quick)
65+
- id: valgrind-quick
66+
name: Valgrind Memory Check (Quick)
67+
entry: bash -c 'valgrind --leak-check=yes --error-exitcode=1 --errors-for-leak-kinds=definite ./tests-unit'
68+
language: system
69+
pass_filenames: false
70+
stages: [pre-push]

LICENSE

100755100644
File mode changed.

0 commit comments

Comments
 (0)