kn-lan-share
v0.2.0
Published
Lightweight HTTP server for local file sharing across your network with QR code access, upload/download capabilities, and smart network detection
Maintainers
Readme
KN-Lan-Share
A lightweight, feature-rich command-line HTTP server for local file sharing and transfer across your network. Password protected by default.
UI Showcase
🚀 Quick Start
# Install globally
npm install -g kn-lan-share
# Start the server
kls -pwd yourpasswordThat's it! Your file server is now running and accessible from any device on your local network.
📋 Table of Contents
📦 Installation
Global Installation (Recommended)
npm install -g kn-lan-shareLocal Development
# Clone the repository
git clone <repository-url>
cd kn-lan-share
# Install dependencies
npm install
# Build the project
npm run build
# Run the server
npm start🎯 Usage
Basic Usage
# Start server on default port (3000)
kls -pwd yourpassword
# The server will display:
# - Server host address
# - Active network interface IP
# - Access URL for other devicesPassword Authentication
Password protection is enabled by default and must be configured when starting the server:
kls -pwd yourpasswordUse any client browser on your local network, enter the password in the page UI, and the app will include it in file requests automatically.
To explicitly disable password protection:
kls -pwd falseWith Custom Port
kls -pwd yourpassword -p 8080With Custom IP Binding
kls -pwd yourpassword -a 192.168.1.100Enable File Uploads
kls -pwd yourpassword -upShow QR Code
kls -pwd yourpassword -qrCombined Options
kls -pwd yourpassword -p 8080 -up -qr🎛️ Command-Line Options
| Flag | Description | Default | Example |
| -------------- | ------------------------------------------------------------- | -------- | -------------------------------------- |
| -pwd <value> | Enable password auth with a password, or disable with false | Required | kls -pwd mysecret / kls -pwd false |
| -p <port> | Custom port number | 3000 | kls -pwd mysecret -p 8080 |
| -a <address> | Bind to specific IP address | 0.0.0.0 | kls -pwd mysecret -a 192.168.1.100 |
| -hw <bytes> | High water mark for streams (1 to 1073741824 bytes) | Default | kls -pwd mysecret -hw 65536 |
| -qr | Display QR code in terminal | false | kls -pwd mysecret -qr |
| -up | Enable file uploads | false | kls -pwd mysecret -up |
🔒 Security Considerations
Upload Protection
By default, file uploads are disabled to protect your system from unauthorized file writes. To enable uploads:
kls -pwd yourpassword -upPassword Protection
The server now requires the -pwd flag on startup. This protects file access by requiring the browser client to send the configured password with requests.
kls -pwd yourpasswordTo disable authentication for trusted environments only:
kls -pwd falseNetwork Exposure
The server binds to 0.0.0.0 by default, making it accessible from any device on your network. To restrict access:
# Bind to localhost only
kls -pwd yourpassword -a 127.0.0.1
# Bind to specific network interface
kls -pwd yourpassword -a 192.168.1.100Recommended Practices
- Always set a strong password with
-pwd - Only use
-pwd falseon trusted networks - Only enable uploads (
-up) when you need to receive files - Use on trusted networks only
- Monitor the terminal for access logs
- Stop the server when not in use
📖 Examples
Example 1: Personal File Server
# Start server with QR code for easy mobile access
kls -pwd mysecret -qrScan the QR code with your phone to instantly access files!
Example 2: custom port with Uploads
# Start on custom port with uploads enabled
kls -pwd mysecret -p 3000 -upShare the URL with your team to both download and upload files.
Example 3: Optimized Streaming
# Start with custom buffer size for large file transfers
kls -pwd mysecret -hw 131072Adjust the high water mark for optimal performance with large files.
Example 4: Development Server
# Bind to localhost only for local testing
kls -pwd mysecret -a 127.0.0.1 -p 3000💻For client
- Client need to enter the password in input given in the top of the page
- To view the entered password double tap on the send button
🤝 Contributing
Contributions are welcome! Please feel free to submit issues or pull requests.
📄 License
ISC License - See LICENSE file for details
👨💻 Author
knkrn5
🙏 Acknowledgments
- Built with Node.js native modules for zero-dependency runtime
- Uses
qrcode-terminalfor QR code generation
Made with ❤️ for easy local file sharing
