Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various dependency updates #265

Merged
merged 11 commits into from
Jun 1, 2023
768 changes: 538 additions & 230 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ path = "src/main.rs"
[dependencies]
anyhow = "1"
colored = "2"
clap = { version = "3", features = ["derive"] }
clap_complete = "3"
clap = { version = "4.3", features = ["derive", "wrap_help"] }
clap_complete = "4.3"
dialoguer = { version = "0.10", default-features = false }
hostsfile = { path = "../hostsfile" }
indoc = "1"
indoc = "2.0.1"
ipnet = { version = "2.4", features = ["serde"] }
log = "0.4"
regex = { version = "1", default-features = false, features = ["std"] }
Expand Down
14 changes: 7 additions & 7 deletions client/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use anyhow::{anyhow, bail};
use clap::{AppSettings, Args, IntoApp, Parser, Subcommand};
use clap::{ArgAction, Args, Parser, Subcommand};
use colored::*;
use dialoguer::{Confirm, Input};
use hostsfile::HostsBuilder;
Expand Down Expand Up @@ -47,15 +47,14 @@ macro_rules! println_pad {
}

#[derive(Clone, Debug, Parser)]
#[clap(name = "innernet", author, version, about)]
#[clap(global_setting(AppSettings::DeriveDisplayOrder))]
#[command(name = "innernet", author, version, about)]
struct Opts {
#[clap(subcommand)]
command: Option<Command>,

/// Verbose output, use -vv for even higher verbositude
#[clap(short, long, parse(from_occurrences))]
verbose: u64,
#[clap(short, long, action = ArgAction::Count)]
verbose: u8,

#[clap(short, long, default_value = "/etc/innernet")]
config_dir: PathBuf,
Expand All @@ -74,7 +73,7 @@ struct HostsOpt {
hosts_path: PathBuf,

/// Don't write to any hosts files
#[clap(long = "no-write-hosts", conflicts_with = "hosts-path")]
#[clap(long = "no-write-hosts", conflicts_with = "hosts_path")]
no_write_hosts: bool,
}

Expand Down Expand Up @@ -254,7 +253,7 @@ enum Command {

/// Generate shell completion scripts
Completions {
#[clap(arg_enum)]
#[clap(value_enum)]
shell: clap_complete::Shell,
},
}
Expand Down Expand Up @@ -1275,6 +1274,7 @@ fn run(opts: &Opts) -> Result<(), Error> {
override_endpoint(&interface, opts, sub_opts)?;
},
Command::Completions { shell } => {
use clap::CommandFactory;
let mut app = Opts::command();
let app_name = app.get_name().to_string();
clap_complete::generate(shell, &mut app, app_name, &mut std::io::stdout());
Expand Down
2 changes: 1 addition & 1 deletion client/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl log::Log for Logger {
fn flush(&self) {}
}

pub fn init_logger(verbosity: u64) {
pub fn init_logger(verbosity: u8) {
let level = match verbosity {
0 => log::LevelFilter::Info,
1 => log::LevelFilter::Debug,
Expand Down
9 changes: 5 additions & 4 deletions netlink-request/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ version = "1.5.5"
edition = "2021"

[target.'cfg(target_os = "linux")'.dependencies]
netlink-sys = "0.8"
netlink-packet-core = "0.4"
netlink-packet-generic = "0.3"
netlink-packet-route = "0.13"
netlink-sys = "0.8.5"
netlink-packet-core = "0.5"
netlink-packet-generic = "0.3.2"
netlink-packet-route = "0.15"
netlink-packet-utils = "0.5.2"
nix = { version = "0.25", features = ["feature"] }
once_cell = "1"
7 changes: 4 additions & 3 deletions netlink-request/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ mod linux {
use netlink_packet_generic::{
constants::GENL_HDRLEN,
ctrl::{nlas::GenlCtrlAttrs, GenlCtrl, GenlCtrlCmd},
GenlFamily, GenlMessage,
GenlFamily, GenlHeader, GenlMessage,
};
use netlink_packet_route::RtnlMessage;
use netlink_packet_utils::{Emitable, ParseableParametrized};
use netlink_sys::{constants::NETLINK_GENERIC, protocols::NETLINK_ROUTE, Socket};
use nix::unistd::{sysconf, SysconfVar};
use once_cell::sync::OnceCell;
Expand Down Expand Up @@ -49,7 +50,7 @@ mod linux {
flags: Option<u16>,
) -> Result<Vec<NetlinkMessage<GenlMessage<F>>>, io::Error>
where
F: GenlFamily + Clone + Debug + Eq,
F: GenlFamily + Clone + Debug + Eq + Emitable + ParseableParametrized<[u8], GenlHeader>,
GenlMessage<F>: Clone + Debug + Eq + NetlinkSerializable + NetlinkDeserializable,
{
if message.family_id() == 0 {
Expand Down Expand Up @@ -98,7 +99,7 @@ mod linux {
) -> Result<Vec<NetlinkMessage<I>>, io::Error>
where
NetlinkPayload<I>: From<I>,
I: Clone + Debug + Eq + NetlinkSerializable + NetlinkDeserializable,
I: Clone + Debug + Eq + Emitable + NetlinkSerializable + NetlinkDeserializable,
{
let mut req = NetlinkMessage::from(message);

Expand Down
18 changes: 9 additions & 9 deletions server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,38 +18,38 @@ v6-test = []
[dependencies]
anyhow = "1"
bytes = "1"
clap = { version = "3", features = ["derive"] }
clap_complete = "3"
clap = { version = "4.3", features = ["derive", "wrap_help"] }
clap_complete = "4.3"
colored = "2"
dialoguer = { version = "0.10", default-features = false }
hyper = { version = "0.14", default-features = false, features = ["http1", "server", "runtime", "stream"] }
indoc = "1"
indoc = "2.0.1"
ipnet = { version = "2.4", features = ["serde"] }
libc = "0.2"
libsqlite3-sys = "0.25"
libsqlite3-sys = "0.26"
log = "0.4"
once_cell = "1.17.1"
parking_lot = "0.12"
pretty_env_logger = "0.4"
publicip = { path = "../publicip" }
regex = { version = "1", default-features = false, features = ["std"] }
rusqlite = "0.28"
rusqlite = "0.29"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
shared = { path = "../shared" }
subtle = "2"
thiserror = "1"
tokio = { version = "1", features = ["macros", "rt-multi-thread", "time"] }
toml = "0.5"
tokio = { version = "1.28.0", features = ["macros", "rt-multi-thread", "time"] }
toml = "0.7.4"
url = "2"
wireguard-control = { path = "../wireguard-control" }

[target.'cfg(target_os = "linux")'.dependencies]
socket2 = { version = "0.4", features = ["all"] }
socket2 = { version = "0.5.2", features = ["all"] }

# Workaround for https://github.com/rusqlite/rusqlite/issues/914
[target.'cfg(target_env = "musl")'.dependencies]
rusqlite = { version = "0.28", features = ["bundled"] }
rusqlite = { version = "0.29", features = ["bundled"] }

[dev-dependencies]
anyhow = "1"
Expand Down
2 changes: 1 addition & 1 deletion server/src/initialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub struct InitializeOpts {
pub network_cidr: Option<IpNet>,

/// This server's external endpoint (ex: 100.100.100.100:51820)
#[clap(long, conflicts_with = "auto-external-endpoint")]
#[clap(long, conflicts_with = "auto_external_endpoint")]
pub external_endpoint: Option<Endpoint>,

/// Auto-resolve external endpoint
Expand Down
12 changes: 7 additions & 5 deletions server/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use anyhow::{anyhow, bail};
use clap::{AppSettings, IntoApp, Parser, Subcommand};
use clap::{Parser, Subcommand};
use colored::*;
use dialoguer::Confirm;
use hyper::{http, server::conn::AddrStream, Body, Request, Response};
Expand Down Expand Up @@ -45,8 +45,7 @@ pub use shared::{Association, AssociationContents};
pub const VERSION: &str = env!("CARGO_PKG_VERSION");

#[derive(Debug, Parser)]
#[clap(name = "innernet-server", author, version, about)]
#[clap(global_setting(AppSettings::DeriveDisplayOrder))]
#[command(name = "innernet-server", author, version, about)]
struct Opts {
#[clap(subcommand)]
command: Command,
Expand Down Expand Up @@ -127,7 +126,7 @@ enum Command {

/// Generate shell completion scripts
Completions {
#[clap(arg_enum)]
#[clap(value_enum)]
shell: clap_complete::Shell,
},
}
Expand Down Expand Up @@ -199,7 +198,9 @@ impl ConfigFile {
path.display()
);
}
Ok(toml::from_slice(&std::fs::read(path).with_path(path)?)?)
Ok(toml::from_str(
&std::fs::read_to_string(path).with_path(path)?,
)?)
}
}

Expand Down Expand Up @@ -279,6 +280,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
Command::AddCidr { interface, args } => add_cidr(&interface, &conf, args)?,
Command::DeleteCidr { interface, args } => delete_cidr(&interface, &conf, args)?,
Command::Completions { shell } => {
use clap::CommandFactory;
let mut app = Opts::command();
let app_name = app.get_name().to_string();
clap_complete::generate(shell, &mut app, app_name, &mut std::io::stdout());
Expand Down
14 changes: 7 additions & 7 deletions shared/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,26 @@ version = "1.5.5"
[dependencies]
anyhow = "1"
atty = "0.2"
clap = { version = "3", features = ["derive"] }
clap = { version = "4.3", features = ["derive", "wrap_help"] }
colored = "2.0"
dialoguer = { version = "0.10", default-features = false }
indoc = "1"
indoc = "2.0.1"
ipnet = { version = "2.4", features = ["serde"] }
libc = "0.2"
log = "0.4"
once_cell = "1.17.1"
publicip = { path = "../publicip" }
regex = "1"
serde = { version = "1", features = ["derive"] }
toml = "0.5"
toml = "0.7.4"
url = "2"
wireguard-control = { path = "../wireguard-control" }

[target.'cfg(target_os = "linux")'.dependencies]
netlink-sys = "0.8"
netlink-packet-core = "0.4"
netlink-packet-route = "0.13"
netlink-sys = "0.8.5"
netlink-packet-core = "0.5"
netlink-packet-route = "0.15"
netlink-request = { path = "../netlink-request" }

[target.'cfg(target_os = "macos")'.dependencies]
nix = "0.25"
nix = "0.26"
4 changes: 3 additions & 1 deletion shared/src/interface_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ impl InterfaceConfig {
}

pub fn from_file<P: AsRef<Path>>(path: P) -> Result<Self, Error> {
Ok(toml::from_slice(&std::fs::read(&path).with_path(path)?)?)
Ok(toml::from_str(
&std::fs::read_to_string(&path).with_path(path)?,
)?)
}

pub fn from_interface(config_dir: &Path, interface: &InterfaceName) -> Result<Self, Error> {
Expand Down
60 changes: 29 additions & 31 deletions shared/src/netlink.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use ipnet::IpNet;
use netlink_packet_core::{NetlinkMessage, NetlinkPayload, NLM_F_ACK, NLM_F_CREATE, NLM_F_REQUEST};
use netlink_packet_core::{
NetlinkMessage, NetlinkPayload, NLM_F_ACK, NLM_F_CREATE, NLM_F_DUMP, NLM_F_REPLACE,
NLM_F_REQUEST,
};
use netlink_packet_route::{
address,
constants::*,
Expand All @@ -23,14 +26,12 @@ fn if_nametoindex(interface: &InterfaceName) -> Result<u32, io::Error> {

pub fn set_up(interface: &InterfaceName, mtu: u32) -> Result<(), io::Error> {
let index = if_nametoindex(interface)?;
let message = LinkMessage {
header: LinkHeader {
index,
flags: IFF_UP,
..Default::default()
},
nlas: vec![link::nlas::Nla::Mtu(mtu)],
};
bschwind marked this conversation as resolved.
Show resolved Hide resolved
let mut header = LinkHeader::default();
header.index = index;
header.flags = IFF_UP;
let mut message = LinkMessage::default();
message.header = header;
message.nlas = vec![link::nlas::Nla::Mtu(mtu)];
netlink_request_rtnl(RtnlMessage::SetLink(message), None)?;
log::debug!("set interface {} up with mtu {}", interface, mtu);
Ok(())
Expand All @@ -54,16 +55,15 @@ pub fn set_addr(interface: &InterfaceName, addr: IpNet) -> Result<(), io::Error>
vec![address::Nla::Address(network.addr().octets().to_vec())],
),
};
let message = AddressMessage {
header: AddressHeader {
index,
family,
prefix_len: addr.prefix_len(),
scope: RT_SCOPE_UNIVERSE,
..Default::default()
},
nlas,
};
let mut header = AddressHeader::default();
header.index = index;
header.family = family;
header.prefix_len = addr.prefix_len();
header.scope = RT_SCOPE_UNIVERSE;

let mut message = AddressMessage::default();
message.header = header;
message.nlas = nlas;
netlink_request_rtnl(
RtnlMessage::NewAddress(message),
Some(NLM_F_REQUEST | NLM_F_ACK | NLM_F_REPLACE | NLM_F_CREATE),
Expand All @@ -78,18 +78,16 @@ pub fn add_route(interface: &InterfaceName, cidr: IpNet) -> Result<bool, io::Err
IpNet::V4(network) => (AF_INET as u8, network.network().octets().to_vec()),
IpNet::V6(network) => (AF_INET6 as u8, network.network().octets().to_vec()),
};
let message = RouteMessage {
header: RouteHeader {
table: RT_TABLE_MAIN,
protocol: RTPROT_BOOT,
scope: RT_SCOPE_LINK,
kind: RTN_UNICAST,
destination_prefix_length: cidr.prefix_len(),
address_family,
..Default::default()
},
nlas: vec![route::Nla::Destination(dst), route::Nla::Oif(if_index)],
};
let mut header = RouteHeader::default();
header.table = RT_TABLE_MAIN;
header.protocol = RTPROT_BOOT;
header.scope = RT_SCOPE_LINK;
header.kind = RTN_UNICAST;
header.destination_prefix_length = cidr.prefix_len();
header.address_family = address_family;
let mut message = RouteMessage::default();
message.header = header;
message.nlas = vec![route::Nla::Destination(dst), route::Nla::Oif(if_index)];

match netlink_request_rtnl(RtnlMessage::NewRoute(message), None) {
Ok(_) => {
Expand Down
Loading