A cross-platform file synchronization command-line tool similar to rsync, designed for local network use with TCP-based transfer.
Important Security Note: This tool is strongly recommended for use within local networks only, preferably through network grouping (e.g., VPN or LAN). Do not use it directly over the public internet as it does not include encryption or authentication mechanisms.
This project was generated by TraeAI
- Cross-platform compatibility: Works on Windows, macOS, and Linux
- TCP-based network transfer: For reliable file synchronization within local networks
- File integrity verification: Uses MD5 hash calculation to ensure file integrity
- Progress printing: Detailed transfer progress information during file synchronization
- Safe file operations: Uses temporary files with MD5 verification before overwriting target files
- Sequential file transfer: Processes files one by one for reliable synchronization
- Simplified sync logic: Directly compares files by MD5 hash for efficient synchronization
- Automatic cleanup: Removes local files that don't exist on the remote server
- Go 1.16 or later
git clone https://github.com/Zhao-Michael/gorsync.git
// build library for windows:
go build -buildmode=c-shared -ldflags="-s -w" -o gorsync.dll ./cmd/gorsync/main.go
// build library for linux:
go build -ldflags "-s -w" -buildmode=c-shared -o gorsync.so ./cmd/gorsync/main.go
// build executable for windows:
go build -o gorsync.exe -ldflags="-s -w" ./cmd/gorsync/main.go
// build executable for linux:
go build -o gorsync -ldflags="-s -w" ./cmd/gorsync/main.go// Start Server
extern int StartServer(void);
// Sync Files
extern int SyncFiles(char* localPath, char* remotePath);
// Stop Server
extern int StopServer(void);# Start server with default port 8730
gorsync
# Start server with custom port
gorsync -listen 9000# Sync from remote source to local destination (default port 8730)
gorsync -path /path/to/destination -remote 192.168.1.100:/path/to/source
# Sync with custom port
gorsync -path /path/to/destination -remote 192.168.1.100:9000:/path/to/source| Argument | Description | Default |
|---|---|---|
-path |
Local directory path for synchronization | N/A |
-remote |
Remote address in format host[:port]:path (e.g., 192.168.1.100:8730:/src or 192.168.1.100:/src) |
N/A |
-listen |
Start in listening mode with optional port number | 8730 |
# Server side (listening mode)
gorsync
# Client side (sync operation)
gorsync -path ./destination -remote 192.168.1.100:/source# Server side (custom port)
gorsync -listen 9000
# Client side (connect to custom port)
gorsync -path ./destination -remote 192.168.1.100:9000:/source- pkg/transfer/transfer.go: File transfer functionality with MD5 verification
- pkg/net/server.go: TCP server for file transfer
- pkg/net/client.go: TCP client for file transfer
- pkg/sync/sync.go: Synchronization logic
- pkg/diff/diff.go: File difference comparison
- pkg/utils/hash.go: MD5 hash calculation utilities
- File Transfer: Uses TCP for reliable file transfer with MD5 verification to ensure file integrity
- Sequential Transfer: Processes files one by one for reliable synchronization
- Safe Operations: Uses temporary files and safe rename operations to ensure atomic file updates
- Progress Tracking: Provides detailed progress information during file transfer
- Simplified Sync Logic: Directly compares files by MD5 hash for efficient synchronization
- Automatic Cleanup: Removes local files that don't exist on the remote server
- Uses TCP for all file transfers
- Default port: 8730
- Supports binary file transfer with chunked encoding
- Includes MD5 hash verification for file integrity
gorsync/
├── cmd/
│ └── gorsync/ # Command-line interface
│ └── main.go # Main entry point
├── pkg/
│ ├── diff/ # File difference comparison
│ ├── net/ # Network client/server implementation
│ ├── sync/ # Synchronization logic
│ ├── transfer/ # File transfer functionality
│ └── utils/ # Utility functions
├── go.mod # Go module definition
└── README.md # This file
- Start a server in listening mode
- Run a client to sync files to the server
- Verify that files are correctly synchronized
MIT License
Contributions are welcome! Please feel free to submit a Pull Request.
- Inspired by gokrazy/rsync but with simplify codes and supoort for windows.
- Built with Go's standard library and cross-platform compatibility in mind