Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add websocket support to transit relay client #49

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
c571ee4
websocket: switch to nhooyr.io/websocket
vu3rdd Feb 4, 2021
9e1121c
Merge pull request #6 from LeastAuthority/switch-websocket-lib
bryanchriswhite Feb 19, 2021
5f8707e
do not compile these files if compiled with -tags js,wasm
vu3rdd Feb 5, 2021
296dece
wasm: copied from bryan/wasm branch
vu3rdd Feb 5, 2021
ee5845d
wasm: build only when wasm build flags are passed
vu3rdd Feb 5, 2021
1a9f99c
cleanup my own messs :p
bryanchriswhite Feb 19, 2021
da48044
Merge pull request #9 from LeastAuthority/wasm-build-tags
bryanchriswhite Feb 19, 2021
b9f6862
refactor promise
bryanchriswhite Mar 3, 2021
aa6c013
add pull request template
bryanchriswhite Sep 15, 2021
f112dc6
Switch zip impl to github.com/klauspost/compress
Jacalz Dec 23, 2020
d1f97c5
Various improvements to the README.md
Jacalz Dec 23, 2020
5a13002
New Readme section for third-party users
psanford Dec 28, 2020
7d35b73
Remove a duplicated space in help message
Jacalz Dec 23, 2020
39bd3c1
Fix spelling mistake
psanford Feb 24, 2021
ab249b4
Add dynamic shell completions
psanford Mar 13, 2021
4c00862
Update github workflow go versions
psanford Mar 13, 2021
d5e9f96
Attempt to deflake rendezvous tests
psanford Mar 13, 2021
55b1977
Bump version v1.0.4 => v1.0.5
psanford Mar 13, 2021
c70c46d
Attempt to deflake TestVerifierAbort
psanford Mar 13, 2021
5549a40
Support cancellation for file/dir receives
psanford Mar 14, 2021
d0b5615
sendFileDirectory: cancel transfers via context
psanford Mar 14, 2021
4d97060
Minor readme updates
psanford Mar 14, 2021
51fabe6
Add meta tests for gofmt and mod tidy
psanford Mar 24, 2021
e00e568
Fix bash completion example
psanford Mar 20, 2021
002e719
Update klauspost/compress/deflate to 1.11.13
Jacalz Mar 27, 2021
2996142
Gofmt rendezvous/client.go properly
psanford Mar 27, 2021
82da865
A few smaller code cleanups
Jacalz Mar 12, 2021
8881adc
add websocket support to transit relay client
bryanchriswhite Mar 29, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ on: [push, pull_request]
jobs:

build:
name: Build
name: Build/Test
runs-on: ${{ matrix.os }}
timeout-minutes: 3
strategy:
matrix:
go-version: [1.14.9, 1.15.2]
go-version: [1.15.10, 1.16.2]
os: [ubuntu-latest, windows-latest]

steps:
Expand All @@ -27,6 +27,10 @@ jobs:
- name: Test
run: go test -v ./... --timeout 60s

- name: Meta Tests
run: go test -v -tags ci ./ci --timeout 60s
if: ${{ runner.os == 'Linux' }}

- name: Cross test for i386
run: env GOOS=linux GOARCH=386 go test -v ./... --timeout 60s
if: ${{ runner.os == 'Linux' }}
Expand Down
29 changes: 16 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# wormhole-william

