Skip to content
Open
4 changes: 2 additions & 2 deletions cmd/ww/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func newConn(code string, length int) *wormhole.Wormhole {
if err == wormhole.ErrBadVersion {
fatalf(
"%s%s%s",
"the signalling server is running an incompatable version.\n",
"the signalling server is running an incompatible version.\n",
"try upgrading the client:\n\n",
" go install webwormhole.io/cmd/ww@latest\n",
)
Expand Down Expand Up @@ -114,7 +114,7 @@ func newConn(code string, length int) *wormhole.Wormhole {
if err == wormhole.ErrBadVersion {
fatalf(
"%s%s%s",
"the signalling server is running an incompatable version.\n",
"the signalling server is running an incompatible version.\n",
"try upgrading the client:\n\n",
" go install webwormhole.io/cmd/ww@latest\n",
)
Expand Down
2 changes: 1 addition & 1 deletion cmd/ww/pipe.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func pipe(args ...string) {
c := newConn(set.Arg(0), *length)

done := make(chan struct{})
// The recieve end of the pipe.
// The receive end of the pipe.
go func() {
_, err := io.CopyBuffer(os.Stdout, c, make([]byte, msgChunkSize))
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions cmd/ww/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"webwormhole.io/wormhole"
)

// slotTimeout is the the maximum amount of time a client is allowed to
// slotTimeout is the maximum amount of time a client is allowed to
// hold a slot.
const slotTimeout = 12 * time.Hour

Expand Down Expand Up @@ -107,7 +107,7 @@ var stunServers []webrtc.ICEServer
// freeslot tries to find an available numeric slot, favouring smaller numbers.
// This assume slots is locked.
func freeslot() (slot string, ok bool) {
// Assuming varint encoding, we first try for one byte. That's 7 bits in varint.
// Assuming varint encoding, we first try for one byte. That's seven bits in varint.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are three commits that spell out small numbers, the idea is described in https://www.scribendi.com/academy/articles/when_to_spell_out_numbers_in_writing.en.html#:~:text=Writing%20Small%20and%20Large%20Numbers,ten%29%20are%20written%20as%20numerals%2e

I'm happy to drop those changes or anything else.

for i := 0; i < 64; i++ {
s := strconv.Itoa(rand.Intn(1 << 7))
if _, ok := slots.m[s]; !ok {
Expand Down
10 changes: 5 additions & 5 deletions web/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,11 +422,11 @@ async function connect() {
};
};
const fingerprint = await w.dial();
// To make it more likely to spot the 1 in 2^16 chance of a successful
// To make it more likely to spot the one in 2^16 chance of a successful
// MITM password guess, we can compare a fingerprint derived from the PAKE
// key. The 7 words visible on the tooltip of the input box should match on
// key. The seven words visible on the tooltip of the input box should match on
// both side.
// We also use the first 3 bits of it to choose the background colour, so
// We also use the first three bits of it to choose the background colour, so
// that should match on both sides as well.
const encodedfp = webwormhole.encode(0, fingerprint.subarray(1));
phraseInput.title = encodedfp.substring(encodedfp.indexOf("-") + 1);
Expand Down Expand Up @@ -619,7 +619,7 @@ function browserhacks() {
if (/^Mozilla\/5.0 \(iPhone; CPU iPhone OS 12_[0-9]_[0-9] like Mac OS X\)/.test(navigator.userAgent)) {
hacks.noblob = true;
hacks.nosw = true;
console.log("quirks: using ios12 dataurl hack");
console.log("quirks: using ios12 data-url hack");
}
// Work around iOS trying to connect when the link is previewed.
// You never saw this.
Expand Down Expand Up @@ -708,7 +708,7 @@ async function init() {
transfersList = document.getElementById("transfers");
infoBox = document.getElementById("info");
autocompleteBox = document.getElementById("autocomplete");
// Friendly error message and bail out if things are clearely not going to work.
// Friendly error message and bail out if things are clearly not going to work.
if (hacks.browserunsupported) {
infoBox.innerText =
"Browser missing required feature. This application needs support for WebSockets, WebRTC, and WebAssembly.";
Expand Down
10 changes: 5 additions & 5 deletions web/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -543,11 +543,11 @@ async function connect() {

const fingerprint = await w.dial();

// To make it more likely to spot the 1 in 2^16 chance of a successful
// To make it more likely to spot the one in 2^16 chance of a successful
// MITM password guess, we can compare a fingerprint derived from the PAKE
// key. The 7 words visible on the tooltip of the input box should match on
// key. The seven words visible on the tooltip of the input box should match on
// both side.
// We also use the first 3 bits of it to choose the background colour, so
// We also use the first three bits of it to choose the background colour, so
// that should match on both sides as well.
const encodedfp = webwormhole.encode(0, fingerprint.subarray(1));
phraseInput.title = encodedfp.substring(encodedfp.indexOf("-") + 1);
Expand Down Expand Up @@ -771,7 +771,7 @@ function browserhacks() {
) {
hacks.noblob = true;
hacks.nosw = true;
console.log("quirks: using ios12 dataurl hack");
console.log("quirks: using ios12 data-url hack");
}

// Work around iOS trying to connect when the link is previewed.
Expand Down Expand Up @@ -883,7 +883,7 @@ async function init() {
infoBox = document.getElementById("info") as HTMLElement;
autocompleteBox = document.getElementById("autocomplete") as HTMLElement;

// Friendly error message and bail out if things are clearely not going to work.
// Friendly error message and bail out if things are clearly not going to work.
if (hacks.browserunsupported) {
infoBox.innerText =
"Browser missing required feature. This application needs support for WebSockets, WebRTC, and WebAssembly.";
Expand Down
4 changes: 2 additions & 2 deletions web/sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Workaround to tell TypeScript about the correct type of a ServiceWorker.
const sw = self;
// There can be multiple clients (pages) receiving files, so they generate an id
// and here we store info assosiated with each transfer.
// and here we store info associated with each transfer.
const streams = new Map();
class Stream {
constructor(name, size, filetype) {
Expand Down Expand Up @@ -125,7 +125,7 @@ async function streamUpload(e) {
return;
}
// ReadableStream is transferable on Chrome at the time of writing. Since Share
// Target also only works on Chome, we can use this and avoid the complexity of
// Target also only works on Chrome, we can use this and avoid the complexity of
// chunking over postMessage (like we do with downloads) or having to read the
// whole file into memory.
// TypeScript doesn't know that ReadableStream is transferable, hence body as
Expand Down
4 changes: 2 additions & 2 deletions web/sw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
const sw = self as ServiceWorkerGlobalScope & typeof globalThis;

// There can be multiple clients (pages) receiving files, so they generate an id
// and here we store info assosiated with each transfer.
// and here we store info associated with each transfer.
const streams = new Map();

class Stream {
Expand Down Expand Up @@ -158,7 +158,7 @@ async function streamUpload(e: FetchEvent) {
}

// ReadableStream is transferable on Chrome at the time of writing. Since Share
// Target also only works on Chome, we can use this and avoid the complexity of
// Target also only works on Chrome, we can use this and avoid the complexity of
// chunking over postMessage (like we do with downloads) or having to read the
// whole file into memory.
// TypeScript doesn't know that ReadableStream is transferable, hence body as
Expand Down
6 changes: 3 additions & 3 deletions web/ww.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Wormhole {
console.log("requesting slot");
this.state = this.statePlayer1;
}
// There are 3 events that we need to synchronise with the caller on:
// There are three events that we need to synchronise with the caller on:
// 1. we got the first message from the signalling server.
// We now have the slot number and the ICE server details, so we can
// create the wormhole code and PeerConnection object, and pass them back
Expand Down Expand Up @@ -67,7 +67,7 @@ class Wormhole {
this.callback(this.pc);
const msgA = webwormhole.start(this.pass);
if (!msgA) {
return this.fail("could nnt generate A's PAKE message");
return this.fail("could not generate A's PAKE message");
}
console.log("message a:", msgA);
this.ws.send(msgA);
Expand Down Expand Up @@ -241,7 +241,7 @@ class Wormhole {
const stats = await this.pc.getStats();
let id;
stats.forEach((s) => {
// s.selected gives more confidenece than s.state == "succeeded", but Chrome does
// s.selected gives more confidence than s.state == "succeeded", but Chrome does
// not implement it.
if (s.type === "candidate-pair" &&
s.state === "succeeded") {
Expand Down
6 changes: 3 additions & 3 deletions web/ww.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class Wormhole {
this.state = this.statePlayer1;
}

// There are 3 events that we need to synchronise with the caller on:
// There are three events that we need to synchronise with the caller on:
// 1. we got the first message from the signalling server.
// We now have the slot number and the ICE server details, so we can
// create the wormhole code and PeerConnection object, and pass them back
Expand Down Expand Up @@ -112,7 +112,7 @@ class Wormhole {
this.callback(this.pc);
const msgA = webwormhole.start(this.pass);
if (!msgA) {
return this.fail("could nnt generate A's PAKE message");
return this.fail("could not generate A's PAKE message");
}
console.log("message a:", msgA);
this.ws.send(msgA);
Expand Down Expand Up @@ -314,7 +314,7 @@ class Wormhole {

let id: string | undefined;
stats.forEach((s) => {
// s.selected gives more confidenece than s.state == "succeeded", but Chrome does
// s.selected gives more confidence than s.state == "succeeded", but Chrome does
// not implement it.
if (
s.type === "candidate-pair" &&
Expand Down
8 changes: 4 additions & 4 deletions wordlist/wordlist.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Package wordlist provides a encoders and a decoder for WebWormhole codes.
// Package wordlist provides encoders and a decoder for WebWormhole codes.
package wordlist

import (
Expand Down Expand Up @@ -71,7 +71,7 @@ func (octalEncoding) Encode(slot int, pass []byte) string {
}

func (octalEncoding) Decode(code string) (slot int, pass []byte) {
// White space and - are interchangable.
// White space and - are interchangeable.
code = strings.ReplaceAll(code, "-", " ")
// Space can turn into + in URLs.
code = strings.ReplaceAll(code, "+", " ")
Expand Down Expand Up @@ -124,7 +124,7 @@ func (list varintEncoding) Encode(slot int, pass []byte) string {
}

func (list varintEncoding) Decode(code string) (slot int, pass []byte) {
// White space and - are interchangable.
// White space and - are interchangeable.
code = strings.ReplaceAll(code, "-", " ")
// Space can turn into + in URLs.
code = strings.ReplaceAll(code, "+", " ")
Expand Down Expand Up @@ -169,7 +169,7 @@ func (list magicWormholeEncoding) Encode(slot int, pass []byte) string {
}

func (list magicWormholeEncoding) Decode(code string) (slot int, pass []byte) {
// White space and - are interchangable.
// White space and - are interchangeable.
code = strings.ReplaceAll(code, "-", " ")
// Space can turn into + in URLs.
code = strings.ReplaceAll(code, "+", " ")
Expand Down
2 changes: 1 addition & 1 deletion wordlist/wordlist_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func TestMatch(t *testing.T) {
{"zo", "zone"},
{"acre-b", ""},
{"zz", ""},
{"snaps", "snapshot"}, // fallback to gpg words
{"snaps", "snapshot"}, // fall back to gpg words
}
for i, c := range cases {
if hint := Match(c.prefix); hint != c.word {
Expand Down
8 changes: 4 additions & 4 deletions wormhole/dial.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// (https://tools.ietf.org/html/rfc5763).
//
// This package removes the signalling server from the trust model by using a
// PAKE to estabish the authenticity of the WebRTC metadata. In other words,
// PAKE to establish the authenticity of the WebRTC metadata. In other words,
// it's a clone of Magic Wormhole made to use WebRTC as the transport.
//
// The protocol requires a signalling server that facilitates exchanging
Expand Down Expand Up @@ -99,7 +99,7 @@ var (
// version of the signalling protocol.
ErrBadVersion = errors.New("bad version")

// ErrBadVersion is returned when the the peer on the same slot uses a different
// ErrBadVersion is returned when the peer on the same slot uses a different
// password.
ErrBadKey = errors.New("bad key")

Expand Down Expand Up @@ -255,7 +255,7 @@ func writeBase64(ws *websocket.Conn, p []byte) error {
}

// readInitMsg reads the first message the signalling server sends over
// the WebSocket connection, which has metadata includign assigned slot
// the WebSocket connection, which has metadata including assigned slot
// and ICE servers to use.
func readInitMsg(ws *websocket.Conn) (slot string, iceServers []webrtc.ICEServer, err error) {
msg := struct {
Expand Down Expand Up @@ -327,7 +327,7 @@ func (c *Wormhole) newPeerConnection(ice []webrtc.ICEServer) error {
return nil
}

// IsRelay returns whether this connection is over a TURN relay or not.
// IsRelay returns whether or not this connection is over a TURN relay.
func (c *Wormhole) IsRelay() bool {
stats := c.pc.GetStats()
for _, s := range stats {
Expand Down