Skip to content

Commit 56f6425

Browse files
committed
feat!: drop support for Node.js <=v20 (#22)
BREAKING CHANGE: Node.js <= 20 is no longer supported.
1 parent 5c797fb commit 56f6425

40 files changed

Lines changed: 3073 additions & 819 deletions

.github/workflows/deploy.yml

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,44 +15,43 @@ jobs:
1515
fail-fast: false
1616
matrix:
1717
include:
18-
- os: macos-12
18+
- os: macos-15
1919
label: x64+arm64
2020
node_arch: x64
2121
command: build:gyp
2222
args: --arch x64+arm64
23-
- os: windows-2019
24-
label: x86
25-
node_arch: x86
26-
command: build:gyp
27-
- os: windows-2019
23+
- os: windows-2022
2824
label: x64
2925
node_arch: x64
3026
command: build:gyp
31-
- os: ubuntu-20.04
27+
- os: ubuntu-22.04
28+
label: linux-glibc
29+
command: build:gyp-cross
30+
args: -i almalinux-devtoolset11
31+
- os: ubuntu-22.04
3232
label: alpine
3333
command: build:gyp-cross
34-
args: -i centos7-devtoolset7 -i alpine
35-
- os: ubuntu-20.04
36-
label: armv6+armv7
34+
args: -i alpine
35+
- os: ubuntu-22.04
36+
label: linux-arm
3737
command: build:gyp-cross
38-
args: -i linux-arm64-lts -i linux-armv7 -i linux-armv6
39-
- os: ubuntu-20.04
40-
label: musl+arm64-musl
38+
args: -i linux-arm64 -i linux-armv7 -i linux-armv6
39+
- os: ubuntu-22.04
40+
label: linux-arm-musl
4141
command: build:gyp-cross
42-
args: --tag-libc musl -i linux-arm64-musl
43-
- os: ubuntu-20.04
44-
label: arm64+armv7
42+
args: -i linux-arm64-musl -i linux-armv7l-musl
43+
- os: ubuntu-22.04
44+
label: android-arm
4545
command: build:gyp-cross
4646
args: -i android-arm64 -i android-armv7
4747
steps:
4848
- uses: actions/checkout@v4
4949
with:
5050
ref: ${{ env.TARGET_REF }}
51-
token: ${{ secrets.GPR_TOKEN }}
5251

5352
- uses: actions/setup-node@v4
5453
with:
55-
node-version: 22
54+
node-version: 24
5655
architecture: ${{ matrix.node_arch }}
5756

5857
- name: Install dependencies
@@ -80,15 +79,18 @@ jobs:
8079
deploy:
8180
needs: merge
8281
runs-on: ubuntu-latest
82+
permissions:
83+
contents: read
84+
packages: write
85+
id-token: write
8386
steps:
8487
- uses: actions/checkout@v4
8588
with:
8689
ref: ${{ env.TARGET_REF }}
87-
token: ${{ secrets.GPR_TOKEN }}
8890

8991
- uses: actions/setup-node@v4
9092
with:
91-
node-version: 22
93+
node-version: 24
9294
registry-url: 'https://registry.npmjs.org'
9395

9496
- uses: actions/download-artifact@v4
@@ -100,17 +102,15 @@ jobs:
100102
run: npm ci
101103

102104
- name: Publish to npm
103-
run: npm publish
104-
env:
105-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
105+
run: npm publish --provenance
106106

107107
- uses: actions/setup-node@v4
108108
with:
109-
node-version: 22
109+
node-version: 24
110110
registry-url: 'https://npm.pkg.github.com'
111111
scope: '@NeuraLegion'
112112

113113
- name: Publish to GPR
114114
run: npm publish
115115
env:
116-
NODE_AUTH_TOKEN: ${{ secrets.GPR_TOKEN }}
116+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,18 @@ on:
77

88
jobs:
99
release:
10+
permissions:
11+
contents: write
1012
runs-on: ubuntu-latest
1113
steps:
1214
- uses: actions/checkout@v4
1315
with:
16+
fetch-depth: 0
1417
token: ${{ secrets.GPR_TOKEN }}
1518

1619
- uses: actions/setup-node@v4
1720
with:
18-
node-version: 22
21+
node-version: 24
1922

2023
- run: npm ci --ignore-scripts
2124
- run: npm run semantic-release

.github/workflows/test.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
11+
jobs:
12+
test:
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
os: [ubuntu-latest, macos-latest, windows-latest]
18+
node-version: [20, 22, 23, 24]
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- uses: actions/setup-node@v4
23+
with:
24+
node-version: ${{ matrix.node-version }}
25+
26+
# unfortunately, raw sockets require elevated privileges to run tests, and neither capabilities nor sudo are supported on Linux runners
27+
- name: Set raw socket capability (Linux)
28+
if: runner.os == 'Linux'
29+
run: sudo setcap cap_net_raw,cap_net_admin,cap_net_bind_service+eip $(which node)
30+
31+
- name: Install dependencies
32+
run: npm ci
33+
34+
- name: Build
35+
run: npm run build
36+
37+
- name: Run tests (Mac)
38+
if: runner.os == 'macOS'
39+
run: sudo npm test
40+
41+
- name: Run tests
42+
if: runner.os != 'macOS'
43+
run: npm test

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ build
33
.idea
44
node_modules
55
npm-debug.log
6+
index.cjs*

binding.gyp

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
{
2-
"variables": {
3-
"openssl_fips": "",
4-
"android_ndk_path": ""
5-
},
62
"targets": [
73
{
84
"target_name": "raw_socket",
@@ -12,20 +8,17 @@
128
"include_dirs": [
139
"<!(node -e \"require('nan')\")"
1410
],
11+
"cflags_cc": [
12+
"-std=c++20"
13+
],
1514
"conditions": [
1615
[
1716
"OS==\"mac\"",
1817
{
1918
"xcode_settings": {
20-
"MACOSX_DEPLOYMENT_TARGET": "10.7",
21-
"OTHER_CFLAGS": [
22-
"-arch x86_64",
23-
"-arch arm64"
24-
],
25-
"OTHER_LDFLAGS": [
26-
"-arch x86_64",
27-
"-arch arm64"
28-
]
19+
"MACOSX_DEPLOYMENT_TARGET": "14.0",
20+
"CLANG_CXX_LANGUAGE_STANDARD": "c++20",
21+
"GCC_ENABLE_CPP_EXCEPTIONS": "YES"
2922
}
3023
}
3124
],
@@ -34,7 +27,12 @@
3427
{
3528
"libraries": [
3629
"ws2_32.lib"
37-
]
30+
],
31+
"msvs_settings": {
32+
"VCCLCompilerTool": {
33+
"AdditionalOptions": ["/std:c++20"]
34+
}
35+
}
3836
}
3937
]
4038
]

example/create-checksum.js

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

example/create-checksum.mjs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { createChecksum } from '../index.mjs';
2+
3+
const buffer1 = Buffer.from([
4+
0x08, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0a, 0x09,
5+
0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
6+
0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70
7+
]);
8+
9+
const buffer2 = Buffer.from([
10+
0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x61,
11+
0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69
12+
]);
13+
14+
const option1 = {
15+
buffer: buffer1,
16+
offset: 0,
17+
length: buffer1.length
18+
};
19+
20+
const sum = createChecksum(option1, buffer2);
21+
22+
console.log(sum.toString(16));

example/get-option.js

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

example/get-option.mjs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { Protocol, SocketLevel, SocketOption, createSocket } from '../index.mjs';
2+
3+
if (process.argv.length < 4) {
4+
console.log('node get-option <name> <option>');
5+
process.exit(-1);
6+
}
7+
8+
let level = process.argv[2];
9+
let option = process.argv[3];
10+
11+
level = SocketLevel[level] || parseInt(level, 10);
12+
option = SocketOption[option] || parseInt(option, 10);
13+
14+
const options = {
15+
protocol: Protocol.ICMP
16+
};
17+
18+
const socket = createSocket(options);
19+
20+
const buffer = Buffer.alloc(4096);
21+
const len = socket.getOption(level, option, buffer, buffer.length);
22+
23+
socket.pauseSend().pauseRecv();
24+
25+
console.log(buffer.toString('hex', 0, len));

example/htonl.js

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

0 commit comments

Comments
 (0)