wormhole-william is a go (golang) implementation of [magic wormhole](https://magic-wormhole.readthedocs.io/en/latest/). It provides secure end-to-end encrypted file transfers between computers. The endpoints are connected using the same "wormhole code".
wormhole-william is a Go (golang) implementation of [magic wormhole](https://magic-wormhole.readthedocs.io/en/latest/). It provides secure end-to-end encrypted file transfers between computers. The endpoints are connected using the same "wormhole code".

wormhole-william is compatible with the official [python magic wormhole cli tool](https://github.com/warner/magic-wormhole).

Expand All @@ -16,7 +16,7 @@ https://pkg.go.dev/github.com/psanford/wormhole-william/wormhole?tab=doc
## CLI Usage

```
$ ./wormhole-william send --help
$ wormhole-william send --help
Send a text message, file, or directory...

Usage:
Expand All @@ -33,7 +33,7 @@ Global Flags:
--relay-url string rendezvous relay to use


$ ./wormhole-william receive --help
$ wormhole-william receive --help
Receive a text message, file, or directory...

Usage:
Expand All @@ -51,20 +51,20 @@ Global Flags:
--relay-url string rendezvous relay to use
```

### CLI tab completion

The wormhole-william CLI supports shell completion, including completing the receive code.
To enable shell completion follow the instructions from `wormhole-william shell-completion -h`.


## Building the CLI tool

wormhole-william uses go modules so it requires a version of the go tool chain >= 1.11. If you are using a version of go that supports modules you can clone the repo outside of your GOPATH and do a `go build` in the top level directory.

To just install via the go tool run:

```
go get -u github.com/psanford/wormhole-william
```

If you have go 1.12+ installed you can fetch/build/run with a single command:

```
GO111MODULE=on go run github.com/psanford/wormhole-william receive
go install github.com/psanford/wormhole-william@latest
```

## API Usage
Expand All @@ -75,11 +75,10 @@ Sending text:
package main

import (
"bufio"
"context"
"fmt"
"io/ioutil"
"log"
"os"

"github.com/psanford/wormhole-william/wormhole"
)
Expand All @@ -100,7 +99,6 @@ func sendText() {

s := <-status


if s.OK {
fmt.Println("OK!")
} else {
Expand Down Expand Up @@ -132,3 +130,8 @@ func recvText(code string) {
```

See the [cli tool](https://github.com/psanford/wormhole-william/tree/master/cmd) and [examples](https://github.com/psanford/wormhole-william/tree/master/examples) directory for working examples of how to use the API to send and receive text, files and directories.

## Third Party Users of Wormhole William

- [wormhole-gui](https://github.com/Jacalz/wormhole-gui): A Magic Wormhole graphical user interface
- [wormhole-william-mobile](https://github.com/psanford/wormhole-william-mobile): Android wormhole-william app
61 changes: 61 additions & 0 deletions ci/gofmt_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// +build ci

package ci

import (
"bytes"
"go/format"
"io/ioutil"
"os"
"path/filepath"
"strings"
"testing"
)

func TestGofmt(t *testing.T) {
var (
needsFormatting []string
checkedFiles int
)

err := filepath.Walk("..", func(path string, info os.FileInfo, err error) error {
if err != nil {
return nil
}
if path == ".git" {
return filepath.SkipDir
}
if info.IsDir() || !strings.HasSuffix(path, ".go") {
return nil
}

content, err := ioutil.ReadFile(path)
if err != nil {
return err
}
formatted, err := format.Source(content)
if err != nil {
return err
}

if !bytes.Equal(content, formatted) {
needsFormatting = append(needsFormatting, strings.TrimPrefix(path, ".."))
}

checkedFiles++

return nil
})

if err != nil {
t.Error(err)
}

if len(needsFormatting) > 0 {
t.Fatalf("The following files are not properlery gofmt'ed: %v", needsFormatting)
}

if checkedFiles < 20 {
t.Fatalf("Expected to check at least 20 files but only checked %d", checkedFiles)
}
}
61 changes: 61 additions & 0 deletions ci/gomodtidy_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// +build ci

package ci

import (
"bytes"
"fmt"
"os/exec"
"strings"
"testing"
)

func TestGoModTidy(t *testing.T) {
modified, err := modifiedFiles()
if err != nil {
t.Fatal(err)
}

if len(modified) > 0 {
t.Fatalf("Modified files detected before running `go mod tidy`: \n%s", strings.Join(modified, "\n"))
}

output, err := exec.Command("go", "mod", "tidy").CombinedOutput()
if err != nil {
t.Fatalf("go mod tidy err: %s %s", err, output)
}

modified, err = modifiedFiles()
if err != nil {
t.Fatal(err)
}

if len(modified) > 0 {
t.Fatalf("Modified files detected from running `go mod tidy`: %v", modified)
}
}

func modifiedFiles() ([]string, error) {
var modifiedFiles []string

status, err := exec.Command("git", "status", "-s").CombinedOutput()
if err != nil {
fmt.Printf("%s\n", status)
return nil, err
}

lines := bytes.Split(status, []byte("\n"))
for _, line := range lines {
line = bytes.TrimSpace(line)
if len(line) == 0 {
continue
}
if bytes.HasPrefix(line, []byte("??")) {
// ignore untracked files
continue
}
modifiedFiles = append(modifiedFiles, string(line))
}

return modifiedFiles, nil
}
5 changes: 4 additions & 1 deletion cmd/cmd.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !js,!wasm

package cmd

import (
Expand All @@ -14,7 +16,7 @@ var rootCmd = &cobra.Command{
Long: `Create a (magic) Wormhole and communicate through it.

Wormholes are created by speaking the same magic CODE in two different
places at the same time. Wormholes are secure against anyone who doesn't
places at the same time. Wormholes are secure against anyone who doesn't
use the same code.`,
}

Expand All @@ -32,5 +34,6 @@ func Execute() error {

rootCmd.AddCommand(recvCommand())
rootCmd.AddCommand(sendCommand())
rootCmd.AddCommand(completionCommand())
return rootCmd.Execute()
}
Loading