This commit is contained in:
parent
67cda61245
commit
804a7fec47
@ -1,15 +1,7 @@
|
|||||||
use crate::listener::*;
|
use crate::listener::*;
|
||||||
use crate::*;
|
use crate::*;
|
||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::{HashMap, HashSet};
|
||||||
use std::env;
|
use std::time;
|
||||||
use std::fmt;
|
|
||||||
use std::io::prelude::*;
|
|
||||||
use std::io::{BufRead, BufReader, Error, ErrorKind, Result};
|
|
||||||
use std::net::SocketAddr;
|
|
||||||
use std::os::unix::net::UnixStream;
|
|
||||||
use std::path::PathBuf;
|
|
||||||
use std::rc::Rc;
|
|
||||||
use std::{thread, time};
|
|
||||||
|
|
||||||
pub(crate) fn gen_events(
|
pub(crate) fn gen_events(
|
||||||
state: &HashMap<String, Peer>,
|
state: &HashMap<String, Peer>,
|
||||||
@ -115,7 +107,7 @@ mod test {
|
|||||||
.push(format!("rem {}", peer.public_key));
|
.push(format!("rem {}", peer.public_key));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn roaming<'a>(&self, peer: &'a Peer, previous_addr: SocketAddr) {
|
fn roaming<'a>(&self, peer: &'a Peer, _previous_addr: SocketAddr) {
|
||||||
self.calls
|
self.calls
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
.push(format!("rom {}", peer.public_key));
|
.push(format!("rom {}", peer.public_key));
|
||||||
@ -227,7 +219,7 @@ mod test {
|
|||||||
|
|
||||||
calls.borrow_mut().clear();
|
calls.borrow_mut().clear();
|
||||||
|
|
||||||
let mut peer_prev = peer.clone();
|
let peer_prev = peer.clone();
|
||||||
|
|
||||||
peer_cur.last_handshake = Some(time::Duration::from_secs(5));
|
peer_cur.last_handshake = Some(time::Duration::from_secs(5));
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ impl ScriptListener {
|
|||||||
ScriptListener { script }
|
ScriptListener { script }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn peer_props<'a>(&self,peer: &'a Peer) -> String {
|
fn peer_props<'a>(&self, peer: &'a Peer) -> String {
|
||||||
format!(
|
format!(
|
||||||
"{id} {allowed_ips} {endpoint} {last_handshake} {persistent_keepalive} {traffic}",
|
"{id} {allowed_ips} {endpoint} {last_handshake} {persistent_keepalive} {traffic}",
|
||||||
id = peer.public_key,
|
id = peer.public_key,
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
mod gen;
|
mod gen;
|
||||||
mod listener;
|
mod listener;
|
||||||
|
|
||||||
use crate::gen::*;
|
use listener::*;
|
||||||
use crate::listener::*;
|
|
||||||
|
|
||||||
use base64;
|
use base64;
|
||||||
use hex;
|
use hex;
|
||||||
@ -135,16 +134,6 @@ impl State {
|
|||||||
pub fn push(&mut self, key: String, value: String) {
|
pub fn push(&mut self, key: String, value: String) {
|
||||||
self.kv_mut().push((key, value));
|
self.kv_mut().push((key, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn delta(&self, other: Self) -> Vec<KV> {
|
|
||||||
let kv = self.kv();
|
|
||||||
other
|
|
||||||
.kv()
|
|
||||||
.iter()
|
|
||||||
.filter(|pair| !kv.contains(pair))
|
|
||||||
.map(|p| p.clone())
|
|
||||||
.collect::<Vec<KV>>()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for State {
|
impl fmt::Display for State {
|
||||||
@ -185,7 +174,7 @@ impl Socket {
|
|||||||
format!("Socket said error: {}", value),
|
format!("Socket said error: {}", value),
|
||||||
))?;
|
))?;
|
||||||
break;
|
break;
|
||||||
},
|
}
|
||||||
"public_key" | "private_key" => {
|
"public_key" | "private_key" => {
|
||||||
state.push(cur);
|
state.push(cur);
|
||||||
cur = if key == "private_key" {
|
cur = if key == "private_key" {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user