@@ -100,6 +100,18 @@ and handle them accordingly, if present:
100
100
expect the protocol to be `tcp` (expect websockets support in the future). Clients
101
101
should make a preselection of viable relay servers (which may include entries from other
102
102
sources as well), and randomly select one or two.
103
+ * `proof_of_work`: A proof of work task to mitigate DOS attacks. The difficulty is dictated
104
+ by the server based on its current load. The entry looks like this:
105
+ ```json
106
+ {
107
+ "challenge" : " 0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABXXXX" ,
108
+ "sha256" : " a66cdd7def34cb0267b83d21c37c429af0a15dcd00465da22402dab9f1cbf10e" ,
109
+ "mac" : " <snip>"
110
+ }
111
+ ```
112
+ The challenge contains exactly 32 hex-encoded bytes, of which the last nibbles are censored ('X'),
113
+ and the `sha256sum` of the uncensored challenge. The goal is to find the complete `challenge` with
114
+ the given hash.
103
115
104
116
The first thing each client sends to the server, immediately after receiving
105
117
the welcome message, is a `bind` message. This specifies the
@@ -108,6 +120,23 @@ messages will be scoped to. While technically each message could be
108
120
independent (with its own `appid` and `side`), I thought it would be less
109
121
confusing to use exactly one WebSocket per logical wormhole connection.
110
122
123
+ Due to backwards compatibity, clients are not forced to give a proof of work.
124
+ However, it is strongly recommended. Here's how a full "bind" message may look like:
125
+
126
+ ```json
127
+ {
128
+ "type" : " bind" ,
129
+ "appid" : " lothar.com/wormhole/text-or-file-xfer" ,
130
+ "side" : " 123456" ,
131
+ "proof_of_work" : {
132
+ "challenge" : " 0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABXXXX" ,
133
+ "sha256" : " a66cdd7def34cb0267b83d21c37c429af0a15dcd00465da22402dab9f1cbf10e" ,
134
+ "mac" : " <snip>" ,
135
+ "response" : " 0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF" ,
136
+ },
137
+ }
138
+ ```
139
+
111
140
A ` ping ` will provoke a ` pong ` : these are only used by unit tests for
112
141
synchronization purposes (to detect when a batch of messages have been fully
113
142
processed by the server). NAT-binding refresh messages are handled by the
@@ -216,7 +245,7 @@ This lists all message types, along with the type-specific keys for each (if
216
245
any), and which ones provoke direct responses:
217
246
218
247
* S->C welcome {welcome:}
219
- * (C->S) bind {appid:, side:}
248
+ * (C->S) bind {appid:, side:, proof_of_work: {..}, }
220
249
* (C->S) list {} -> nameplates
221
250
* S->C nameplates {nameplates: [ {id: str},..] }
222
251
* (C->S) allocate {} -> allocated
0 commit comments