Skip to content

Commit

Permalink
Add websocket to NetAddr
Browse files Browse the repository at this point in the history
  • Loading branch information
benthecarman committed Apr 26, 2023
1 parent c182567 commit 6241f6b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lightning/src/ln/msgs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,11 @@ pub enum NetAddress {
/// The port on which the node is listening.
port: u16,
},
/// A websocket address/port on which the peer is listening.
Websocket {
/// The port on which the node is listening.
port: u16,
},
}
impl NetAddress {
/// Gets the ID of this address type. Addresses in [`NodeAnnouncement`] messages should be sorted
Expand All @@ -556,6 +561,7 @@ impl NetAddress {
&NetAddress::OnionV2(_) => { 3 },
&NetAddress::OnionV3 {..} => { 4 },
&NetAddress::Hostname {..} => { 5 },
&NetAddress::Websocket {..} => { 6 },
}
}

Expand All @@ -568,6 +574,7 @@ impl NetAddress {
&NetAddress::OnionV3 { .. } => { 37 },
// Consists of 1-byte hostname length, hostname bytes, and 2-byte port.
&NetAddress::Hostname { ref hostname, .. } => { u16::from(hostname.len()) + 3 },
&NetAddress::Websocket { .. } => { 2 },
}
}

Expand Down Expand Up @@ -606,6 +613,9 @@ impl Writeable for NetAddress {
hostname.write(writer)?;
port.write(writer)?;
},
&NetAddress::Websocket { ref port } => {
port.write(writer)?;
},
}
Ok(())
}
Expand Down Expand Up @@ -642,6 +652,11 @@ impl Readable for Result<NetAddress, u8> {
port: Readable::read(reader)?,
}))
},
6 => {
Ok(Ok(NetAddress::Websocket {
port: Readable::read(reader)?,
}))
},
_ => return Ok(Err(byte)),
}
}
Expand Down

0 comments on commit 6241f6b

Please sign in to comment.