Skip to content

A file sharing CLI tool, based on QR codes and local area network.

Notifications You must be signed in to change notification settings

harshrai654/shareit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ShareIT

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.

Features

  • 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.

How It Works

Components

There are two main components in ShareIT:

  1. shareit.server: The server process that handles file requests.
  2. shareit.cli: The command-line interface for initiating file shares.

Workflow

shareit-workflow

  1. 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"
  2. 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.
  3. Server Initialization:
    • The server starts an HTTP server and a Unix domain socket server.
    • It writes the HTTP port to the server.pid file.
  4. 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.
  5. 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.
  6. Security:
    • JWT tokens mask the file path parameter and ensure that only links generated by the CLI can be used for downloading files.

Installation Instructions

You can download and install the latest CLI and Server executables by running shell script from the command line.

  • For Linux And MacOS

    curl -fsSL https://raw.githubusercontent.com/harshrai654/shareit/main/scripts/install.sh | sh
  • For Windows (Powershell)

    Run the powershell script with admin privileges.

    Invoke-RestMethod -Uri "https://raw.githubusercontent.com/harshrai654/shareit/main/scripts/install.ps1" | Invoke-Expression

Uninstallation Instructions

To uninstall the CLI and Server executables, run the following shell script from the command line.

  • For Linux And MacOS

    curl -fsSL https://raw.githubusercontent.com/harshrai654/shareit/main/scripts/uninstall.sh | sh
  • For Windows (Powershell)

    Run the powershell script with admin privileges.

    Invoke-RestMethod -Uri "https://raw.githubusercontent.com/harshrai654/shareit/main/scripts/uninstall.ps1" | Invoke-Expression

Future Features

  • 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.