LocalGo
A Go implementation of the LocalSend protocol for secure, cross-platform file sharing.

π Features
Core Functionality
- β
Complete LocalSend v2.1 Protocol - Full compatibility with LocalSend ecosystem
- β
Secure File Transfer - HTTPS with self-signed certificates and PIN protection
- β
Multi-Platform Discovery - Multicast UDP + HTTP fallback for reliable device detection
- β
Cross-Platform - Works on Linux, macOS, and Windows
- β
High Performance - Efficient file transfer with progress tracking
π¦ Quick Start
Installation
Option 1: One-command installation (Recommended)
# User installation
./scripts/install.sh
# System-wide with service
sudo ./scripts/install.sh --mode system --service --create-user
Option 2: Manual build
git clone https://github.com/bethropolis/localgo.git
cd localgo
make build
Option 3: Go global install
go install github.com/bethropolis/localgo/cmd/localgo-cli@latest
Basic Usage
# Start server to receive files
localgo-cli serve
# Discover devices on network
localgo-cli discover
# Send a file
localgo-cli send --file document.pdf --to "John's Phone"
# Get help
localgo-cli help
localgo-cli help send
π Usage Guide
Starting the Server
# Basic server (HTTPS on port 53317)
localgo-cli serve
# Custom configuration
localgo-cli serve --port 8080 --http --alias "MyServer" --pin 123456
# With environment variables
export LOCALSEND_ALIAS="File Server"
export LOCALSEND_DOWNLOAD_DIR="/srv/files"
localgo-cli serve
Sending Files
# Send to specific device
localgo-cli send --file presentation.pptx --to "MacBook Pro"
# Send with custom timeout
localgo-cli send --file large-video.mp4 --to "Desktop" --timeout 300
# Send with custom sender alias
localgo-cli send --file report.pdf --to "Office PC" --alias "Mobile Device"
Discovery and Scanning
# Discover devices (multicast)
localgo-cli discover --timeout 10
# Scan network (HTTP)
localgo-cli scan --port 53317
# JSON output for scripting
localgo-cli discover --json | jq '.devices[].alias'
# Quiet mode for automation
localgo-cli scan --quiet --timeout 5
# Show device configuration
localgo-cli info
# JSON format for scripts
localgo-cli info --json
# Check version
localgo-cli version
βοΈ Configuration
Environment Variables
# Device Configuration
LOCALSEND_ALIAS="My Device" # Device name
LOCALSEND_PORT=53317 # Server port
LOCALSEND_DOWNLOAD_DIR="./downloads" # Download directory
LOCALSEND_DEVICE_TYPE="desktop" # Device type
# Network Configuration
LOCALSEND_MULTICAST_GROUP="224.0.0.167" # Multicast address
LOCALSEND_FORCE_HTTP=false # Use HTTP instead of HTTPS
# Security Configuration
LOCALSEND_PIN="123456" # PIN for authentication
LOCALSEND_SECURITY_DIR="./.localgo_security" # Security files location
# Logging Configuration
LOCALSEND_LOG_LEVEL="info" # Log level (debug,info,warn,error)
LOCALSEND_VERBOSE=false # Verbose output
LOCALSEND_NO_COLOR=false # Disable colored output
Configuration File
Create localgo.env:
# Copy example configuration
cp scripts/localgo.env.example localgo.env
# Edit configuration
editor localgo.env
# Use configuration
source localgo.env && localgo-cli serve
Command-Line Flags
Each command supports specific flags:
# Serve command
localgo-cli serve --port 8080 --http --pin 123456 --alias "Server" --dir "/tmp" --verbose
# Send command
localgo-cli send --file data.zip --to "Device" --port 8080 --timeout 60 --alias "Sender"
# Discovery commands
localgo-cli discover --timeout 10 --json --quiet
localgo-cli scan --port 8080 --timeout 15 --json
π§ System Service
Installation
# Install as system service
sudo ./scripts/install.sh --mode system --service --create-user
Service Management
# Enable and start service
sudo systemctl enable localgo
sudo systemctl start localgo
# Check status
sudo systemctl status localgo
# View logs
sudo journalctl -u localgo -f
# Restart service
sudo systemctl restart localgo
Service Configuration
Edit /etc/localgo/localgo.env:
LOCALSEND_ALIAS="File Server"
LOCALSEND_PORT=53317
LOCALSEND_DOWNLOAD_DIR="/srv/localgo/downloads"
LOCALSEND_PIN="secure123"
LOCALSEND_DEVICE_TYPE="server"
π€ Automation & Scripting
JSON Output
Perfect for integration with other tools:
# Get device list
DEVICES=$(localgo-cli scan --json --timeout 5)
echo "$DEVICES" | jq -r '.devices[].alias'
# Check if service is running
localgo-cli info --json | jq -r '.alias + " on port " + (.port|tostring)'
# Monitor file transfers
localgo-cli info --json | jq '.downloadDir'
Batch Operations
# Send multiple files
find /uploads -name "*.pdf" | while read file; do
localgo-cli send --file "$file" --to "PrintServer"
done
# Health check script
#!/bin/bash
if localgo-cli info --json >/dev/null 2>&1; then
echo "LocalGo is healthy"
exit 0
else
echo "LocalGo is not responding"
exit 1
fi
Docker Integration
FROM golang:1.19-alpine AS builder
WORKDIR /app
COPY . .
RUN make build
FROM alpine:latest
RUN apk --no-cache add ca-certificates
WORKDIR /root/
COPY --from=builder /app/localgo-cli .
COPY scripts/localgo.env.example localgo.env
CMD ["./localgo-cli", "serve"]
π» Development
Building
# Build binary
make build
# Run tests
make test
# Run with coverage
make test-coverage
# Clean build artifacts
make clean
Project Structure
localgo/
βββ cmd/localgo-cli/ # CLI application entry point
βββ pkg/ # Core library packages
β βββ cli/ # CLI output utilities
β βββ config/ # Configuration management
β βββ crypto/ # TLS certificates and fingerprints
β βββ discovery/ # Network discovery (multicast + HTTP)
β βββ httputil/ # HTTP response utilities
β βββ logging/ # Structured logging
β βββ model/ # Data structures (Device, File, DTOs)
β βββ network/ # Network interface utilities
β βββ send/ # File sending logic
β βββ server/ # HTTP server and handlers
β βββ storage/ # File storage management
βββ scripts/ # Installation and utility scripts
βββ protocol/ # LocalSend protocol specification
βββ downloads/ # Default download directory
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests:
make test
- Submit a pull request
π Examples
# Configure as media server
export LOCALSEND_ALIAS="Home Media Server"
export LOCALSEND_DOWNLOAD_DIR="/media/shared"
export LOCALSEND_DEVICE_TYPE="server"
export LOCALSEND_PIN="family123"
# Install as system service
sudo ./scripts/install.sh --mode system --service --create-user
# Start service
sudo systemctl start localgo
Development Setup
# Configure for development
export LOCALSEND_ALIAS="Dev-$(whoami)"
export LOCALSEND_PORT=8080
export LOCALSEND_FORCE_HTTP=true
export LOCALSEND_VERBOSE=true
export LOCALSEND_LOG_LEVEL="debug"
# Start with verbose logging
localgo-cli serve --verbose
CI/CD Integration
# GitHub Actions example
- name: Test file transfer
run: |
# Start receiver
localgo-cli serve --http --port 8080 &
sleep 2
# Send test file
echo "test data" > test.txt
localgo-cli send --file test.txt --to "$(localgo-cli info --json | jq -r '.alias')"
# Verify transfer
test -f downloads/test.txt
Network Monitoring
#!/bin/bash
# Monitor LocalGo devices on network
while true; do
echo "=== LocalGo Network Scan $(date) ==="
localgo-cli scan --json --timeout 10 | jq -r '
.devices[] |
"\(.alias) (\(.deviceType)) - \(.ip):\(.port) - \(.protocol)"
'
echo
sleep 60
done
π οΈ Troubleshooting
Common Issues
Port already in use:
# Check what's using the port
sudo netstat -tlnp | grep 53317
# Use different port
localgo-cli serve --port 8080
Discovery not working:
# Check firewall
sudo ufw status
# Test network connectivity
localgo-cli scan --timeout 10
# Use HTTP discovery
localgo-cli scan --json
Permission denied:
# Fix download directory permissions
sudo chown -R $USER:$USER ~/Downloads/LocalGo
# Check service user permissions (systemd)
sudo journalctl -u localgo -n 50
Debug Mode
# Enable verbose logging
localgo-cli serve --verbose
# Debug network issues
export LOCALSEND_LOG_LEVEL="debug"
localgo-cli discover
π Protocol Compliance
LocalGo implements the complete LocalSend v2.1 protocol:
- β
Discovery API -
/api/localsend/v2/register, /api/localsend/v2/info
- β
Upload API -
/api/localsend/v2/prepare-upload, /api/localsend/v2/upload
- β
Download API -
/api/localsend/v2/prepare-download, /api/localsend/v2/download
- β
Session Management - Proper session handling with tokens and timeouts
- β
Security - TLS encryption, fingerprint validation, PIN protection
- β
Discovery - Multicast UDP announcements with HTTP fallback
π License
MIT License - see LICENSE file for details.
π Acknowledgments
thank you