ShareIT is a command-line tool written in Go that enables easy file sharing from a laptop or PC to mobile devices over the same local area network using QR codes.
- Seamless File Sharing: Share files quickly and securely within the same local network.
- Cross-Platform Compatibility: Supports macOS, Linux, and Windows.
- QR Code Generation: Automatically generates a QR code for easy file access on mobile devices.
- JWT Token Security: Ensures secure file transfer using JWT tokens.
- Pause and Resume: Supports content-range headers for pausing and resuming downloads.
- Automatic Server Management: CLI tool manages the server process, including starting and stopping the server as needed.
There are two main components in ShareIT:
- shareit.server: The server process that handles file requests.
- shareit.cli: The command-line interface for initiating file shares.
- CLI Command Execution:
To share a file to devices in the local network you will need the Absolute address of the file in the local machine.
shareit.cli.<darwin|linux|windows>[.exe] -filepath "/path/to/file"
- File and Server Validation:
- The CLI checks the validity of the file path.
- It checks if the server process is running by attempting a TCP dial-up.
- If the server process is not running, the CLI starts the server in a new process.
- The CLI reads the server.pid file to get the server's HTTP port. If the file is missing or the dial-up fails, the CLI starts a new server process.
- Server Initialization:
- The server starts an HTTP server and a Unix domain socket server.
- It writes the HTTP port to the server.pid file.
- File Sharing Process:
- The CLI fetches the local IP of all network interfaces.
- It generates a random secret and creates a JWT token with the file path as the payload.
- The CLI shares the secret with the server via a Unix socket along with the file path. Each file share generates a unique secret.
- The CLI appends the local IP and port to the token and generates a QR code from this string, displaying it in the terminal.
- Mobile Device Access:
- Scanning the QR code on a mobile device sends a request to the server with the token value.
- The server decodes the token using the secret to verify the request's authenticity.
- The server reads the file from the given file path and provides it for download.
- The server supports pause and resume functionality through content-range headers.
- Security:
- JWT tokens mask the file path parameter and ensure that only links generated by the CLI can be used for downloading files.
You can download and install the latest CLI and Server executables by running shell script from the command line.
-
curl -fsSL https://raw.githubusercontent.com/harshrai654/shareit/main/scripts/install.sh | sh
-
Run the powershell script with admin privileges.
Invoke-RestMethod -Uri "https://raw.githubusercontent.com/harshrai654/shareit/main/scripts/install.ps1" | Invoke-Expression
To uninstall the CLI and Server executables, run the following shell script from the command line.
-
curl -fsSL https://raw.githubusercontent.com/harshrai654/shareit/main/scripts/uninstall.sh | sh
-
Run the powershell script with admin privileges.
Invoke-RestMethod -Uri "https://raw.githubusercontent.com/harshrai654/shareit/main/scripts/uninstall.ps1" | Invoke-Expression
- Context Menu Action : Add a context menu action to share files.
- Basic Authentication: Share a user-entered password along with the JWT secret for basic authentication before file download.
- Auto Termination: Automatically terminate the server process after a period of idle behavior to prevent resource leaks.