Skip to content

Commit

Permalink
Merge branch 'master' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
drozdziak1 committed Aug 16, 2018
2 parents dd85e7c + 920d3d1 commit e700804
Show file tree
Hide file tree
Showing 69 changed files with 2,601 additions and 2,032 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ integration-tests/staging*
integration-tests/althea_rs_*
integration-tests/target*
integration-tests/mail/*
integration-tests/bounty.db-journal
41 changes: 20 additions & 21 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,33 @@ before_install:
- which diesel || cargo install diesel_cli --no-default-features --features sqlite
- sudo cp $(which diesel) /usr/bin
env:
- TEST_COMMAND="rustup component add rustfmt-preview --toolchain nightly && cargo fmt --all -- --check"
- TEST_COMMAND="rustup component add rustfmt-preview --toolchain nightly && cargo +nightly fmt --all -- --check"
- TEST_COMMAND="cargo build --verbose --all"
- TEST_COMMAND="./integration-tests/cross-build.sh"
- TEST_COMMAND="cargo test --verbose --all" RUST_TEST_THREADS=1
- TEST_COMMAND="./integration-tests/rita.sh" INITIAL_POLL_INTERVAL=5 BACKOFF_FACTOR="1.5" VERBOSE=1
- TEST_COMMAND="./integration-tests/rita.sh" REVISION_B=release COMPAT_LAYOUT="inner_ring_old" INITIAL_POLL_INTERVAL=5 BACKOFF_FACTOR="1.5" VERBOSE=1
- TEST_COMMAND="./integration-tests/rita.sh" REVISION_B=master COMPAT_LAYOUT="inner_ring_old" INITIAL_POLL_INTERVAL=5 BACKOFF_FACTOR="1.5" VERBOSE=1
rust:
- stable
- beta
- nightly
script:
- (eval "$TEST_COMMAND")
matrix:
allow_failures:
- rust: beta
- rust: nightly
env: TEST_COMMAND="cargo build --verbose --all"
- rust: nightly
env: TEST_COMMAND="cargo test --verbose --all" RUST_TEST_THREADS=1
exclude:
- rust: stable
env: TEST_COMMAND="rustup component add rustfmt-preview --toolchain nightly && cargo fmt --all -- --check"
- rust: beta
env: TEST_COMMAND="rustup component add rustfmt-preview --toolchain nightly && cargo fmt --all -- --check"
- rust: stable
env: TEST_COMMAND="./integration-tests/cross-build.sh"
- rust: beta
env: TEST_COMMAND="./integration-tests/cross-build.sh"
- rust: stable
env: TEST_COMMAND="./integration-tests/rita.sh" REVISION_B=release COMPAT_LAYOUT="inner_ring_old" INITIAL_POLL_INTERVAL=5 BACKOFF_FACTOR="1.5" VERBOSE=1
- rust: beta
env: TEST_COMMAND="./integration-tests/rita.sh" REVISION_B=release COMPAT_LAYOUT="inner_ring_old" INITIAL_POLL_INTERVAL=5 BACKOFF_FACTOR="1.5" VERBOSE=1
- rust: stable
env: TEST_COMMAND="./integration-tests/rita.sh" REVISION_B=master COMPAT_LAYOUT="inner_ring_old" INITIAL_POLL_INTERVAL=5 BACKOFF_FACTOR="1.5" VERBOSE=1
- rust: beta
env: TEST_COMMAND="./integration-tests/rita.sh" REVISION_B=master COMPAT_LAYOUT="inner_ring_old" INITIAL_POLL_INTERVAL=5 BACKOFF_FACTOR="1.5" VERBOSE=1
- rust: beta
env: TEST_COMMAND="rustup component add rustfmt-preview --toolchain nightly && cargo +nightly fmt --all -- --check"
- rust: stable
env: TEST_COMMAND="rustup component add rustfmt-preview --toolchain nightly && cargo +nightly fmt --all -- --check"
include:
- name: "Cross compile on MIPS"
script: ./integration-tests/cross-build.sh
- script: ./integration-tests/rita.sh
env: INITIAL_POLL_INTERVAL=5 BACKOFF_FACTOR="1.5" VERBOSE=1
- script: ./integration-tests/rita.sh
env: REVISION_B=release REMOTE_A=.. REMOTE_B="https://github.com/althea-mesh/althea_rs.git" COMPAT_LAYOUT="inner_ring_old" INITIAL_POLL_INTERVAL=5 BACKOFF_FACTOR="1.5" VERBOSE=1
- script: ./integration-tests/rita.sh
env: REVISION_B=master REMOTE_A=.. REMOTE_B="https://github.com/althea-mesh/althea_rs.git" COMPAT_LAYOUT="inner_ring_old" INITIAL_POLL_INTERVAL=5 BACKOFF_FACTOR="1.5" VERBOSE=1
908 changes: 475 additions & 433 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
[package]
name = "althea_rs"
version = "0.1.4"
version = "0.1.5"
authors = ["Stan Drozd <[email protected]>"]

[features]
development = ["rita/development"]

[dependencies]
rita = { path = "./rita" }

Expand All @@ -11,7 +14,6 @@ members = ["althea_kernel_interface", "bounty_hunter", "settings", "clu", "exit_

[profile.release]
opt-level = "z"
debug=true
lto = true
codegen-units = 1
incremental = false
Expand Down
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@ You are now ready to build code from this Rust repository by running

cargo build --all

If you want to build a development build that contains unsafe options that are not suitable for production usage:

cargo build --all --features development

## Development

Please install required git hooks before contributing. Those hooks are responsible for making the codebase consistent.

```sh
rustup component add rustfmt-preview --toolchain nightly
cd .git/hooks && ln -s ../../scripts/.git-hooks/pre-commit
```

## Components

### Rita
Expand Down
10 changes: 5 additions & 5 deletions althea_kernel_interface/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ description = "Gets information from and changes settings of kernel network stac
license = "Apache-2.0"

[dependencies]
regex = "0.2"
failure = "0.1.1"
itertools = "0.7.4"
log = "^0.4"
lazy_static = "1.0"
regex = "1.0.2"
failure = "0.1.2"
itertools = "0.7.8"
log = "0.4.3"
lazy_static = "1.0.2"
eui48 = { git = "https://github.com/althea-mesh/eui48", features = ["serde"] }
34 changes: 34 additions & 0 deletions althea_kernel_interface/src/dns.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
use super::KernelInterface;

use std::fs::File;
use std::io::Error;
use std::io::Read;
use std::net::IpAddr;

impl KernelInterface {
/// Gets a list of IP addresses of nameservers from /etc/resolv.conf, may be v6, v4 or both
/// generally ignores malformed lines but produces IO errors
pub fn get_resolv_servers(&self) -> Result<Vec<IpAddr>, Error> {
let mut f = File::open("/etc/resolv.conf")?;
let mut contents = String::new();
f.read_to_string(&mut contents)?;

let mut res = Vec::new();
for line in contents.lines() {
if line.starts_with("nameserver") {
let mut nameserver = line.split(" ");
nameserver.next();
match nameserver.next() {
Some(ip) => match ip.parse() {
Ok(addr) => res.push(addr),
Err(e) => {
warn!("Could not parse /etc/resolv.conf ip {:?} with {:?}", ip, e)
}
},
None => warn!("Invalid /etc/resolv.conf!"),
}
}
}
Ok(res)
}
}
2 changes: 1 addition & 1 deletion althea_kernel_interface/src/exit_server_tunnel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub struct ExitClient {
impl KernelInterface {
pub fn set_exit_wg_config(
&self,
clients: Vec<(ExitClient)>,
clients: Vec<ExitClient>,
listen_port: u16,
private_key_path: &str,
local_ip: &IpAddr,
Expand Down
3 changes: 1 addition & 2 deletions althea_kernel_interface/src/interface_tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,7 @@ fn test_get_wg_remote_ip() {
assert_eq!(args, &["show", "wg0", "endpoints"]);
Ok(Output {
stdout: b"fvLYbeMV+RYbzJEc4lNEPuK8ulva/5wcSJBz0W5t3hM= 71.8.186.226:60000\
"
.to_vec(),
".to_vec(),
stderr: b"".to_vec(),
status: ExitStatus::from_raw(0),
})
Expand Down
1 change: 1 addition & 0 deletions althea_kernel_interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use std::str;
mod counter;
mod create_wg_key;
mod delete_tunnel;
mod dns;
mod exit_client_tunnel;
mod exit_server_counter;
mod exit_server_tunnel;
Expand Down
14 changes: 7 additions & 7 deletions althea_kernel_interface/src/link_local_tools.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use super::{KernelInterface, KernelInterfaceError};

use std::net::IpAddr;
use std::net::{IpAddr, Ipv6Addr};

use regex::Regex;

use failure::Error;

impl KernelInterface {
/// This gets our link local ip for a given device
pub fn get_link_local_device_ip(&self, dev: &str) -> Result<IpAddr, Error> {
pub fn get_link_local_device_ip(&self, dev: &str) -> Result<Ipv6Addr, Error> {
let output = self.run_command("ip", &["addr", "show", "dev", dev, "scope", "link"])?;
trace!("Got {:?} from `ip addr`", output);

Expand All @@ -17,7 +17,7 @@ impl KernelInterface {
let cap = re.captures(&str);
if let Some(cap) = cap {
trace!("got link local IP of {} from device {}", &cap[1], &dev);
Ok(cap[1].parse()?)
Ok(cap[1].parse::<Ipv6Addr>()?)
} else {
Err(KernelInterfaceError::RuntimeError(
"No link local addresses found or no interface found".to_string(),
Expand All @@ -26,7 +26,7 @@ impl KernelInterface {
}

/// This gets our global ip for a given device
pub fn get_global_device_ip(&self, dev: &str) -> Result<IpAddr, Error> {
pub fn get_global_device_ip(&self, dev: &str) -> Result<Ipv6Addr, Error> {
let output = self.run_command("ip", &["addr", "show", "dev", dev, "scope", "global"])?;
trace!("Got {:?} from `ip addr`", output);

Expand All @@ -35,7 +35,7 @@ impl KernelInterface {
let cap = re.captures(&str);
if let Some(cap) = cap {
trace!("got global IP of {} from device {}", &cap[1], &dev);
Ok(cap[1].parse()?)
Ok(cap[1].parse::<Ipv6Addr>()?)
} else {
Err(KernelInterfaceError::RuntimeError(
"No global found or no interface found".to_string(),
Expand All @@ -59,9 +59,9 @@ impl KernelInterface {
/// This gets our link local ip that can be reached by another node with link local ip
pub fn get_reply_ip(
&self,
their_ip: IpAddr,
their_ip: Ipv6Addr,
external_interface: Option<String>,
) -> Result<IpAddr, Error> {
) -> Result<Ipv6Addr, Error> {
let neigh = self.get_neighbors()?;

trace!("Looking for {:?} in {:?} for reply ip", their_ip, neigh);
Expand Down
12 changes: 6 additions & 6 deletions althea_types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ authors = ["Jehan <[email protected]>"]

[dependencies]
num256 = { path = "../num256" }
base64 = "0.9.0"
serde_derive = "1.0.24"
serde = "1.0.24"
serde_json = "1.0.8"
hex = "0.3.1"
base64 = "0.9.2"
serde_derive = "1.0.70"
serde = "1.0.70"
serde_json = "1.0.24"
hex = "0.3.2"
eui48 = { git = "https://github.com/althea-mesh/eui48", features = ["serde"] }
actix = { git = "https://github.com/kingoflolz/actix", branch = "althea-mesh", optional=true}
ethereum-types = {git="https://github.com/paritytech/primitives.git"}
ethereum-types = {git="https://github.com/paritytech/primitives.git"}
1 change: 1 addition & 0 deletions althea_types/src/interop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ impl Message for Identity {
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Hash, Clone)]
pub struct LocalIdentity {
pub wg_port: u16,
pub have_tunnel: Option<bool>, // If we have an existing tunnel, None if we don't know
pub global: Identity,
}

Expand Down
10 changes: 5 additions & 5 deletions babel_monitor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ authors = ["jkilpatr <[email protected]>"]

[dependencies]
mockstream = { git = "https://github.com/lazy-bitfield/rust-mockstream.git" }
ascii = "0.8.6"
bufstream = "0.1"
ascii = "0.9.0"
bufstream = "0.1.3"
ipnetwork = "0.13.0"
failure = "0.1.1"
log = "^0.4"
env_logger = "0.5"
failure = "0.1.2"
log = "0.4.3"
env_logger = "0.5.11"
18 changes: 9 additions & 9 deletions bounty_hunter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ version = "0.1.0"
authors = ["kingoflolz <[email protected]>"]

[dependencies]
log = "^0.4"
env_logger = "^0.5.5"
log = "0.4.3"
env_logger = "0.5.11"
num256 = { path = "../num256" }
althea_types = { path = "../althea_types" }
diesel = { version = "=1.2.0", features = ["sqlite"] }
dotenv = "0.9.0"
serde = "1.0.24"
serde_derive = "1.0.24"
serde_json = "1.0.8"
diesel = { version = "1.3.2", features = ["sqlite"] }
dotenv = "0.13.0"
serde = "1.0.70"
serde_derive = "1.0.70"
serde_json = "1.0.24"

[dependencies.rouille]
version = "2.0"
default-features = false
version = "2.1.0"
default-features = false
20 changes: 10 additions & 10 deletions clu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ authors = ["Justin <[email protected]>"]
settings = { path = "../settings" }
althea_kernel_interface = { path = "../althea_kernel_interface" }
althea_types = { path = "../althea_types" }
lazy_static = "1.0"
docopt = "0.8.1"
log = "^0.4"
env_logger = "^0.5.5"
failure = "0.1.1"
lazy_static = "1.0.2"
docopt = "0.8.3"
log = "0.4.3"
env_logger = "0.5.11"
failure = "0.1.2"
ipgen = "0.0.4"
regex = "0.2"
rand = "0.4"
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
regex = "1.0.2"
rand = "0.5.4"
serde = "1.0.70"
serde_derive = "1.0.70"
serde_json = "1.0.24"
7 changes: 4 additions & 3 deletions clu/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use failure::Error;
use althea_kernel_interface::KI;

extern crate althea_kernel_interface;
use rand::distributions::Alphanumeric;
use regex::Regex;
use std::path::Path;
use std::sync::{Arc, RwLock};
Expand All @@ -33,7 +34,7 @@ pub enum CluError {
RuntimeError(String),
}

fn linux_generate_wg_keys(config: &mut NetworkSettings) -> Result<(), Error> {
pub fn linux_generate_wg_keys(config: &mut NetworkSettings) -> Result<(), Error> {
let keys = KI.create_wg_keypair()?;
let wg_public_key = &keys[0];
let wg_private_key = &keys[1];
Expand All @@ -45,8 +46,8 @@ fn linux_generate_wg_keys(config: &mut NetworkSettings) -> Result<(), Error> {
Ok(())
}

fn linux_generate_mesh_ip(config: &mut NetworkSettings) -> Result<(), Error> {
let seed: String = thread_rng().gen_ascii_chars().take(50).collect();
pub fn linux_generate_mesh_ip(config: &mut NetworkSettings) -> Result<(), Error> {
let seed: String = thread_rng().sample_iter(&Alphanumeric).take(50).collect();
let mesh_ip = ipgen::ip(&seed, "fd00::/8").unwrap();

info!("generated new ip address {}", mesh_ip);
Expand Down
Loading

0 comments on commit e700804

Please sign in to comment.