Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
Contextualist committed Jan 15, 2023
0 parents commit df138a9
Show file tree
Hide file tree
Showing 25 changed files with 1,710 additions and 0 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Release

on:
push:
tags:
- 'v*'


jobs:

goreleaser:
runs-on: ubuntu-latest
permissions:
contents: write
steps:

- uses: actions/checkout@v3
with:
fetch-depth: 0

- run: git fetch --force --tags

- uses: actions/setup-go@v3
with:
go-version: stable
cache: true

- uses: goreleaser/goreleaser-action@v4
with:
distribution: goreleaser
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


deploy:
runs-on: ubuntu-latest
permissions:
id-token: write # allow GitHub Action to authenticate with Deno Deploy
contents: read
steps:

- uses: actions/checkout@v3

- uses: denoland/deployctl@v1
with:
project: acp
root: edge
entrypoint: index.ts

80 changes: 80 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Test

on:
push:
branches:
- main
pull_request:
branches:
- main


jobs:

checks:
name: Checks
runs-on: ubuntu-latest
timeout-minutes: 5
steps:

- uses: actions/checkout@v3

- uses: actions/setup-go@v3
with:
go-version: stable
cache: true

- uses: golangci/golangci-lint-action@v3
with:
version: latest

- name: Go mod
env:
DIFF_PATH: "go.mod go.sum"
run: |
go mod tidy
DIFF=$(git status --porcelain -- $DIFF_PATH)
if [ "$DIFF" ]; then
echo 'Please run `go mod tidy` before commits involving dependency change'
exit 1
fi
build:
name: Build
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
timeout-minutes: 5
steps:

- uses: actions/checkout@v3

- uses: actions/setup-go@v3
with:
go-version: stable
cache: true

- run: go build ./cmd/acp


test:
name: Test
needs: build
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
timeout-minutes: 5
steps:

- uses: actions/checkout@v3

- uses: actions/setup-go@v3
with:
go-version: stable
cache: true

- run: go test ./...

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

dist/
45 changes: 45 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
before:
hooks:
- go mod tidy

builds:
- main: ./cmd/acp
binary: acp
env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
goarch:
- amd64
- arm64
flags:
- -trimpath
ldflags:
- -s -w -X main.buildTag={{.Version}}

archives:
- format: tar.gz
name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
format_overrides:
- goos: windows
format: zip
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
- '^chore:'

21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Contextualist

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
87 changes: 87 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# acp

![demo.gif](media/demo.gif)

Highlights (aka "Why making another file-transfer tool?"):

- Designed for personal use; no need to copy-paste a token / code for each transfer
- Rendezvous service runs distributively on [serverless edge function](https://deno.com/deploy/docs),
a robust solution with low latency worldwide.

Other features:

- End-to-end encryption (ChaCha20-Poly1305)
- P2P connection: LAN or WAN, with NAT transversal
- Compression (gzip)
- Cross platform: Linux, macOS, Windows
- Support transfering multiple files and directories

See also [comparison table with similar tools](#similar-projects).


## Get started

### Linux, macOS

On any of your machine, run

```bash
curl -fsS https://acp.deno.dev/get | sh
```

It sets up the current machine by downloading an executable and generating an identity.
By default the install path is `/usr/local/bin`; you can change it by `curl -fsS 'https://acp.deno.dev/get?dir=/path/to/bin' | sh`
At the end, it prints out the command for setting up your other machines.
You can run `acp --setup` any time you want to see the command.

### Windows

Currently there is no installation script for PowerShell (PR welcomes :)
You can download the released executable and put it on your `Path`.
Then run `acp --setup` to generate an identity.


## Usage

```bash
# sender
acp path/to/files

# receiver
acp # for receiving to pwd or
acp -d path/to/dest
```

You can run the sender and receiver in arbitrary order.
Whenever both sides are up and running, they will attempt to establish a P2P connection.
If you see messages such as `rendezvous timeout`, at least one side is behind a firewall or a strict NAT that prohibits P2P connection.

For advanced configuration and self-hosting (it's free & takes only 5 minutes!), check out [the docs here](docs/advanced.md).


## Similar projects

| | [trzsz](https://github.com/trzsz/trzsz) | scp | **acp** | [pcp](https://github.com/dennis-tra/pcp) | [croc](https://github.com/schollz/croc) |
| ------------------------------------------------------------ | --------------------------------------- | ---- | ------- | ---------------------------------------- | --------------------------------------- |
| can share files to other people /<br/>receiver needs to enter a token | | | | O | O |
| LAN | O | O | O | O | O |
| WAN (local ↔︎ remote) | O | O | O | P | O |
| WAN (remote ↔︎ remote) | | P | O | P | O |
| relay | | | | P | O |
| p2p | | | O | O | O |
| distributive | | | O | O | |

O: supported; P: partial support or limited usablity; (void): not supported or not relevant

Don't judge a tool based on its apparent set of features.
This table only lists a few features, intending to differentiate the target scenarios of these tools.


## Acknowledgement

Apart from the dependencies listed in [`go.mod`](go.mod), this project is also built upon

- [**Deno Deploy**](https://deno.com/deploy) exposes low-level connection infomation and provides a fantastic `BroadcastChannel` API that makes "serverless" TCP hole-punching possible
- [**mholt/archiver**](https://github.com/mholt/archiver): tar/untar implementation
- [**libp2p/go-reuseport**](https://github.com/libp2p/go-reuseport): address reuse for TCP hole-punching
- [**egoist/bina**](https://github.com/egoist/bina): installation script
Loading

0 comments on commit df138a9

Please sign in to comment.