mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-07 13:03:45 +02:00
added explicit lifetime for session refs
This commit is contained in:
parent
b6e68d9e7c
commit
44d854e03a
3 changed files with 5 additions and 5 deletions
|
@ -19,7 +19,7 @@ pub trait ApplicationLayer: Sized {
|
||||||
type Data;
|
type Data;
|
||||||
|
|
||||||
/// Arbitrary object that dereferences to the session, such as Arc<Session<Self>>.
|
/// Arbitrary object that dereferences to the session, such as Arc<Session<Self>>.
|
||||||
type SessionRef: Deref<Target = Session<Self>>;
|
type SessionRef<'a>: Deref<Target = Session<Self>>;
|
||||||
|
|
||||||
/// A buffer containing data read from the network that can be cached.
|
/// A buffer containing data read from the network that can be cached.
|
||||||
///
|
///
|
||||||
|
@ -57,7 +57,7 @@ pub trait ApplicationLayer: Sized {
|
||||||
fn extract_s_public_from_raw(static_public: &[u8]) -> Option<P384PublicKey>;
|
fn extract_s_public_from_raw(static_public: &[u8]) -> Option<P384PublicKey>;
|
||||||
|
|
||||||
/// Look up a local session by local session ID or return None if not found.
|
/// Look up a local session by local session ID or return None if not found.
|
||||||
fn lookup_session(&self, local_session_id: SessionId) -> Option<Self::SessionRef>;
|
fn lookup_session<'a>(&self, local_session_id: SessionId) -> Option<Self::SessionRef<'a>>;
|
||||||
|
|
||||||
/// Rate limit and check an attempted new session (called before accept_new_session).
|
/// Rate limit and check an attempted new session (called before accept_new_session).
|
||||||
fn check_new_session(&self, rc: &ReceiveContext<Self>, remote_address: &Self::RemoteAddress) -> bool;
|
fn check_new_session(&self, rc: &ReceiveContext<Self>, remote_address: &Self::RemoteAddress) -> bool;
|
||||||
|
|
|
@ -45,7 +45,7 @@ mod tests {
|
||||||
|
|
||||||
impl ApplicationLayer for Box<TestHost> {
|
impl ApplicationLayer for Box<TestHost> {
|
||||||
type Data = u32;
|
type Data = u32;
|
||||||
type SessionRef = Arc<Session<Box<TestHost>>>;
|
type SessionRef<'a> = Arc<Session<Box<TestHost>>>;
|
||||||
type IncomingPacketBuffer = Vec<u8>;
|
type IncomingPacketBuffer = Vec<u8>;
|
||||||
type RemoteAddress = u32;
|
type RemoteAddress = u32;
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ mod tests {
|
||||||
P384PublicKey::from_bytes(static_public)
|
P384PublicKey::from_bytes(static_public)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn lookup_session(&self, local_session_id: SessionId) -> Option<Self::SessionRef> {
|
fn lookup_session<'a>(&self, local_session_id: SessionId) -> Option<Self::SessionRef<'a>> {
|
||||||
self.session.lock().unwrap().as_ref().and_then(|s| {
|
self.session.lock().unwrap().as_ref().and_then(|s| {
|
||||||
if s.id == local_session_id {
|
if s.id == local_session_id {
|
||||||
Some(s.clone())
|
Some(s.clone())
|
||||||
|
|
|
@ -638,7 +638,7 @@ impl<Application: ApplicationLayer> ReceiveContext<Application> {
|
||||||
canonical_header_bytes: &[u8; 12],
|
canonical_header_bytes: &[u8; 12],
|
||||||
fragments: &[Application::IncomingPacketBuffer],
|
fragments: &[Application::IncomingPacketBuffer],
|
||||||
packet_type: u8,
|
packet_type: u8,
|
||||||
session: Option<Application::SessionRef>,
|
session: Option<Application::SessionRef<'a>>,
|
||||||
mtu: usize,
|
mtu: usize,
|
||||||
current_time: i64,
|
current_time: i64,
|
||||||
) -> Result<ReceiveResult<'a, Application>, Error> {
|
) -> Result<ReceiveResult<'a, Application>, Error> {
|
||||||
|
|
Loading…
Add table
Reference in a new issue