mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-04-26 17:03:43 +02:00
Have caller into inner protocol send cursor in case it needs to be different from 0/1.
This commit is contained in:
parent
b0ffd4f56b
commit
752dbf4816
4 changed files with 18 additions and 36 deletions
|
@ -97,30 +97,8 @@ impl<DatabaseImpl: Database> Handler<DatabaseImpl> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<DatabaseImpl: Database> PathFilter for Handler<DatabaseImpl> {
|
||||
fn should_use_physical_path<HostSystemImpl: HostSystem + ?Sized>(
|
||||
&self,
|
||||
_id: &Identity,
|
||||
_endpoint: &zerotier_network_hypervisor::vl1::Endpoint,
|
||||
_local_socket: Option<&HostSystemImpl::LocalSocket>,
|
||||
_local_interface: Option<&HostSystemImpl::LocalInterface>,
|
||||
) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn get_path_hints<HostSystemImpl: HostSystem + ?Sized>(
|
||||
&self,
|
||||
_id: &Identity,
|
||||
) -> Option<
|
||||
Vec<(
|
||||
zerotier_network_hypervisor::vl1::Endpoint,
|
||||
Option<HostSystemImpl::LocalSocket>,
|
||||
Option<HostSystemImpl::LocalInterface>,
|
||||
)>,
|
||||
> {
|
||||
None
|
||||
}
|
||||
}
|
||||
// Default PathFilter implementations permit anything.
|
||||
impl<DatabaseImpl: Database> PathFilter for Handler<DatabaseImpl> {}
|
||||
|
||||
impl<DatabaseImpl: Database> InnerProtocol for Handler<DatabaseImpl> {
|
||||
fn handle_packet<HostSystemImpl: HostSystem + ?Sized>(
|
||||
|
@ -133,11 +111,10 @@ impl<DatabaseImpl: Database> InnerProtocol for Handler<DatabaseImpl> {
|
|||
message_id: u64,
|
||||
verb: u8,
|
||||
payload: &PacketBuffer,
|
||||
mut cursor: usize,
|
||||
) -> PacketHandlerResult {
|
||||
match verb {
|
||||
protocol::verbs::VL2_VERB_NETWORK_CONFIG_REQUEST => {
|
||||
let mut cursor = 1;
|
||||
|
||||
let network_id = payload.read_u64(&mut cursor);
|
||||
if network_id.is_err() {
|
||||
return PacketHandlerResult::Error;
|
||||
|
@ -242,7 +219,7 @@ impl<DatabaseImpl: Database> InnerProtocol for Handler<DatabaseImpl> {
|
|||
_in_re_message_id: u64,
|
||||
_error_code: u8,
|
||||
_payload: &PacketBuffer,
|
||||
_cursor: &mut usize,
|
||||
_cursor: usize,
|
||||
) -> PacketHandlerResult {
|
||||
PacketHandlerResult::NotHandled
|
||||
}
|
||||
|
@ -258,7 +235,7 @@ impl<DatabaseImpl: Database> InnerProtocol for Handler<DatabaseImpl> {
|
|||
_in_re_verb: u8,
|
||||
_in_re_message_id: u64,
|
||||
_payload: &PacketBuffer,
|
||||
_cursor: &mut usize,
|
||||
_cursor: usize,
|
||||
) -> PacketHandlerResult {
|
||||
PacketHandlerResult::NotHandled
|
||||
}
|
||||
|
|
|
@ -154,6 +154,7 @@ pub trait InnerProtocol: Sync + Send {
|
|||
message_id: u64,
|
||||
verb: u8,
|
||||
payload: &PacketBuffer,
|
||||
cursor: usize,
|
||||
) -> PacketHandlerResult;
|
||||
|
||||
/// Handle errors, returning true if the error was recognized.
|
||||
|
@ -169,7 +170,7 @@ pub trait InnerProtocol: Sync + Send {
|
|||
in_re_message_id: u64,
|
||||
error_code: u8,
|
||||
payload: &PacketBuffer,
|
||||
cursor: &mut usize,
|
||||
cursor: usize,
|
||||
) -> PacketHandlerResult;
|
||||
|
||||
/// Handle an OK, returing true if the OK was recognized.
|
||||
|
@ -184,7 +185,7 @@ pub trait InnerProtocol: Sync + Send {
|
|||
in_re_verb: u8,
|
||||
in_re_message_id: u64,
|
||||
payload: &PacketBuffer,
|
||||
cursor: &mut usize,
|
||||
cursor: usize,
|
||||
) -> PacketHandlerResult;
|
||||
|
||||
/// Check if this node should respond to messages from a given peer.
|
||||
|
@ -1092,6 +1093,7 @@ impl InnerProtocol for DummyInnerProtocol {
|
|||
_message_id: u64,
|
||||
_verb: u8,
|
||||
_payload: &PacketBuffer,
|
||||
_cursor: usize,
|
||||
) -> PacketHandlerResult {
|
||||
PacketHandlerResult::NotHandled
|
||||
}
|
||||
|
@ -1109,7 +1111,7 @@ impl InnerProtocol for DummyInnerProtocol {
|
|||
_in_re_message_id: u64,
|
||||
_error_code: u8,
|
||||
_payload: &PacketBuffer,
|
||||
_cursor: &mut usize,
|
||||
_cursor: usize,
|
||||
) -> PacketHandlerResult {
|
||||
PacketHandlerResult::NotHandled
|
||||
}
|
||||
|
@ -1126,7 +1128,7 @@ impl InnerProtocol for DummyInnerProtocol {
|
|||
_in_re_verb: u8,
|
||||
_in_re_message_id: u64,
|
||||
_payload: &PacketBuffer,
|
||||
_cursor: &mut usize,
|
||||
_cursor: usize,
|
||||
) -> PacketHandlerResult {
|
||||
PacketHandlerResult::NotHandled
|
||||
}
|
||||
|
|
|
@ -585,6 +585,7 @@ impl Peer {
|
|||
message_id,
|
||||
verb,
|
||||
&payload,
|
||||
1,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
@ -682,7 +683,7 @@ impl Peer {
|
|||
in_re_message_id,
|
||||
error_header.error_code,
|
||||
payload,
|
||||
&mut cursor,
|
||||
cursor,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -782,7 +783,7 @@ impl Peer {
|
|||
ok_header.in_re_verb,
|
||||
in_re_message_id,
|
||||
payload,
|
||||
&mut cursor,
|
||||
cursor,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ pub trait SwitchInterface: Sync + Send {}
|
|||
|
||||
pub struct Switch {}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
impl InnerProtocol for Switch {
|
||||
fn handle_packet<HostSystemImpl: HostSystem + ?Sized>(
|
||||
&self,
|
||||
|
@ -21,6 +22,7 @@ impl InnerProtocol for Switch {
|
|||
message_id: u64,
|
||||
verb: u8,
|
||||
payload: &PacketBuffer,
|
||||
cursor: usize,
|
||||
) -> PacketHandlerResult {
|
||||
PacketHandlerResult::NotHandled
|
||||
}
|
||||
|
@ -37,7 +39,7 @@ impl InnerProtocol for Switch {
|
|||
in_re_message_id: u64,
|
||||
error_code: u8,
|
||||
payload: &PacketBuffer,
|
||||
cursor: &mut usize,
|
||||
cursor: usize,
|
||||
) -> PacketHandlerResult {
|
||||
PacketHandlerResult::NotHandled
|
||||
}
|
||||
|
@ -53,7 +55,7 @@ impl InnerProtocol for Switch {
|
|||
in_re_verb: u8,
|
||||
in_re_message_id: u64,
|
||||
payload: &PacketBuffer,
|
||||
cursor: &mut usize,
|
||||
cursor: usize,
|
||||
) -> PacketHandlerResult {
|
||||
PacketHandlerResult::NotHandled
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue