diff --git a/.aspell.en.pws b/.aspell.en.pws index c527a657d..3d855d764 100644 --- a/.aspell.en.pws +++ b/.aspell.en.pws @@ -392,4 +392,6 @@ unspendable pkh kB unblind -unblinded \ No newline at end of file +unblinded +WebSocket +websocket \ No newline at end of file diff --git a/07-routing-gossip.md b/07-routing-gossip.md index b53d75e8a..ce6f10dec 100644 --- a/07-routing-gossip.md +++ b/07-routing-gossip.md @@ -294,6 +294,10 @@ The following `address descriptor` types are defined: * `hostname` bytes MUST be ASCII characters. * Non-ASCII characters MUST be encoded using Punycode: https://en.wikipedia.org/wiki/Punycode + * `6`: WebSocket address; data = `[1:hostname_len][hostname_len:hostname][2:port]` (length up to 258) + * `hostname` bytes MUST be ASCII characters. + * Non-ASCII characters MUST be encoded using Punycode: + https://en.wikipedia.org/wiki/Punycode ### Requirements @@ -315,7 +319,7 @@ The origin node: - MUST place address descriptors in ascending order. - SHOULD NOT place any zero-typed address descriptors anywhere. - SHOULD use placement only for aligning fields that follow `addresses`. - - MUST NOT create a `type 1`, `type 2` or `type 5` address descriptor with + - MUST NOT create a `type 1`, `type 2`, `type 5` or `type 6` address descriptor with `port` equal to 0. - SHOULD ensure `ipv4_addr` AND `ipv6_addr` are routable addresses. - MUST set `features` according to [BOLT #9](09-features.md#assigned-features-flags) @@ -323,6 +327,7 @@ The origin node: bits it sets. - SHOULD not announce a Tor v2 onion service. - MUST NOT announce more than one `type 5` DNS hostname. + - MUST NOT announce more than one `type 6` DNS hostname. The receiving node: - if `node_id` is NOT a valid compressed public key: @@ -363,6 +368,9 @@ any future fields appended to the end): - if more than one `type 5` address is announced: - SHOULD ignore the additional data. - MUST not forward the `node_announcement`. + - if more than one `type 6` address is announced: + - SHOULD ignore the additional data. + - MUST not forward the `node_announcement`. ### Rationale diff --git a/08-transport.md b/08-transport.md index 49ca45e05..3368929f6 100644 --- a/08-transport.md +++ b/08-transport.md @@ -18,6 +18,7 @@ of a node. * [Handshake State](#handshake-state) * [Handshake State Initialization](#handshake-state-initialization) * [Handshake Exchange](#handshake-exchange) + * [Alternate Transport Layers: WebSocket](#websocket) * [Lightning Message Specification](#lightning-message-specification) * [Encrypting and Sending Messages](#encrypting-and-sending-messages) * [Receiving and Decrypting Messages](#receiving-and-decrypting-messages) @@ -402,6 +403,34 @@ construction, and 16 bytes for a final authenticating tag. 10. `rn = 0, sn = 0` * The sending and receiving nonces are initialized to 0. +## Alternate Transport Layers: WebSocket + +Normally the transport protocol defined here is performed over TCP/IP, +but it can also be performed over other underlying transports, such as +the WebSocket protocol as specified in +RFC6455[4](#reference-4) on ports so-advertized (in the +[node_announcement message](07-routing-gossip.md#the-node_announcement-message). + +A client may connect to this port node and initiate a WebSocket; and +operate the protocol over binary WebSocket frames instead of raw TCP/IP. + +### Requirements + +The initiator: +- MAY attempt to initiate an unencrypted WebSocket as specified in RFC6455[4](#reference-4): + - MUST abort the connection attempt if WebSocket upgrade fails. + - MUST begin the [Handshake Exchange](#handshake-exchange) as initiator + as soon as upgrade succeeds. + +The responder: +- if it supports WebSocket connections on an address: + - SHOULD advertise it using a type 6 address its node announcement. + - MUST abort the connection attempt if WebSocket upgrade fails. + +Both nodes, after upgrade: + - MUST use binary frames to send and receive messages. + - MUST NOT rely on WebSocket framing for message semantics. + ## Lightning Message Specification At the conclusion of Act Three, both sides have derived the encryption keys, which @@ -779,6 +808,7 @@ TODO(roasbeef); fin 1. https://tools.ietf.org/html/rfc8439 2. http://noiseprotocol.org/noise.html 3. https://tools.ietf.org/html/rfc5869 +4. https://tools.ietf.org/html/rfc6455 # Authors