Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LANShare

A lightweight, single-binary web app for sharing files and messages across computers on the same LAN. Built for lab environments where you need quick file transfers and messaging between multiple machines without any setup.

Open a browser on any machine → drop files, send messages, done.

Features

  • Slack-style unified feed — chat messages and file uploads appear in the same timeline
  • File sharing — upload/download files through the browser, with optional per-file password protection
  • Real-time chat — instant messaging via WebSocket, no page refresh needed
  • Private transfers — drag a file onto a device name in the sidebar to send it directly (only the recipient sees it)
  • Device discovery — automatically shows all connected browsers in a sidebar
  • Dark mode — follows system preference
  • Zero config — single binary, no database, no accounts, no login
  • Embedded UI — all HTML/CSS/JS baked into the binary via go:embed

Quick Start

# Build
go build -o lanshare.exe .

# Run with defaults (port 8080, files saved to ./shared)
./lanshare.exe

# Or customize
./lanshare.exe --port 3000 --dir /path/to/shared/folder

Then open http://<your-lan-ip>:8080 from any machine on the network. The server prints the correct URL on startup.

Usage

Chat

Type a message in the input box at the bottom and press Enter or click Send.

Share a file

Click the 📎 button (or drag a file onto the feed area) to attach a file. Optionally check "Set password" to protect it. Click Send. The file appears in the feed for everyone to download.

Private transfer

Drag a file from your desktop onto a device name in the left sidebar. Only that device will see the transfer notification and download link.

Per-file password

When uploading, check "Set password" and enter a password. The file will show a 🔒 icon in the feed. Anyone downloading it must enter the correct password first.

CLI Flags

Flag Default Description
--port 8080 HTTP server port
--dir ./shared Directory to store shared files
--host 0.0.0.0 Bind address

Architecture

main.go                         Entry point, CLI flags, graceful shutdown
internal/
  config/config.go              Flag parsing, LAN IP detection
  server/server.go              HTTP routing
  hub/hub.go                    WebSocket hub — manages connections, chat, device state
  handlers/
    files.go                    File upload/download/delete, per-file passwords (bcrypt)
    transfer.go                 Private device-to-device transfers with auto-cleanup
    devices.go                  Online device list endpoint
  models/models.go              Shared data types
web/
  embed.go                      go:embed directive
  index.html                    Single-page app shell
  static/js/                    Vanilla JS modules (no build step)
  static/css/style.css          Dark/light theme via CSS custom properties

Dependencies: Go standard library + github.com/coder/websocket + golang.org/x/crypto/bcrypt

How It Works

  • Each browser that opens the page connects via WebSocket and registers with a nickname (stored in localStorage)
  • The hub tracks all connected clients and broadcasts chat messages, file upload notifications, and device join/leave events
  • Files are stored on disk in the shared directory; metadata (uploader, password hash) in .meta.json sidecar files
  • Private transfers are saved to a .transfers/ subdirectory and auto-cleaned after 30 minutes
  • Chat history (last 200 messages) is kept in memory and sent to new connections

Deployment

Option 1: Run directly on one lab machine

# Install Go (1.22+), then:
git clone <this-repo>
cd LAN_sharing
go build -o lanshare.exe .
./lanshare.exe

Leave it running on one machine. Everyone else opens the URL in their browser.

Option 2: Cross-compile for different OS

Build on your machine, copy the binary to the target:

# Linux (e.g. lab server)
GOOS=linux GOARCH=amd64 go build -o lanshare .

# macOS
GOOS=darwin GOARCH=amd64 go build -o lanshare .

# Windows
GOOS=windows GOARCH=amd64 go build -o lanshare.exe .

No Go installation needed on the target — just copy and run the binary.

Option 3: Run as a background service (Linux)

Create /etc/systemd/system/lanshare.service:

[Unit]
Description=LANShare file sharing server
After=network.target

[Service]
ExecStart=/opt/lanshare/lanshare --port 8080 --dir /opt/lanshare/shared
WorkingDirectory=/opt/lanshare
Restart=always
User=nobody

[Install]
WantedBy=multi-user.target

Then:

sudo cp lanshare /opt/lanshare/
sudo systemctl enable --now lanshare

Option 4: Run on Windows startup

  1. Build: go build -o lanshare.exe .
  2. Press Win+R, type shell:startup
  3. Create a shortcut to lanshare.exe --port 8080 in that folder

Firewall

The server listens on the configured port (default 8080). Make sure your firewall allows inbound TCP connections on that port from your LAN:

# Windows (run as admin)
netsh advfirewall firewall add rule name="LANShare" dir=in action=allow protocol=TCP localport=8080

# Linux
sudo ufw allow 8080/tcp

Requirements

  • Go 1.22+ (only needed to build, not to run)
  • Any modern browser on the LAN

About

A lightweight chat-based web app for sharing files and messages across computers on the same LAN

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages