|
1 | | -# BIP-324 Encrypted Transport Protocol |
| 1 | +# BIP-324 V2 Proxy |
2 | 2 |
|
3 | | -[BIP-324](https://github.com/bitcoin/bips/blob/master/bip-0324.mediawiki) describes the V2 encrypted communication protocol for the bitcoin P2P network. |
| 3 | +A proxy sidecar process which allows V1-only clients to communicate over the V2 protocol. The process listens on port `1324` for V1 connections and requires the V1 client to send along the remote peer's IP address in the `addr_recv` field. |
4 | 4 |
|
5 | | -## Motivation |
| 5 | +## Running the Proxy |
6 | 6 |
|
7 | | -Bitcoin's original P2P protocol, "V1", was designed without any encryption. Even though the data exchanged over the bitcoin P2P network is public to some degree, encrypted communications offers a number of benefits over plaintext communication. |
| 7 | +`cargo run --bin proxy` |
8 | 8 |
|
9 | | -* Internet Service Providers (ISPs) can easily detect and censor plaintext bitcoin communication. |
10 | | -* Plaintext message tampering, without detection, is trivial for a man in the middle (MitM) attacker. |
11 | | -* Nefarious actors may associate metadata, such as IP addresses and transaction origins, without explicitly having to connect directly to peers. |
| 9 | +The `--v1-fallback=true` flag can be used to fallback to the V1 protocol if the remote client does not support V2. |
12 | 10 |
|
13 | | -BIP-324 - "V2" - encrypted communication protects against the above issues increasing the privacy and censorship-resistance of the bitcoin ecosystem. Any applications communicating with bitcoin nodes, including light clients, should make use of the V2 protocol. |
| 11 | +## Testing with Nakamoto |
14 | 12 |
|
15 | | -## Crates |
| 13 | +[Nakamoto](https://github.com/cloudhead/nakamoto) is a BIP-157/BIP-158 Light Client that communicates over the Bitcoin P2P network. With a single change, Nakamoto may be modified to use the proxy. This patch hardcodes Nakamoto to connect to the localhost on port 1324 where the proxy should be running. |
16 | 14 |
|
17 | | -* [`protocol`](./protocol) - Exports the `bip324` client library. |
18 | | -* [`proxy`](./proxy) - A small side-car application to enable V2 communication for V1-only applications. |
19 | | -* [`traffic`](./traffic) - Traffic shape hiding layer over the base client. |
| 15 | +```diff |
| 16 | +diff --git a/net/poll/src/reactor.rs b/net/poll/src/reactor.rs |
| 17 | + |
| 18 | +--- a/net/poll/src/reactor.rs |
| 19 | ++++ b/net/poll/src/reactor.rs |
| 20 | +@@ -468,7 +468,7 @@ fn dial(addr: &net::SocketAddr) -> Result<net::TcpStream, io::Error> { |
| 21 | + sock.set_write_timeout(Some(WRITE_TIMEOUT))?; |
| 22 | + sock.set_nonblocking(true)?; |
| 23 | + |
| 24 | +- match sock.connect(&(*addr).into()) { |
| 25 | ++ match sock.connect(&net::SocketAddr::from(([127, 0, 0, 1], 1324)).into()) { |
| 26 | + Ok(()) => {} |
| 27 | + Err(e) if e.raw_os_error() == Some(libc::EINPROGRESS) => {} |
| 28 | + Err(e) if e.raw_os_error() == Some(libc::EALREADY) => { |
| 29 | +``` |
0 commit comments