summaryrefslogtreecommitdiffstats
path: root/src/wireguard/router/workers.rs
diff options
context:
space:
mode:
authorMathias Hall-Andersen <mathias@hall-andersen.dk>2019-11-04 13:19:27 +0100
committerMathias Hall-Andersen <mathias@hall-andersen.dk>2019-11-04 13:19:27 +0100
commit6ba40f17cb484c0b9b76caf926ef24539892d5a6 (patch)
tree4df08b852aab26bfe37c144123a377e4fd28acb2 /src/wireguard/router/workers.rs
parentWork on UAPI parser (diff)
downloadwireguard-rs-6ba40f17cb484c0b9b76caf926ef24539892d5a6.tar.xz
wireguard-rs-6ba40f17cb484c0b9b76caf926ef24539892d5a6.zip
Work on Up/Down operation on WireGuard device
Diffstat (limited to 'src/wireguard/router/workers.rs')
-rw-r--r--src/wireguard/router/workers.rs22
1 files changed, 3 insertions, 19 deletions
diff --git a/src/wireguard/router/workers.rs b/src/wireguard/router/workers.rs
index 08c2db9..5482cee 100644
--- a/src/wireguard/router/workers.rs
+++ b/src/wireguard/router/workers.rs
@@ -141,8 +141,7 @@ pub fn worker_inbound<E: Endpoint, C: Callbacks, T: tun::Writer, B: bind::Writer
/* TODO: Replace with run-queue
*/
pub fn worker_outbound<E: Endpoint, C: Callbacks, T: tun::Writer, B: bind::Writer<E>>(
- device: Arc<DeviceInner<E, C, T, B>>, // related device
- peer: Arc<PeerInner<E, C, T, B>>, // related peer
+ peer: Arc<PeerInner<E, C, T, B>>,
receiver: Receiver<JobOutbound>,
) {
loop {
@@ -160,23 +159,8 @@ pub fn worker_outbound<E: Endpoint, C: Callbacks, T: tun::Writer, B: bind::Write
.map(|buf| {
debug!("outbound worker: job complete");
- // write to UDP bind
- let xmit = if let Some(dst) = peer.endpoint.lock().as_ref() {
- let send: &Option<B> = &*device.outbound.read();
- if let Some(writer) = send.as_ref() {
- match writer.write(&buf.msg[..], dst) {
- Err(e) => {
- debug!("failed to send outbound packet: {:?}", e);
- false
- }
- Ok(_) => true,
- }
- } else {
- false
- }
- } else {
- false
- };
+ // send to peer
+ let xmit = peer.send(&buf.msg[..]).is_ok();
// trigger callback
C::send(&peer.opaque, buf.msg.len(), xmit, &buf.keypair, buf.counter);