pub struct DhtRequest {
pub rpk: PublicKey,
pub spk: PublicKey,
pub nonce: Nonce,
pub payload: Vec<u8>,
}
Expand description
DHT Request packet struct. DHT Request packet consists of NatPingRequest and NatPingResponse. When my known friend is not connected directly, send NatPingRequest to peers which are in Ktree. When NatPingResponse arrives to me, it means that my known friend is also searching me, and running behind NAT, so start hole-punching.
https://zetok.github.io/tox-spec/#dht-request-packets
Length | Content |
---|---|
1 | 0x20 |
32 | Receiver’s Public Key |
32 | Sender’s Public Key |
24 | Nonce |
variable | Payload |
where Payload is encrypted DhtRequestPayload
Fields§
§rpk: PublicKey
receiver public key
spk: PublicKey
sender public key
nonce: Nonce
one time serial number
payload: Vec<u8>
payload of DhtRequest packet
Implementations§
Source§impl DhtRequest
impl DhtRequest
Sourcepub fn new(
shared_secret: &PrecomputedKey,
rpk: &PublicKey,
spk: &PublicKey,
dp: &DhtRequestPayload,
) -> DhtRequest
pub fn new( shared_secret: &PrecomputedKey, rpk: &PublicKey, spk: &PublicKey, dp: &DhtRequestPayload, ) -> DhtRequest
create new DhtRequest object
Sourcepub fn get_payload(
&self,
shared_secret: &PrecomputedKey,
) -> Result<DhtRequestPayload, GetPayloadError>
pub fn get_payload( &self, shared_secret: &PrecomputedKey, ) -> Result<DhtRequestPayload, GetPayloadError>
Decrypt payload and try to parse it as packet type.
Returns Error
in case of failure:
- fails to decrypt
- fails to parse as given packet type
Trait Implementations§
Source§impl Clone for DhtRequest
impl Clone for DhtRequest
Source§fn clone(&self) -> DhtRequest
fn clone(&self) -> DhtRequest
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for DhtRequest
impl Debug for DhtRequest
Source§impl FromBytes for DhtRequest
impl FromBytes for DhtRequest
Source§fn from_bytes(i: &[u8]) -> IResult<&[u8], DhtRequest, (&[u8], ErrorKind)>
fn from_bytes(i: &[u8]) -> IResult<&[u8], DhtRequest, (&[u8], ErrorKind)>
Deserialize struct using
nom
from raw bytesSource§impl PartialEq for DhtRequest
impl PartialEq for DhtRequest
Source§impl ToBytes for DhtRequest
impl ToBytes for DhtRequest
impl Eq for DhtRequest
impl StructuralPartialEq for DhtRequest
Auto Trait Implementations§
impl Freeze for DhtRequest
impl RefUnwindSafe for DhtRequest
impl Send for DhtRequest
impl Sync for DhtRequest
impl Unpin for DhtRequest
impl UnwindSafe for DhtRequest
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more