pub struct PingRequest {
pub pk: PublicKey,
pub nonce: Nonce,
pub payload: Vec<u8>,
}
Expand description
Ping request packet struct. Every 60 seconds DHT node sends PingRequest
packet to peers to check whether it is alive. When PingRequest
is received
DHT node should respond with PingResponse
that contains the same ping id
inside it’s encrypted payload as it got from PingRequest
. If PingResponse
doesn’t arrive for 122 seconds the DHT node removes peer from ktree and marks
it as offline if the peer is known friend.
https://zetok.github.io/tox-spec/#dht-packet
Length | Content |
---|---|
1 | 0x00 |
32 | Public Key |
24 | Nonce |
25 | Payload |
where Payload is encrypted PingRequestPayload
Fields§
§pk: PublicKey
public key used for payload encryption
nonce: Nonce
one time serial number
payload: Vec<u8>
encrypted payload
Implementations§
Source§impl PingRequest
impl PingRequest
Sourcepub fn new(
shared_secret: &PrecomputedKey,
pk: &PublicKey,
payload: &PingRequestPayload,
) -> PingRequest
pub fn new( shared_secret: &PrecomputedKey, pk: &PublicKey, payload: &PingRequestPayload, ) -> PingRequest
create new PingRequest object
Sourcepub fn get_payload(
&self,
shared_secret: &PrecomputedKey,
) -> Result<PingRequestPayload, GetPayloadError>
pub fn get_payload( &self, shared_secret: &PrecomputedKey, ) -> Result<PingRequestPayload, GetPayloadError>
Decrypt payload and try to parse it as PingRequestPayload
.
Returns Error
in case of failure:
- fails to decrypt
- fails to parse as given packet type
Trait Implementations§
Source§impl Clone for PingRequest
impl Clone for PingRequest
Source§fn clone(&self) -> PingRequest
fn clone(&self) -> PingRequest
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 PingRequest
impl Debug for PingRequest
Source§impl FromBytes for PingRequest
impl FromBytes for PingRequest
Source§fn from_bytes(i: &[u8]) -> IResult<&[u8], PingRequest, (&[u8], ErrorKind)>
fn from_bytes(i: &[u8]) -> IResult<&[u8], PingRequest, (&[u8], ErrorKind)>
Deserialize struct using
nom
from raw bytesSource§impl PartialEq for PingRequest
impl PartialEq for PingRequest
Source§impl ToBytes for PingRequest
impl ToBytes for PingRequest
impl Eq for PingRequest
impl StructuralPartialEq for PingRequest
Auto Trait Implementations§
impl Freeze for PingRequest
impl RefUnwindSafe for PingRequest
impl Send for PingRequest
impl Sync for PingRequest
impl Unpin for PingRequest
impl UnwindSafe for PingRequest
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