WireGuard Utils
A powerful TypeScript library for programmatically managing WireGuard VPN configurations. Generate keys, manage peers, and control interfaces with simple, intuitive APIs.
✨ Features
🔑 Key Management
Generate WireGuard key pairs securely with built-in key generation utilities.
⚙️ Configuration Management
Parse, modify, and stringify WireGuard configuration files with ease.
👥 Peer Management
Add and remove peers automatically with intelligent IP assignment.
🔌 Interface Control
Start and stop WireGuard interfaces programmatically.
🛡️ Type Safety
Built with TypeScript for full type safety and excellent IDE support.
⚡ Easy to Use
Simple, intuitive APIs that make WireGuard management effortless.
🚀 Quick Start
import { generateKeys, initConf, addPeer, up } from "@kriper0nind/wg-utils"
async function setupVPN() {
// Generate server keys
const serverKeys = await generateKeys()
// Create server configuration
await initConf("/etc/wireguard/wg0.conf", {
privateKey: serverKeys.privateKey,
port: 51820,
ip: "10.0.0.1"
})
// Add a client
const clientKeys = await generateKeys()
const result = await addPeer("/etc/wireguard/wg0.conf", {
publicKey: clientKeys.publicKey
})
// Start the VPN
await up("wg0")
console.log(`Client IP: ${result.ip}`)
}📖 What's Inside
Configuration Parsing
Parse WireGuard configs into JavaScript objects
Peer Management
Add and remove peers with automatic IP assignment
Key Generation
Generate secure WireGuard key pairs
Interface Control
Start and stop WireGuard interfaces
Configuration Creation
Create initial server configurations
TypeScript Support
Full TypeScript definitions included
🎯 Perfect For
🏢 Enterprise VPN Management
🛠️ DevOps Automation
🔧 Configuration Tools
📱 Mobile App Backends
☁️ Cloud Infrastructure
📊 Stats
🚀 Ready to Get Started?
Start building with WireGuard Utils today!
Join developers who are already using our library to manage their VPN infrastructure.