
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
node-ping-rs
Advanced tools
A high-performance ping utility for Node.js built with Rust and napi-rs, supporting both single ping operations.
⚠️ Important: This library requires special permissions on Linux/macOS. See Permission Requirements section.
npm install node-ping-rs
sudo setcap cap_net_raw+ep $(which node)
import { ping } from 'node-ping-rs';
const result = await ping('google.com');
console.log(result.success); // true
import { ping } from 'node-ping-rs';
async function example() {
try {
const result = await ping('google.com');
console.log(result);
// {
// host: 'google.com',
// ip: '142.250.191.14',
// bytes: 56,
// icmp_seq: 1,
// ttl: 116,
// time: 12.5,
// success: true,
// error: null
// }
} catch (error) {
console.error('Ping failed:', error);
}
}
This library requires special permissions to send ICMP packets on most systems.
On Unix-like systems, ICMP sockets require elevated privileges. Choose one of the following approaches:
# Grant raw socket capabilities to Node.js
sudo setcap cap_net_raw+ep $(which node)
# Verify the capability was set
getcap $(which node)
# Should output: /path/to/node = cap_net_raw+ep
💡 Quick Check: Use our permission checker script:
# Download and run the permission checker
curl -s https://raw.githubusercontent.com/luckyyyyy/node-ping-rs/main/scripts/check-permissions.sh | bash
# Or if you've cloned the repo:
./scripts/check-permissions.sh
sudo node your-app.js
# Temporarily (until reboot)
sudo sysctl -w net.ipv4.ping_group_range="0 2147483647"
# Permanently
echo 'net.ipv4.ping_group_range = 0 2147483647' | sudo tee -a /etc/sysctl.conf
sudo sysctl -p
FROM node:18
# Add NET_RAW capability
# docker run --cap-add=NET_RAW your-image
On Windows, no special permissions are required as the library uses the system's ping functionality.
--cap-add=NET_RAW capability instead of running as rootAmbientCapabilities=CAP_NET_RAWping(host: string): Promise<PingResult>Performs a single ping operation.
Parameters:
host - The hostname or IP address to pingReturns: Promise that resolves to a PingResult object
PingResultinterface PingResult {
host: string; // Original hostname
ip: string; // Resolved IP address
bytes: number; // Payload size in bytes
icmp_seq: number; // ICMP sequence number
ttl?: number; // Time to live
time: number; // Round-trip time in milliseconds
success: boolean; // Whether the ping was successful
error?: string; // Error message if unsuccessful
}
The library handles various error conditions:
# Ubuntu/Debian
sudo apt-get install build-essential
# CentOS/RHEL/Fedora
sudo yum groupinstall "Development Tools"
# Install Xcode Command Line Tools
xcode-select --install
# Clone the repository
git clone https://github.com/luckyyyyy/node-ping-rs.git
cd node-ping-rs
# Install dependencies
yarn install
# Build the native module
yarn build
# Run tests
yarn test
# Run benchmarks
yarn bench
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
And you will see:
$ ava --verbose
✔ sync function from native code
✔ sleep function from native code (201ms)
─
2 tests passed
✨ Done in 1.12s.
Ensure you have set your NPM_TOKEN in the GitHub project setting.
In Settings -> Secrets, add NPM_TOKEN into it.
When you want to release the package:
npm version [<newversion> | major | minor | patch | premajor | preminor | prepatch | prerelease [--preid=<prerelease-id>] | from-git]
git push
GitHub actions will do the rest job for you.
FAQs
A high-performance ping utility for Node.js built with Rust and napi-rs
We found that node-ping-rs demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.