├── .github ├── funding.yml └── workflows │ ├── cron.yml │ └── build.yml ├── .gitignore ├── README.md ├── examples ├── macros.conf └── relayd.conf ├── .cargo └── config ├── src ├── main.rs ├── error.rs ├── lib.rs ├── message.rs ├── options.rs ├── redirect.rs ├── relay.rs ├── parent.rs ├── health.rs ├── config │ ├── expand.rs │ └── parser.rs └── config.rs ├── LICENSE ├── Cargo.toml └── Cargo.lock /.github/funding.yml: -------------------------------------------------------------------------------- 1 | github: reyk 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | .#* 3 | /target 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Rust Relayd 2 | =========== 3 | 4 | A reimplementation of OpenBSD's relayd in Rust. 5 | -------------------------------------------------------------------------------- /examples/macros.conf: -------------------------------------------------------------------------------- 1 | # 2 | # Macros 3 | # 4 | ext_addr="192.168.1.1" 5 | webhost1="10.0.0.1" 6 | webhost2="10.0.0.2" 7 | sshhost1="10.0.0.3" 8 | foo="table" 9 | -------------------------------------------------------------------------------- /.cargo/config: -------------------------------------------------------------------------------- 1 | [alias] 2 | ci-clippy = "clippy --all --workspace --all-features -- -Dwarnings -Drust-2018-idioms" 3 | ci-fmt = "fmt --all -- --check" 4 | 5 | # The runner must be specified per target - 6 | # This break "cargo test" as 'cfg(test)' is not supported here. 7 | #[target.'cfg(not(target_os = "openbsd"))'] 8 | #runner = 'sudo' 9 | #[target.'cfg(target_os = "openbsd")'] 10 | #runner = 'doas' 11 | -------------------------------------------------------------------------------- /.github/workflows/cron.yml: -------------------------------------------------------------------------------- 1 | name: cron 2 | on: 3 | schedule: 4 | - cron: '* 9 * * *' 5 | jobs: 6 | audit: 7 | name: cargo audit 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/checkout@v2 11 | - uses: actions-rs/install@v0.1 12 | with: 13 | crate: cargo-audit 14 | version: latest 15 | use-tool-cache: true 16 | - uses: actions-rs/cargo@v1 17 | with: 18 | command: audit 19 | -------------------------------------------------------------------------------- /src/main.rs: -------------------------------------------------------------------------------- 1 | use relayd::{Options, Privsep}; 2 | use std::{env, process}; 3 | 4 | #[tokio::main] 5 | async fn main() { 6 | let opts = Options::new(); 7 | 8 | let matches = match opts.parse() { 9 | Ok(matches) => matches, 10 | Err(_) => process::exit(1), 11 | }; 12 | 13 | let log_level = env::var("RUST_LOG") 14 | .unwrap_or_else(|_| privsep_log::verbose(matches.opt_count("v"))) 15 | .into(); 16 | 17 | let config = privsep::Config { 18 | foreground: matches.opt_present("d"), 19 | log_level, 20 | }; 21 | 22 | if let Err(err) = Privsep::main(config).await { 23 | eprintln!("{}: {}", opts, err); 24 | process::exit(1); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2021 Reyk Floeter 2 | 3 | Permission to use, copy, modify, and distribute this software for any 4 | purpose with or without fee is hereby granted, provided that the above 5 | copyright notice and this permission notice appear in all copies. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 10 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 12 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 | -------------------------------------------------------------------------------- /src/error.rs: -------------------------------------------------------------------------------- 1 | use derive_more::{Display, From}; 2 | use std::io; 3 | 4 | /// Common errors of the `privsep` crate. 5 | #[derive(Debug, Display, From)] 6 | pub enum Error { 7 | #[display(fmt = "Invalid message")] 8 | InvalidMessage, 9 | #[display(fmt = "I/O error: {}", "_0")] 10 | IoError(io::Error), 11 | #[display(fmt = "Invalid arguments: {}", "_0")] 12 | Options(getopts::Fail), 13 | #[display(fmt = "Privilge separation error: {}", "_0")] 14 | PrivsepError(privsep::Error), 15 | #[display(fmt = "Parser error: {}", "_0")] 16 | ParserError(String), 17 | #[display(fmt = "Lost {}, terminated", "_0")] 18 | #[from(ignore)] 19 | Terminated(&'static str), 20 | } 21 | 22 | impl std::error::Error for Error {} 23 | 24 | // Convert to privsep error. 25 | impl From for privsep::Error { 26 | fn from(error: Error) -> privsep::Error { 27 | privsep::Error::GeneralError(Box::new(error)) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "relayd" 3 | version = "0.1.0" 4 | authors = ["Reyk Floeter "] 5 | edition = "2021" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | arc-swap = "1.4.0" 11 | derive_more = "0.99" 12 | futures = "0.3.14" 13 | getopts = "0.2.21" 14 | log = "0.4.14" 15 | nix = "0.22.1" 16 | nom = "7.0.0" 17 | privsep = { version = "0.0.2", features = [ "log" ] } 18 | privsep-derive = "0.0.1" 19 | privsep-log = "0.0.1" 20 | serde = { version = "1.0.125", features = ["derive"] } 21 | serde_with = "1.9" 22 | tokio-ping = "0.3.0" 23 | 24 | [dependencies.tokio] 25 | version = "1.4.0" 26 | features = [ "fs", "net", "time", "rt-multi-thread", "macros", "io-util", "signal" ] 27 | 28 | [features] 29 | debug = [ "privsep-log/debug" ] 30 | 31 | #[patch.crates-io] 32 | #privsep = { path = "../privsep-rs/privsep" } 33 | #privsep-derive = { path = "../privsep-rs/privsep-derive" } 34 | #privsep-log = { path = "../privsep-rs/log" } 35 | -------------------------------------------------------------------------------- /src/lib.rs: -------------------------------------------------------------------------------- 1 | mod config; 2 | mod error; 3 | mod health; 4 | mod message; 5 | mod options; 6 | mod parent; 7 | mod redirect; 8 | mod relay; 9 | 10 | use crate::config::Config; 11 | use arc_swap::ArcSwap; 12 | use privsep_derive::Privsep; 13 | use std::{sync::Arc, time::Duration}; 14 | pub use { 15 | error::Error, 16 | options::Options, 17 | privsep::process::{Child, Parent}, 18 | }; 19 | 20 | /// Privsep processes. 21 | #[derive(Debug, Privsep)] 22 | #[username = "nobody"] 23 | pub enum Privsep { 24 | /// Parent process. 25 | Parent, 26 | /// Health Check Engine 27 | #[connect(Relay, Redirect)] 28 | Health, 29 | /// Packet Filter Engine 30 | Redirect, 31 | /// L7 Relays 32 | Relay, 33 | } 34 | 35 | /// Child context 36 | #[derive(Clone)] 37 | struct Context { 38 | pub config: Arc>, 39 | pub child: Arc>, 40 | } 41 | 42 | /// Default configuration path. 43 | const RELAYD_CONFIG: &str = "/etc/relayd.conf"; 44 | /// Default control socket path. 45 | const RELAYD_SOCKET: &str = "/var/run/relayd.sock"; 46 | /// Default relayd server name. 47 | #[allow(unused)] 48 | const RELAYD_SERVERNAME: &str = "relayd-rs"; 49 | 50 | /// Default health check timeout. 51 | const CHECK_TIMEOUT: Duration = Duration::from_millis(200); 52 | /// Default health check interval. 53 | const CHECK_INTERVAL: Duration = Duration::from_secs(10); 54 | 55 | /// Default PF socket. 56 | #[allow(unused)] 57 | const PF_SOCKET: &str = "/dev/pf"; 58 | /// Default relayd PF anchor. 59 | #[allow(unused)] 60 | const PF_RELAYD_ANCHOR: &str = "relayd"; 61 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: build 2 | on: 3 | - push 4 | - pull_request 5 | jobs: 6 | rustfmt: 7 | name: cargo fmt 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/checkout@v2 11 | - uses: actions-rs/toolchain@v1 12 | with: 13 | toolchain: stable 14 | components: rustfmt 15 | override: true 16 | - uses: actions-rs/cargo@v1 17 | with: 18 | command: ci-fmt 19 | clippy: 20 | name: cargo clippy 21 | runs-on: ubuntu-latest 22 | steps: 23 | - uses: actions/checkout@v2 24 | - uses: actions-rs/toolchain@v1 25 | with: 26 | toolchain: stable 27 | components: clippy 28 | override: true 29 | - uses: actions-rs/cargo@v1 30 | with: 31 | command: ci-clippy 32 | test: 33 | name: cargo test 34 | runs-on: ${{ matrix.os }} 35 | strategy: 36 | matrix: 37 | os: 38 | - ubuntu-latest 39 | - macos-latest 40 | steps: 41 | - uses: actions/checkout@v2 42 | - uses: actions-rs/toolchain@v1 43 | with: 44 | toolchain: stable 45 | override: true 46 | - uses: actions-rs/cargo@v1 47 | with: 48 | command: test 49 | args: --workspace --all-features 50 | audit: 51 | name: cargo audit 52 | runs-on: ubuntu-latest 53 | steps: 54 | - uses: actions/checkout@v2 55 | - uses: actions-rs/install@v0.1 56 | with: 57 | crate: cargo-audit 58 | version: latest 59 | use-tool-cache: true 60 | - uses: actions-rs/cargo@v1 61 | with: 62 | command: audit 63 | -------------------------------------------------------------------------------- /src/message.rs: -------------------------------------------------------------------------------- 1 | use crate::config::{Config, Id}; 2 | use derive_more::Display; 3 | use privsep::imsg::Message; 4 | use serde::{Deserialize, Serialize}; 5 | use std::borrow::Cow; 6 | 7 | #[derive(Clone, Copy, Debug, Display)] 8 | #[repr(u32)] 9 | pub enum Type { 10 | /// Send configuration 11 | Config = Message::RESERVED + 1, 12 | /// Start process operation 13 | Start, 14 | /// Host is up 15 | HostUp, 16 | /// Host is down 17 | HostDown, 18 | /// Unknown message 19 | Unknown, 20 | } 21 | 22 | impl Type { 23 | pub const CONFIG: u32 = Self::Config as u32; 24 | pub const START: u32 = Self::Start as u32; 25 | pub const HOST_UP: u32 = Self::HostUp as u32; 26 | pub const HOST_DOWN: u32 = Self::HostDown as u32; 27 | } 28 | 29 | impl From for Type { 30 | fn from(id: u32) -> Self { 31 | match id { 32 | Type::CONFIG => Self::Config, 33 | Type::START => Self::Start, 34 | Type::HOST_UP => Self::HostUp, 35 | Type::HOST_DOWN => Self::HostDown, 36 | _ => Self::Unknown, 37 | } 38 | } 39 | } 40 | 41 | impl From for Message { 42 | fn from(typ: Type) -> Self { 43 | Self::from(typ as u32) 44 | } 45 | } 46 | 47 | /// Internal message data 48 | #[derive(Debug, Deserialize, Serialize)] 49 | pub enum Data<'a> { 50 | Config(Cow<'a, Config>), 51 | Host(Id), 52 | None, 53 | } 54 | 55 | impl<'a> From<&'a Config> for Data<'a> { 56 | fn from(config: &'a Config) -> Self { 57 | Self::Config(Cow::Borrowed(config)) 58 | } 59 | } 60 | 61 | impl From<()> for Data<'_> { 62 | fn from(_none: ()) -> Self { 63 | Self::None 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/options.rs: -------------------------------------------------------------------------------- 1 | use crate::error::Error; 2 | use derive_more::{Deref, DerefMut, Display}; 3 | use std::env; 4 | 5 | #[derive(Deref, DerefMut, Display)] 6 | #[display(fmt = "{}", prog)] 7 | pub struct Options { 8 | pub args: Vec, 9 | #[deref] 10 | #[deref_mut] 11 | opts: getopts::Options, 12 | pub prog: String, 13 | } 14 | 15 | impl Options { 16 | pub fn new() -> Self { 17 | let mut args: Vec = env::args().collect(); 18 | let prog = args.remove(0); 19 | 20 | let mut opts = getopts::Options::new(); 21 | 22 | opts.optflag("d", "", "Do not daemonize"); 23 | opts.optopt( 24 | "f", 25 | "", 26 | "Specify an alternative configuration file", 27 | crate::RELAYD_CONFIG, 28 | ); 29 | opts.optmulti( 30 | "D", 31 | "", 32 | "Define macro to be set to value on the command line", 33 | "macro=value", 34 | ); 35 | opts.optflagmulti("v", "verbose", "Enable verbose logging"); 36 | 37 | Self { args, opts, prog } 38 | } 39 | 40 | pub fn parse(&self) -> Result { 41 | match self.opts.parse(&self.args) { 42 | Ok(matches) => Ok(matches), 43 | Err(err) => { 44 | eprintln!("{}: {}", self, err); 45 | self.usage(); 46 | Err(err.into()) 47 | } 48 | } 49 | } 50 | 51 | pub fn usage(&self) { 52 | eprintln!("{}", self.opts.short_usage(&self.prog)); 53 | } 54 | } 55 | 56 | impl Default for Options { 57 | fn default() -> Self { 58 | Self::new() 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/redirect.rs: -------------------------------------------------------------------------------- 1 | use crate::{ 2 | error::Error, 3 | message::{Data, Type}, 4 | parent::default_handler, 5 | Child, Privsep, 6 | }; 7 | use privsep::imsg::Message; 8 | use privsep_log::{info, trace}; 9 | use std::sync::Arc; 10 | 11 | pub async fn main( 12 | child: Child, 13 | config: privsep::Config, 14 | ) -> Result<(), privsep::Error> { 15 | let _guard = privsep_log::async_logger(&child.to_string(), &config) 16 | .await 17 | .map_err(|err| privsep::Error::GeneralError(Box::new(err)))?; 18 | 19 | let child = Arc::new(child); 20 | 21 | info!("Started"); 22 | 23 | loop { 24 | tokio::select! { 25 | message = default_handler::>(&child[Privsep::PARENT_ID]) => { 26 | match message? { 27 | (Message { id: Type::CONFIG, .. }, _, Data::Config(config)) => { 28 | trace!("received config: {:?}", config); 29 | } 30 | (Message { id: Type::START, .. }, ..) => { 31 | trace!("received start command"); 32 | } 33 | _ => return Err(Error::InvalidMessage.into()), 34 | } 35 | } 36 | message = default_handler::>(&child[Privsep::HEALTH_ID]) => { 37 | match message? { 38 | (Message { id: Type::HOST_UP, .. }, _, Data::Host(id)) => { 39 | trace!("received host UP: {}", id); 40 | } 41 | (Message { id: Type::HOST_DOWN, .. }, _, Data::Host(id)) => { 42 | trace!("received host DOWN: {}", id); 43 | } 44 | _ => return Err(Error::InvalidMessage.into()), 45 | } 46 | } 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/relay.rs: -------------------------------------------------------------------------------- 1 | use crate::{ 2 | error::Error, 3 | message::{Data, Type}, 4 | parent::default_handler, 5 | Child, Privsep, 6 | }; 7 | use privsep::imsg::Message; 8 | use privsep_log::{info, trace}; 9 | use std::sync::Arc; 10 | 11 | pub async fn main( 12 | child: Child, 13 | config: privsep::Config, 14 | ) -> Result<(), privsep::Error> { 15 | let _guard = privsep_log::async_logger(&child.to_string(), &config) 16 | .await 17 | .map_err(|err| privsep::Error::GeneralError(Box::new(err)))?; 18 | 19 | let child = Arc::new(child); 20 | 21 | info!("Started"); 22 | 23 | loop { 24 | tokio::select! { 25 | message = default_handler::>(&child[Privsep::PARENT_ID]) => { 26 | match message? { 27 | (Message { id: Type::CONFIG, .. }, _, Data::Config(config)) => { 28 | trace!("received config: {:?}", config); 29 | } 30 | (Message { id: Type::START, .. }, ..) => { 31 | trace!("received start command"); 32 | } 33 | _ => return Err(Error::InvalidMessage.into()), 34 | } 35 | } 36 | message = default_handler::>(&child[Privsep::HEALTH_ID]) => { 37 | match message? { 38 | (Message { id: Type::HOST_UP, .. }, _, Data::Host(id)) => { 39 | trace!("received host UP: {}", id); 40 | } 41 | (Message { id: Type::HOST_DOWN, .. }, _, Data::Host(id)) => { 42 | trace!("received host DOWN: {}", id); 43 | } 44 | _ => return Err(Error::InvalidMessage.into()), 45 | } 46 | } 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /examples/relayd.conf: -------------------------------------------------------------------------------- 1 | # $OpenBSD: \ 2 | relayd.conf,v 1.5 2018/05/06 20:56:55 benno Exp $ 3 | 4 | include "examples/macros.conf" 5 | 6 | # 7 | # Global Options 8 | # 9 | interval 10 10 | timeout 1000 11 | # prefork 5 12 | 13 | # 14 | # Each table will be mapped to a pf table. 15 | # 16 | table { $webhost1 $webhost2 } 17 | table { 193.99.144.85 } 18 | $foo disable { 10.1.1.1, 10.1.1.2, 129.128.5.194 } 19 | 20 | # 21 | # Services will be mapped to a rdr rule. 22 | # 23 | redirect www { 24 | listen on $ext_addr port http interface trunk0 25 | 26 | # tag every packet that goes thru the rdr rule with RELAYD 27 | pftag RELAYD 28 | 29 | forward to check http "/" code 200 30 | forward to check icmp 31 | } 32 | 33 | # 34 | # Relay and protocol for HTTP layer 7 loadbalancing and SSL/TLS acceleration 35 | # 36 | http protocol https { 37 | match request header append "X-Forwarded-For" \ 38 | value "$REMOTE_ADDR" 39 | match request header append "X-Forwarded-By" \ 40 | value "$SERVER_ADDR:$SERVER_PORT" 41 | match request header set "Connection" value "close" 42 | 43 | # Various TCP options 44 | tcp { sack, backlog 128 } 45 | 46 | # tls { no tlsv1.0, ciphers HIGH } 47 | # tls no session tickets 48 | } 49 | 50 | relay wwwtls { 51 | # Run as a SSL/TLS accelerator 52 | listen on $ext_addr port 443 tls 53 | protocol https 54 | 55 | # Forward to hosts in the webhosts table using a src/dst hash 56 | forward to port http mode loadbalance \ 57 | check http "/" code 200 58 | } 59 | 60 | # 61 | # Relay and protocol for simple TCP forwarding on layer 7 62 | # 63 | protocol sshtcp { 64 | # The TCP_NODELAY option is required for "smooth" terminal sessions 65 | tcp nodelay 66 | } 67 | 68 | relay sshgw { 69 | # Run as a simple TCP relay 70 | listen on $ext_addr port 2222 71 | protocol sshtcp 72 | 73 | # Forward to the shared carp(4) address of an internal gateway 74 | forward to $sshhost1 port 22 75 | } 76 | 77 | # 78 | # Relay and protocol for a transparent HTTP proxy 79 | # 80 | http protocol httpfilter { 81 | # Return HTTP/HTML error pages to the client 82 | return error 83 | 84 | # Block disallowed sites 85 | match request label "URL filtered!" 86 | block request quick url "www.example.com/" value "*" 87 | 88 | # Block disallowed browsers 89 | match request label "Please try a different Browser" 90 | block request quick header "User-Agent" \ 91 | value "Mozilla/4.0 (compatible; MSIE *" 92 | 93 | # Block some well-known Instant Messengers 94 | match request label "Instant messenger disallowed!" 95 | block response quick header "Content-Type" \ 96 | value "application/x-msn-messenger" 97 | block response quick header "Content-Type" value "app/x-hotbar-xip20" 98 | block response quick header "Content-Type" value "application/x-icq" 99 | block response quick header "Content-Type" value "AIM/HTTP" 100 | block response quick header "Content-Type" \ 101 | value "application/x-comet-log" 102 | } 103 | 104 | relay httpproxy { 105 | # Listen on localhost, accept diverted connections from pf(4) 106 | listen on 127.0.0.1 port 8080 107 | protocol httpfilter 108 | 109 | # Forward to the original target host 110 | forward to destination 111 | } 112 | -------------------------------------------------------------------------------- /src/parent.rs: -------------------------------------------------------------------------------- 1 | use crate::{ 2 | config::{Config, Variables}, 3 | error::Error, 4 | message::{Data, Type}, 5 | options::Options, 6 | Privsep, 7 | }; 8 | use nix::sys::wait::{waitpid, WaitStatus}; 9 | use privsep::{ 10 | imsg::Message, 11 | net::Fd, 12 | process::{daemon, Parent, Peer}, 13 | Error as PrivsepError, 14 | }; 15 | use privsep_log::{debug, info, warn}; 16 | use serde::de::DeserializeOwned; 17 | use std::{io, process, sync::Arc}; 18 | use tokio::signal::unix::{signal, SignalKind}; 19 | 20 | pub async fn main( 21 | parent: Parent, 22 | privsep: privsep::Config, 23 | ) -> Result<(), privsep::Error> { 24 | let _guard = privsep_log::async_logger(&parent.to_string(), &privsep) 25 | .await 26 | .map_err(|err| PrivsepError::GeneralError(Box::new(err)))?; 27 | 28 | let parent = Arc::new(parent); 29 | 30 | let config = Config { 31 | privsep, 32 | ..init(&parent) 33 | .await 34 | .map_err(|err| PrivsepError::GeneralError(Box::new(err)))? 35 | }; 36 | let mut sigchld = signal(SignalKind::child())?; 37 | 38 | // Detach the parent from the foreground. 39 | if !config.privsep.foreground { 40 | daemon(true, false)?; 41 | } 42 | 43 | info!("Started"); 44 | 45 | // Send the configuration to all children. 46 | send_to_all(&parent, Type::Config, None, &Data::from(&config)).await?; 47 | send_to_all(&parent, Type::Start, None, &Data::None).await?; 48 | 49 | loop { 50 | tokio::select! { 51 | _ = sigchld.recv() => { 52 | match waitpid(None, None) { 53 | Ok(WaitStatus::Exited(pid, status)) => { 54 | warn!("Child {} exited with status {}", pid, status); 55 | process::exit(0); 56 | } 57 | status => { 58 | warn!("Child exited with error: {:?}", status); 59 | process::exit(1); 60 | } 61 | } 62 | } 63 | 64 | message = default_handler::<()>(&parent[Privsep::HEALTH_ID]) => { message?; }, 65 | message = default_handler::<()>(&parent[Privsep::RELAY_ID]) => { message?; }, 66 | message = default_handler::<()>(&parent[Privsep::REDIRECT_ID]) => { message?; }, 67 | } 68 | } 69 | } 70 | 71 | async fn send_to_all + Clone, const N: usize>( 72 | parent: &Parent, 73 | id: T, 74 | fd: Option<&Fd>, 75 | data: &Data<'_>, 76 | ) -> io::Result<()> { 77 | for i in Privsep::PROCESS_IDS 78 | .iter() 79 | .filter(|i| **i != Privsep::PARENT_ID) 80 | { 81 | parent[*i].send_message(id.clone().into(), fd, data).await?; 82 | } 83 | 84 | Ok(()) 85 | } 86 | 87 | pub async fn send_to_peer>( 88 | peer: &Peer, 89 | id: T, 90 | fd: Option<&Fd>, 91 | data: &Data<'_>, 92 | ) -> io::Result<()> { 93 | peer.send_message(id.into(), fd, data).await 94 | } 95 | 96 | pub async fn init(_parent: &Parent) -> Result { 97 | let opts = Options::new(); 98 | let matches = opts.parse()?; 99 | 100 | let path = matches 101 | .opt_str("f") 102 | .unwrap_or_else(|| crate::RELAYD_CONFIG.to_string()); 103 | 104 | let mut variables = Variables::new(); 105 | for variable in matches.opt_strs("D") { 106 | let kv = variable.split('=').collect::>(); 107 | if kv.len() != 2 { 108 | return Err(Error::ParserError(variable)); 109 | } 110 | variables.insert(kv[0].to_string(), kv[1].to_string()); 111 | } 112 | 113 | let config = Config::load(&path, variables).await?; 114 | 115 | Ok(config) 116 | } 117 | 118 | pub async fn default_handler( 119 | peer: &Peer, 120 | ) -> Result<(Message, Option, T), Error> { 121 | match peer.recv_message::().await? { 122 | None => Err(Error::Terminated(peer.as_ref())), 123 | Some((message, fd, data)) => { 124 | debug!( 125 | "received message {}", Type::from(message.id); 126 | "source" => peer.as_ref(), 127 | ); 128 | 129 | Ok((message, fd, data)) 130 | } 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /src/health.rs: -------------------------------------------------------------------------------- 1 | use crate::{ 2 | error::Error, 3 | message::{Data, Type}, 4 | parent::{default_handler, send_to_peer}, 5 | Child, Context, Privsep, 6 | }; 7 | use futures::{stream::FuturesUnordered, StreamExt}; 8 | use privsep::imsg::Message; 9 | use privsep_log::{debug, info, trace}; 10 | use std::{io, sync::Arc}; 11 | use tokio::{net, time}; 12 | 13 | pub async fn main( 14 | child: Child, 15 | privsep_config: privsep::Config, 16 | ) -> Result<(), privsep::Error> { 17 | let _guard = privsep_log::async_logger(&child.to_string(), &privsep_config) 18 | .await 19 | .map_err(|err| privsep::Error::GeneralError(Box::new(err)))?; 20 | 21 | let context = Context { 22 | child: Arc::new(child), 23 | config: Default::default(), 24 | }; 25 | 26 | info!("Started"); 27 | 28 | loop { 29 | tokio::select! { 30 | message = default_handler::>(&context.child[Privsep::PARENT_ID]) => { 31 | match message? { 32 | (Message { id: Type::CONFIG, .. }, _, Data::Config(new_config)) => { 33 | trace!("received config: {:?}", new_config); 34 | context.config.store(Arc::new(new_config.into_owned())); 35 | } 36 | (Message { id: Type::START, .. }, ..) => { 37 | trace!("received start command"); 38 | run(context.clone()).await 39 | } 40 | _ => return Err(Error::InvalidMessage.into()), 41 | } 42 | } 43 | message = default_handler::<()>(&context.child[Privsep::RELAY_ID]) => { message?; }, 44 | message = default_handler::<()>(&context.child[Privsep::REDIRECT_ID]) => { message?; }, 45 | } 46 | } 47 | } 48 | 49 | async fn run(context: Context) { 50 | trace!("Running"); 51 | 52 | tokio::spawn(async move { 53 | let mut interval = time::interval(context.config.load().interval); 54 | loop { 55 | interval.tick().await; 56 | debug!("tick"); 57 | 58 | let context = context.clone(); 59 | let config = context.config.load(); 60 | 61 | tokio::spawn(async move { 62 | let _ = &context; 63 | let mut tasks = FuturesUnordered::new(); 64 | let timeout = config.timeout; 65 | 66 | for host in config 67 | .tables 68 | .iter() 69 | .map(|table| table.hosts.iter()) 70 | .flatten() 71 | { 72 | let host = host.clone(); 73 | let id = host.id; 74 | let fut = tokio::spawn(async move { 75 | let addr = host.name + ":80"; 76 | let addrs = net::lookup_host(&addr).await.map_err(|_| id)?; 77 | for addr in addrs { 78 | debug!("checking host {}: {}", id, addr); 79 | if let Ok(Ok(_)) = 80 | time::timeout(timeout, net::TcpStream::connect(addr)).await 81 | { 82 | return Ok(id); 83 | } 84 | } 85 | Err(id) 86 | }); 87 | tasks.push(fut); 88 | } 89 | 90 | while let Some(result) = tasks.next().await { 91 | let (typ, id) = match result? { 92 | Ok(id) => { 93 | debug!("host {} is UP", id); 94 | (Type::HostUp, id) 95 | } 96 | Err(id) => { 97 | debug!("host {} is DOWN", id); 98 | (Type::HostDown, id) 99 | } 100 | }; 101 | 102 | let peer = &context.child[Privsep::REDIRECT_ID]; 103 | send_to_peer(peer, typ, None, &Data::Host(id)) 104 | .await 105 | .unwrap(); 106 | let peer = &context.child[Privsep::RELAY_ID]; 107 | send_to_peer(peer, typ, None, &Data::Host(id)) 108 | .await 109 | .unwrap(); 110 | } 111 | Ok::<_, io::Error>(()) 112 | }); 113 | } 114 | }); 115 | } 116 | -------------------------------------------------------------------------------- /src/config/expand.rs: -------------------------------------------------------------------------------- 1 | use crate::config::{ 2 | parser::{comment, line, quoted, string, CResult}, 3 | Variable, Variables, 4 | }; 5 | use nom::{ 6 | branch::alt, 7 | bytes::complete::{is_not, tag}, 8 | character::complete::{char, multispace1}, 9 | combinator::{map, opt}, 10 | error::{VerboseError, VerboseErrorKind}, 11 | multi::many0, 12 | sequence::{pair, separated_pair}, 13 | Err, IResult, 14 | }; 15 | 16 | #[derive(Debug)] 17 | enum Token { 18 | Variable(Variable), 19 | UseVariable(String), 20 | Escaped(String), 21 | Next(String), 22 | Nested(Vec), 23 | None, 24 | } 25 | 26 | impl Token { 27 | pub fn resolve(&self, output: &mut String, variables: &mut Variables) { 28 | match self { 29 | Token::None => {} 30 | Token::Variable(variable) => { 31 | if !variables.contains_key(&variable.key) { 32 | variables.insert(variable.key.clone(), variable.value.clone()); 33 | } 34 | } 35 | Token::UseVariable(name) if variables.contains_key(name) => { 36 | if let Some(value) = variables.get(name) { 37 | output.push_str(value); 38 | } 39 | } 40 | Token::Nested(values) => { 41 | for token in values { 42 | token.resolve(output, variables); 43 | } 44 | } 45 | _ => output.push_str(&self.to_string()), 46 | } 47 | } 48 | } 49 | 50 | impl Default for Token { 51 | fn default() -> Self { 52 | Self::None 53 | } 54 | } 55 | 56 | impl ToString for Token { 57 | fn to_string(&self) -> String { 58 | let mut result = String::new(); 59 | match self { 60 | Token::Variable(variable) => { 61 | result = variable.to_string(); 62 | } 63 | Token::UseVariable(name) => { 64 | result.push('$'); 65 | result.push_str(name); 66 | } 67 | Token::Escaped(value) => { 68 | result.push_str(value); 69 | } 70 | Token::Nested(values) => { 71 | result = values 72 | .iter() 73 | .map(ToString::to_string) 74 | .collect::>() 75 | .join("\n"); 76 | } 77 | Token::Next(value) => { 78 | result.push_str(value); 79 | } 80 | Token::None => {} 81 | } 82 | result 83 | } 84 | } 85 | 86 | fn escaped_line(s: &str) -> CResult<'_, Token> { 87 | map( 88 | pair(is_not("\\\n"), tag("\\\n")), 89 | |(a, _b): (&str, &str)| Token::Escaped(a.to_string()), 90 | )(s) 91 | } 92 | 93 | fn variable(s: &str) -> CResult<'_, Variable> { 94 | map(separated_pair(string, char('='), quoted), |(key, value)| { 95 | Variable { 96 | key: key.to_string(), 97 | value: value.to_string(), 98 | } 99 | })(s) 100 | } 101 | 102 | fn use_variable(s: &str) -> CResult<'_, Token> { 103 | map( 104 | pair( 105 | opt(is_not("$\n")), 106 | map(pair(char('$'), string), |(_, value): (_, &str)| { 107 | Token::UseVariable(value.to_string()) 108 | }), 109 | ), 110 | |(line, variable)| { 111 | Token::Nested(vec![ 112 | line.map(|line| Token::Next(line.to_string())) 113 | .unwrap_or_default(), 114 | variable, 115 | ]) 116 | }, 117 | )(s) 118 | } 119 | 120 | fn include(s: &str) -> CResult<'_, Token> { 121 | let (input, (_, file)) = separated_pair(tag("include"), multispace1, quoted)(s)?; 122 | 123 | let output = std::fs::read_to_string(file).map_err(|_err| { 124 | Err::>::Error(VerboseError::<&str> { 125 | errors: vec![(input, VerboseErrorKind::Context("include file not found"))], 126 | }) 127 | })?; 128 | let (_, tokens) = many0(ast)(&output).map_err(|_err| { 129 | Err::>::Error(VerboseError::<&str> { 130 | errors: vec![(input, VerboseErrorKind::Context("invalid include"))], 131 | }) 132 | })?; 133 | 134 | Ok((input, Token::Nested(tokens))) 135 | } 136 | 137 | fn read_line(s: &str) -> CResult<'_, Token> { 138 | alt(( 139 | map(comment, |_| Token::None), 140 | map(line, |s| Token::Next(format!("{}\n", s))), 141 | ))(s) 142 | } 143 | 144 | fn ast(s: &str) -> CResult<'_, Token> { 145 | alt(( 146 | map(variable, Token::Variable), 147 | escaped_line, 148 | use_variable, 149 | include, 150 | read_line, 151 | ))(s) 152 | } 153 | 154 | pub fn config_expand( 155 | s: &str, 156 | mut variables: Variables, 157 | ) -> IResult<&str, String, VerboseError<&str>> { 158 | map(many0(ast), |ast: Vec| { 159 | let mut result = String::new(); 160 | for token in ast { 161 | token.resolve(&mut result, &mut variables); 162 | } 163 | result 164 | })(s) 165 | } 166 | -------------------------------------------------------------------------------- /src/config.rs: -------------------------------------------------------------------------------- 1 | mod expand; 2 | mod parser; 3 | 4 | use crate::error::Error; 5 | use expand::config_expand; 6 | use nom::{error::convert_error, Finish}; 7 | use parser::config_parser; 8 | use serde::{Deserialize, Serialize}; 9 | use serde_with::{serde_as, DurationMilliSeconds, DurationSeconds}; 10 | use std::{ 11 | collections::HashMap, 12 | path::{Path, PathBuf}, 13 | sync::atomic::{AtomicU32, Ordering}, 14 | time::Duration, 15 | }; 16 | use tokio::fs; 17 | 18 | #[serde_as] 19 | #[derive(Clone, Debug, Deserialize, Serialize)] 20 | #[serde(default)] 21 | pub struct Config { 22 | /// Privsep and log configuration. 23 | #[serde(skip)] 24 | pub privsep: privsep::Config, 25 | 26 | /// The interval in seconds at which the hosts will be checked. 27 | #[serde_as(as = "DurationSeconds")] 28 | pub interval: Duration, 29 | /// Create a control socket at path. 30 | pub socket: PathBuf, 31 | /// The global timeout in milliseconds for checks. 32 | #[serde_as(as = "DurationMilliSeconds")] 33 | pub timeout: Duration, 34 | 35 | pub redirects: Vec, 36 | pub relays: Vec, 37 | pub protocols: Vec, 38 | pub tables: Vec, 39 | // Currently not supported: 40 | //agentx: not supported 41 | //log: TODO 42 | //prefork: not supported 43 | } 44 | 45 | impl Default for Config { 46 | fn default() -> Self { 47 | Self { 48 | privsep: Default::default(), 49 | interval: crate::CHECK_INTERVAL, 50 | socket: PathBuf::from(crate::RELAYD_SOCKET), 51 | timeout: crate::CHECK_TIMEOUT, 52 | redirects: Default::default(), 53 | relays: Default::default(), 54 | protocols: Default::default(), 55 | tables: Default::default(), 56 | } 57 | } 58 | } 59 | 60 | impl Config { 61 | pub async fn load + ?Sized>( 62 | path: &P, 63 | variables: Variables, 64 | ) -> Result { 65 | let input = fs::read_to_string(path).await?; 66 | Self::parse(input, variables) 67 | } 68 | 69 | pub fn parse>(input: S, variables: Variables) -> Result { 70 | let input = input.as_ref(); 71 | let (_, input) = config_expand(input, variables) 72 | .finish() 73 | .map_err(|err| Error::ParserError(convert_error(input, err)))?; 74 | let input = input.as_ref(); 75 | config_parser(input) 76 | .finish() 77 | .map_err(|err| Error::ParserError(convert_error(input, err))) 78 | .map(|(_, o)| o) 79 | } 80 | } 81 | 82 | #[derive(Debug, Default)] 83 | pub struct Variable { 84 | key: String, 85 | value: String, 86 | } 87 | 88 | impl From<(String, String)> for Variable { 89 | fn from((key, value): (String, String)) -> Self { 90 | Self { key, value } 91 | } 92 | } 93 | 94 | impl ToString for Variable { 95 | fn to_string(&self) -> String { 96 | format!("{}=\"{}\"", self.key, self.value) 97 | } 98 | } 99 | 100 | pub type Variables = HashMap; 101 | 102 | /// General relayd object Id. 103 | pub type Id = u32; 104 | 105 | /// Counter of tables. 106 | pub static TABLE_ID: AtomicU32 = AtomicU32::new(1); 107 | 108 | /// Counter of hosts. 109 | pub static HOST_ID: AtomicU32 = AtomicU32::new(1); 110 | 111 | /// Counter of redirects. 112 | pub static REDIRECT_ID: AtomicU32 = AtomicU32::new(1); 113 | 114 | /// Counter of relays. 115 | pub static RELAY_ID: AtomicU32 = AtomicU32::new(1); 116 | 117 | /// Counter of protocols. 118 | pub static PROTOCOL_ID: AtomicU32 = AtomicU32::new(1); 119 | 120 | /// Table of hosts. 121 | #[derive(Clone, Debug, Default, Deserialize, Serialize)] 122 | pub struct Table { 123 | /// Id. 124 | pub id: Id, 125 | /// Symbolic name of the table. 126 | pub name: String, 127 | /// Target host pool. 128 | pub hosts: Vec, 129 | /// Whether to disable the table. 130 | pub disabled: bool, 131 | } 132 | 133 | impl Table { 134 | fn new() -> Self { 135 | Self { 136 | id: TABLE_ID.fetch_add(1, Ordering::SeqCst), 137 | ..Default::default() 138 | } 139 | } 140 | } 141 | 142 | /// Target host pool and definitions. 143 | #[derive(Clone, Debug, Default, Deserialize, Serialize)] 144 | pub struct Host { 145 | /// Id. 146 | pub id: Id, 147 | /// FQDN or IP address of the host. 148 | pub name: String, 149 | /// Time-to-live value in the IP headers for host checks. 150 | pub ip_ttl: Option, 151 | /// Optional parent Id to inherit the state from. 152 | pub parent: Option, 153 | /// Optional route priority. 154 | pub priority: Option, 155 | /// Retry tolerance for host checks. 156 | pub retry: usize, 157 | } 158 | 159 | impl Host { 160 | fn new() -> Self { 161 | Self { 162 | id: HOST_ID.fetch_add(1, Ordering::SeqCst), 163 | ..Default::default() 164 | } 165 | } 166 | } 167 | 168 | #[derive(Clone, Debug, Default, Deserialize, Serialize)] 169 | pub struct Redirect { 170 | /// Id. 171 | pub id: Id, 172 | /// Symbolic name of the redirect. 173 | pub name: String, 174 | } 175 | 176 | impl Redirect { 177 | fn new() -> Self { 178 | Self { 179 | id: REDIRECT_ID.fetch_add(1, Ordering::SeqCst), 180 | ..Default::default() 181 | } 182 | } 183 | } 184 | 185 | #[derive(Clone, Debug, Default, Deserialize, Serialize)] 186 | pub struct Relay { 187 | /// Id. 188 | pub id: Id, 189 | /// Symbolic name of the relay. 190 | pub name: String, 191 | } 192 | 193 | impl Relay { 194 | fn new() -> Self { 195 | Self { 196 | id: RELAY_ID.fetch_add(1, Ordering::SeqCst), 197 | ..Default::default() 198 | } 199 | } 200 | } 201 | 202 | #[derive(Clone, Copy, Debug, Deserialize, Serialize)] 203 | pub enum ProtocolType { 204 | Tcp, 205 | Http, 206 | Dns, 207 | } 208 | 209 | impl Default for ProtocolType { 210 | fn default() -> Self { 211 | Self::Tcp 212 | } 213 | } 214 | 215 | #[derive(Clone, Debug, Default, Deserialize, Serialize)] 216 | pub struct Protocol { 217 | /// Id. 218 | pub id: Id, 219 | /// Symbolic name of the protocol. 220 | pub name: String, 221 | /// Protocol or application type. 222 | pub typ: ProtocolType, 223 | } 224 | 225 | impl Protocol { 226 | fn new() -> Self { 227 | Self { 228 | id: PROTOCOL_ID.fetch_add(1, Ordering::SeqCst), 229 | ..Default::default() 230 | } 231 | } 232 | } 233 | 234 | #[cfg(test)] 235 | mod tests { 236 | use super::*; 237 | 238 | #[test] 239 | fn test_config_example() { 240 | let _guard = privsep_log::sync_logger( 241 | "config", 242 | privsep_log::Config { 243 | foreground: true, 244 | filter: Some("trace".to_string()), 245 | }, 246 | ) 247 | .unwrap(); 248 | let config = include_bytes!("../examples/relayd.conf"); 249 | 250 | Config::parse( 251 | &String::from_utf8(config.to_vec()).unwrap(), 252 | Default::default(), 253 | ) 254 | .unwrap(); 255 | } 256 | } 257 | -------------------------------------------------------------------------------- /src/config/parser.rs: -------------------------------------------------------------------------------- 1 | use crate::config::{Config, Host, Protocol, ProtocolType, Redirect, Relay, Table}; 2 | use nom::{ 3 | branch::alt, 4 | bytes::complete::{tag, take_until, take_while1}, 5 | character::complete::{char, digit1, multispace0}, 6 | combinator::{all_consuming, eof, map, map_res, not, opt, peek, recognize}, 7 | error::VerboseError, 8 | multi::{many0, many_till}, 9 | sequence::{delimited, pair, preceded, separated_pair, tuple}, 10 | IResult, 11 | }; 12 | use privsep_log::debug; 13 | use std::{path::PathBuf, time::Duration}; 14 | 15 | pub(super) type CResult<'a, T> = IResult<&'a str, T, VerboseError<&'a str>>; 16 | 17 | enum Section { 18 | // Global configuration. 19 | Interval(Duration), 20 | Socket(PathBuf), 21 | Timeout(Duration), 22 | 23 | // Other sections. 24 | Table(Table), 25 | Redirect(Redirect), 26 | Relay(Relay), 27 | Protocol(Protocol), 28 | Ignore, 29 | } 30 | 31 | fn section(s: &str) -> CResult<'_, Section> { 32 | preceded( 33 | not(eof), 34 | alt(( 35 | map(interval, |d| { 36 | debug!("interval {:?}", d); 37 | Section::Interval(d) 38 | }), 39 | map(socket, |p| { 40 | debug!("socket {:?}", p); 41 | Section::Socket(p) 42 | }), 43 | map(timeout, |d| { 44 | debug!("timeout {:?}", d); 45 | Section::Timeout(d) 46 | }), 47 | map(table, |t| { 48 | debug!("{:?}", t); 49 | Section::Table(t) 50 | }), 51 | map(redirect, |r| { 52 | debug!("{:?}", r); 53 | Section::Redirect(r) 54 | }), 55 | map(relay, |r| { 56 | debug!("{:?}", r); 57 | Section::Relay(r) 58 | }), 59 | map(protocol, |p| { 60 | debug!("{:?}", p); 61 | Section::Protocol(p) 62 | }), 63 | map(comment, |c| { 64 | debug!("#{}", c); 65 | Section::Ignore 66 | }), 67 | map(nl, |_| Section::Ignore), 68 | )), 69 | )(s) 70 | } 71 | 72 | fn section_options(s: &str, c: fn(&str) -> CResult<'_, T>) -> CResult<'_, Vec> { 73 | delimited( 74 | char('{'), 75 | map(many_till(c, peek(char('}'))), |options: (Vec, _)| { 76 | options.0 77 | }), 78 | char('}'), 79 | )(s) 80 | } 81 | 82 | fn interval(s: &str) -> CResult<'_, Duration> { 83 | map( 84 | separated_pair(tag("interval"), nl, integer), 85 | |(_, seconds)| Duration::from_secs(seconds), 86 | )(s) 87 | } 88 | 89 | fn socket(s: &str) -> CResult<'_, PathBuf> { 90 | map(separated_pair(tag("socket<"), nl, string), |(_, path)| { 91 | PathBuf::from(path) 92 | })(s) 93 | } 94 | 95 | fn timeout(s: &str) -> CResult<'_, Duration> { 96 | map( 97 | separated_pair(tag("timeout"), nl, integer), 98 | |(_, seconds)| Duration::from_millis(seconds), 99 | )(s) 100 | } 101 | 102 | fn host(s: &str) -> CResult<'_, Host> { 103 | map(tuple((sep, string, sep)), |(_, name, _)| Host { 104 | name: name.to_string(), 105 | ..Host::new() 106 | })(s) 107 | } 108 | 109 | fn table_options(s: &str) -> CResult<'_, Vec> { 110 | delimited( 111 | char('{'), 112 | map(many_till(host, peek(char('}'))), |(hosts, _)| hosts), 113 | char('}'), 114 | )(s) 115 | } 116 | 117 | fn table_name(s: &str) -> CResult<'_, &str> { 118 | delimited(char('<'), string, char('>'))(s) 119 | } 120 | 121 | fn table(s: &str) -> CResult<'_, Table> { 122 | map( 123 | tuple(( 124 | tag("table"), 125 | nl, 126 | table_name, 127 | nl, 128 | opt(pair(tag("disable"), nl)), 129 | table_options, 130 | line, 131 | )), 132 | |(_, _, name, _n, disable, hosts, _)| Table { 133 | name: name.to_string(), 134 | disabled: disable.is_some(), 135 | hosts, 136 | ..Table::new() 137 | }, 138 | )(s) 139 | } 140 | 141 | enum RedirectOption { 142 | PfTag(String), 143 | Ignore, 144 | } 145 | 146 | fn redirect_option(s: &str) -> CResult<'_, RedirectOption> { 147 | alt(( 148 | map(preceded(tag("listen"), line), |_| { 149 | debug!("return"); 150 | RedirectOption::Ignore 151 | }), 152 | map(preceded(tag("pftag"), line), |line| { 153 | debug!("pftag"); 154 | RedirectOption::PfTag(line.to_string()) 155 | }), 156 | map( 157 | tuple((tag("forward"), nl, tag("to"), nl, table_name, line)), 158 | |_line| { 159 | debug!("forward"); 160 | RedirectOption::Ignore 161 | }, 162 | ), 163 | map(comment, |_| RedirectOption::Ignore), 164 | map(nl, |_| RedirectOption::Ignore), 165 | ))(s) 166 | } 167 | 168 | fn redirect_options(s: &str) -> CResult<'_, Vec> { 169 | section_options(s, redirect_option) 170 | } 171 | 172 | fn redirect(s: &str) -> CResult<'_, Redirect> { 173 | map( 174 | tuple((tag("redirect"), nl, quoted, nl, redirect_options, line)), 175 | |(name, _, _, _, _, _)| Redirect { 176 | name: name.to_string(), 177 | ..Redirect::new() 178 | }, 179 | )(s) 180 | } 181 | 182 | fn relay(s: &str) -> CResult<'_, Relay> { 183 | map( 184 | tuple(( 185 | tag("relay"), 186 | nl, 187 | quoted, 188 | nl, 189 | char('{'), 190 | take_until("}"), 191 | line, 192 | )), 193 | |(_, _, name, _, _, _, _)| Relay { 194 | name: name.to_string(), 195 | ..Relay::new() 196 | }, 197 | )(s) 198 | } 199 | 200 | fn protocol_type(s: &str) -> CResult<'_, ProtocolType> { 201 | alt(( 202 | map(tag("tcp"), |_| ProtocolType::Tcp), 203 | map(tag("http"), |_| ProtocolType::Http), 204 | map(tag("dns"), |_| ProtocolType::Dns), 205 | ))(s) 206 | } 207 | 208 | fn protocol_option(s: &str) -> CResult<'_, ()> { 209 | alt(( 210 | map(preceded(tag("return"), line), |_| { 211 | debug!("return"); 212 | }), 213 | map(pair(alt((tag("block"), tag("match"))), line), |(t, _)| { 214 | debug!("{}", t); 215 | }), 216 | map(preceded(tag("tcp"), line), |_| { 217 | debug!("tcp"); 218 | }), 219 | map(preceded(tag("tls"), line), |_| ()), 220 | map(comment, |_| ()), 221 | map(nl, |_| ()), 222 | ))(s) 223 | } 224 | 225 | fn protocol_options(s: &str) -> CResult<'_, Vec<()>> { 226 | section_options(s, protocol_option) 227 | } 228 | 229 | fn protocol(s: &str) -> CResult<'_, Protocol> { 230 | map( 231 | tuple(( 232 | opt(protocol_type), 233 | nl, 234 | tag("protocol"), 235 | nl, 236 | quoted, 237 | nl, 238 | protocol_options, 239 | line, 240 | )), 241 | |(typ, _, _, _, name, _, _, _)| Protocol { 242 | name: name.to_string(), 243 | typ: typ.unwrap_or_default(), 244 | ..Protocol::new() 245 | }, 246 | )(s) 247 | } 248 | 249 | fn allowed_in_string(ch: char) -> bool { 250 | ch.is_ascii_alphanumeric() 251 | || (ch.is_ascii_punctuation() 252 | && ch != '(' 253 | && ch != ')' 254 | && ch != '{' 255 | && ch != '}' 256 | && ch != '<' 257 | && ch != '>' 258 | && ch != '!' 259 | && ch != '=' 260 | && ch != '#' 261 | && ch != ',' 262 | && ch != '/') 263 | } 264 | 265 | pub(super) fn string(s: &str) -> CResult<'_, &str> { 266 | take_while1(allowed_in_string)(s) 267 | } 268 | 269 | pub(super) fn line(s: &str) -> CResult<'_, &str> { 270 | take_until("\n")(s).and_then(|(s, value)| nl(s).map(|(s, _)| (s, value))) 271 | } 272 | 273 | pub(super) fn quoted(s: &str) -> CResult<'_, &str> { 274 | alt((delimited(char('\"'), take_until("\""), char('\"')), string))(s) 275 | } 276 | 277 | pub(super) fn nl(s: &str) -> CResult<'_, Option<&str>> { 278 | alt((map(multispace0, |_| None), map(comment, Some)))(s) 279 | } 280 | 281 | fn sep(s: &str) -> CResult<'_, ()> { 282 | map(tuple((nl, opt(char(',')), nl)), |_| ())(s) 283 | } 284 | 285 | pub(super) fn comment(s: &str) -> CResult<'_, &str> { 286 | preceded(pair(nl, char('#')), line)(s) 287 | } 288 | 289 | fn integer(s: &str) -> CResult<'_, u64> { 290 | map_res(recognize(digit1), str::parse)(s) 291 | } 292 | 293 | pub fn config_parser(s: &str) -> CResult<'_, Config> { 294 | all_consuming(map(many0(section), |sections: Vec
| { 295 | let mut config = Config::default(); 296 | for section in sections { 297 | match section { 298 | Section::Interval(d) => config.interval = d, 299 | Section::Socket(p) => config.socket = p, 300 | Section::Timeout(d) => config.timeout = d, 301 | Section::Table(t) => config.tables.push(t), 302 | Section::Redirect(r) => config.redirects.push(r), 303 | Section::Relay(r) => config.relays.push(r), 304 | Section::Protocol(p) => config.protocols.push(p), 305 | Section::Ignore => (), 306 | } 307 | } 308 | config 309 | }))(s) 310 | } 311 | -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "addr2line" 7 | version = "0.17.0" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b" 10 | dependencies = [ 11 | "gimli", 12 | ] 13 | 14 | [[package]] 15 | name = "adler" 16 | version = "1.0.2" 17 | source = "registry+https://github.com/rust-lang/crates.io-index" 18 | checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" 19 | 20 | [[package]] 21 | name = "arc-swap" 22 | version = "1.5.0" 23 | source = "registry+https://github.com/rust-lang/crates.io-index" 24 | checksum = "c5d78ce20460b82d3fa150275ed9d55e21064fc7951177baacf86a145c4a4b1f" 25 | 26 | [[package]] 27 | name = "arrayvec" 28 | version = "0.7.2" 29 | source = "registry+https://github.com/rust-lang/crates.io-index" 30 | checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" 31 | 32 | [[package]] 33 | name = "async-trait" 34 | version = "0.1.51" 35 | source = "registry+https://github.com/rust-lang/crates.io-index" 36 | checksum = "44318e776df68115a881de9a8fd1b9e53368d7a4a5ce4cc48517da3393233a5e" 37 | dependencies = [ 38 | "proc-macro2", 39 | "quote", 40 | "syn", 41 | ] 42 | 43 | [[package]] 44 | name = "autocfg" 45 | version = "1.0.1" 46 | source = "registry+https://github.com/rust-lang/crates.io-index" 47 | checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" 48 | 49 | [[package]] 50 | name = "backtrace" 51 | version = "0.3.63" 52 | source = "registry+https://github.com/rust-lang/crates.io-index" 53 | checksum = "321629d8ba6513061f26707241fa9bc89524ff1cd7a915a97ef0c62c666ce1b6" 54 | dependencies = [ 55 | "addr2line", 56 | "cc", 57 | "cfg-if 1.0.0", 58 | "libc", 59 | "miniz_oxide", 60 | "object", 61 | "rustc-demangle", 62 | ] 63 | 64 | [[package]] 65 | name = "bincode" 66 | version = "1.3.3" 67 | source = "registry+https://github.com/rust-lang/crates.io-index" 68 | checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" 69 | dependencies = [ 70 | "serde", 71 | ] 72 | 73 | [[package]] 74 | name = "bitflags" 75 | version = "1.2.1" 76 | source = "registry+https://github.com/rust-lang/crates.io-index" 77 | checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" 78 | 79 | [[package]] 80 | name = "byteorder" 81 | version = "1.4.3" 82 | source = "registry+https://github.com/rust-lang/crates.io-index" 83 | checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" 84 | 85 | [[package]] 86 | name = "bytes" 87 | version = "0.4.12" 88 | source = "registry+https://github.com/rust-lang/crates.io-index" 89 | checksum = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" 90 | dependencies = [ 91 | "byteorder", 92 | "iovec", 93 | ] 94 | 95 | [[package]] 96 | name = "bytes" 97 | version = "1.1.0" 98 | source = "registry+https://github.com/rust-lang/crates.io-index" 99 | checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8" 100 | 101 | [[package]] 102 | name = "cc" 103 | version = "1.0.72" 104 | source = "registry+https://github.com/rust-lang/crates.io-index" 105 | checksum = "22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee" 106 | 107 | [[package]] 108 | name = "cfg-if" 109 | version = "0.1.10" 110 | source = "registry+https://github.com/rust-lang/crates.io-index" 111 | checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" 112 | 113 | [[package]] 114 | name = "cfg-if" 115 | version = "1.0.0" 116 | source = "registry+https://github.com/rust-lang/crates.io-index" 117 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 118 | 119 | [[package]] 120 | name = "close_fds" 121 | version = "0.3.2" 122 | source = "registry+https://github.com/rust-lang/crates.io-index" 123 | checksum = "3bc416f33de9d59e79e57560f450d21ff8393adcf1cdfc3e6d8fb93d5f88a2ed" 124 | dependencies = [ 125 | "cfg-if 1.0.0", 126 | "libc", 127 | ] 128 | 129 | [[package]] 130 | name = "cloudabi" 131 | version = "0.0.3" 132 | source = "registry+https://github.com/rust-lang/crates.io-index" 133 | checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" 134 | dependencies = [ 135 | "bitflags", 136 | ] 137 | 138 | [[package]] 139 | name = "convert_case" 140 | version = "0.4.0" 141 | source = "registry+https://github.com/rust-lang/crates.io-index" 142 | checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" 143 | 144 | [[package]] 145 | name = "crossbeam-utils" 146 | version = "0.7.2" 147 | source = "registry+https://github.com/rust-lang/crates.io-index" 148 | checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" 149 | dependencies = [ 150 | "autocfg", 151 | "cfg-if 0.1.10", 152 | "lazy_static", 153 | ] 154 | 155 | [[package]] 156 | name = "darling" 157 | version = "0.13.0" 158 | source = "registry+https://github.com/rust-lang/crates.io-index" 159 | checksum = "757c0ded2af11d8e739c4daea1ac623dd1624b06c844cf3f5a39f1bdbd99bb12" 160 | dependencies = [ 161 | "darling_core", 162 | "darling_macro", 163 | ] 164 | 165 | [[package]] 166 | name = "darling_core" 167 | version = "0.13.0" 168 | source = "registry+https://github.com/rust-lang/crates.io-index" 169 | checksum = "2c34d8efb62d0c2d7f60ece80f75e5c63c1588ba68032740494b0b9a996466e3" 170 | dependencies = [ 171 | "fnv", 172 | "ident_case", 173 | "proc-macro2", 174 | "quote", 175 | "strsim", 176 | "syn", 177 | ] 178 | 179 | [[package]] 180 | name = "darling_macro" 181 | version = "0.13.0" 182 | source = "registry+https://github.com/rust-lang/crates.io-index" 183 | checksum = "ade7bff147130fe5e6d39f089c6bd49ec0250f35d70b2eebf72afdfc919f15cc" 184 | dependencies = [ 185 | "darling_core", 186 | "quote", 187 | "syn", 188 | ] 189 | 190 | [[package]] 191 | name = "derive_more" 192 | version = "0.99.16" 193 | source = "registry+https://github.com/rust-lang/crates.io-index" 194 | checksum = "40eebddd2156ce1bb37b20bbe5151340a31828b1f2d22ba4141f3531710e38df" 195 | dependencies = [ 196 | "convert_case", 197 | "proc-macro2", 198 | "quote", 199 | "rustc_version 0.3.3", 200 | "syn", 201 | ] 202 | 203 | [[package]] 204 | name = "failure" 205 | version = "0.1.8" 206 | source = "registry+https://github.com/rust-lang/crates.io-index" 207 | checksum = "d32e9bd16cc02eae7db7ef620b392808b89f6a5e16bb3497d159c6b92a0f4f86" 208 | dependencies = [ 209 | "backtrace", 210 | "failure_derive", 211 | ] 212 | 213 | [[package]] 214 | name = "failure_derive" 215 | version = "0.1.8" 216 | source = "registry+https://github.com/rust-lang/crates.io-index" 217 | checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4" 218 | dependencies = [ 219 | "proc-macro2", 220 | "quote", 221 | "syn", 222 | "synstructure", 223 | ] 224 | 225 | [[package]] 226 | name = "fnv" 227 | version = "1.0.7" 228 | source = "registry+https://github.com/rust-lang/crates.io-index" 229 | checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" 230 | 231 | [[package]] 232 | name = "fuchsia-cprng" 233 | version = "0.1.1" 234 | source = "registry+https://github.com/rust-lang/crates.io-index" 235 | checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" 236 | 237 | [[package]] 238 | name = "fuchsia-zircon" 239 | version = "0.3.3" 240 | source = "registry+https://github.com/rust-lang/crates.io-index" 241 | checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" 242 | dependencies = [ 243 | "bitflags", 244 | "fuchsia-zircon-sys", 245 | ] 246 | 247 | [[package]] 248 | name = "fuchsia-zircon-sys" 249 | version = "0.3.3" 250 | source = "registry+https://github.com/rust-lang/crates.io-index" 251 | checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" 252 | 253 | [[package]] 254 | name = "futures" 255 | version = "0.1.31" 256 | source = "registry+https://github.com/rust-lang/crates.io-index" 257 | checksum = "3a471a38ef8ed83cd6e40aa59c1ffe17db6855c18e3604d9c4ed8c08ebc28678" 258 | 259 | [[package]] 260 | name = "futures" 261 | version = "0.3.17" 262 | source = "registry+https://github.com/rust-lang/crates.io-index" 263 | checksum = "a12aa0eb539080d55c3f2d45a67c3b58b6b0773c1a3ca2dfec66d58c97fd66ca" 264 | dependencies = [ 265 | "futures-channel", 266 | "futures-core", 267 | "futures-executor", 268 | "futures-io", 269 | "futures-sink", 270 | "futures-task", 271 | "futures-util", 272 | ] 273 | 274 | [[package]] 275 | name = "futures-channel" 276 | version = "0.3.17" 277 | source = "registry+https://github.com/rust-lang/crates.io-index" 278 | checksum = "5da6ba8c3bb3c165d3c7319fc1cc8304facf1fb8db99c5de877183c08a273888" 279 | dependencies = [ 280 | "futures-core", 281 | "futures-sink", 282 | ] 283 | 284 | [[package]] 285 | name = "futures-core" 286 | version = "0.3.17" 287 | source = "registry+https://github.com/rust-lang/crates.io-index" 288 | checksum = "88d1c26957f23603395cd326b0ffe64124b818f4449552f960d815cfba83a53d" 289 | 290 | [[package]] 291 | name = "futures-executor" 292 | version = "0.3.17" 293 | source = "registry+https://github.com/rust-lang/crates.io-index" 294 | checksum = "45025be030969d763025784f7f355043dc6bc74093e4ecc5000ca4dc50d8745c" 295 | dependencies = [ 296 | "futures-core", 297 | "futures-task", 298 | "futures-util", 299 | ] 300 | 301 | [[package]] 302 | name = "futures-io" 303 | version = "0.3.17" 304 | source = "registry+https://github.com/rust-lang/crates.io-index" 305 | checksum = "522de2a0fe3e380f1bc577ba0474108faf3f6b18321dbf60b3b9c39a75073377" 306 | 307 | [[package]] 308 | name = "futures-macro" 309 | version = "0.3.17" 310 | source = "registry+https://github.com/rust-lang/crates.io-index" 311 | checksum = "18e4a4b95cea4b4ccbcf1c5675ca7c4ee4e9e75eb79944d07defde18068f79bb" 312 | dependencies = [ 313 | "autocfg", 314 | "proc-macro-hack", 315 | "proc-macro2", 316 | "quote", 317 | "syn", 318 | ] 319 | 320 | [[package]] 321 | name = "futures-sink" 322 | version = "0.3.17" 323 | source = "registry+https://github.com/rust-lang/crates.io-index" 324 | checksum = "36ea153c13024fe480590b3e3d4cad89a0cfacecc24577b68f86c6ced9c2bc11" 325 | 326 | [[package]] 327 | name = "futures-task" 328 | version = "0.3.17" 329 | source = "registry+https://github.com/rust-lang/crates.io-index" 330 | checksum = "1d3d00f4eddb73e498a54394f228cd55853bdf059259e8e7bc6e69d408892e99" 331 | 332 | [[package]] 333 | name = "futures-util" 334 | version = "0.3.17" 335 | source = "registry+https://github.com/rust-lang/crates.io-index" 336 | checksum = "36568465210a3a6ee45e1f165136d68671471a501e632e9a98d96872222b5481" 337 | dependencies = [ 338 | "autocfg", 339 | "futures-channel", 340 | "futures-core", 341 | "futures-io", 342 | "futures-macro", 343 | "futures-sink", 344 | "futures-task", 345 | "memchr", 346 | "pin-project-lite", 347 | "pin-utils", 348 | "proc-macro-hack", 349 | "proc-macro-nested", 350 | "slab", 351 | ] 352 | 353 | [[package]] 354 | name = "getopts" 355 | version = "0.2.21" 356 | source = "registry+https://github.com/rust-lang/crates.io-index" 357 | checksum = "14dbbfd5c71d70241ecf9e6f13737f7b5ce823821063188d7e46c41d371eebd5" 358 | dependencies = [ 359 | "unicode-width", 360 | ] 361 | 362 | [[package]] 363 | name = "gimli" 364 | version = "0.26.1" 365 | source = "registry+https://github.com/rust-lang/crates.io-index" 366 | checksum = "78cc372d058dcf6d5ecd98510e7fbc9e5aec4d21de70f65fea8fecebcd881bd4" 367 | 368 | [[package]] 369 | name = "hermit-abi" 370 | version = "0.1.19" 371 | source = "registry+https://github.com/rust-lang/crates.io-index" 372 | checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" 373 | dependencies = [ 374 | "libc", 375 | ] 376 | 377 | [[package]] 378 | name = "ident_case" 379 | version = "1.0.1" 380 | source = "registry+https://github.com/rust-lang/crates.io-index" 381 | checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" 382 | 383 | [[package]] 384 | name = "instant" 385 | version = "0.1.12" 386 | source = "registry+https://github.com/rust-lang/crates.io-index" 387 | checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" 388 | dependencies = [ 389 | "cfg-if 1.0.0", 390 | ] 391 | 392 | [[package]] 393 | name = "iovec" 394 | version = "0.1.4" 395 | source = "registry+https://github.com/rust-lang/crates.io-index" 396 | checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" 397 | dependencies = [ 398 | "libc", 399 | ] 400 | 401 | [[package]] 402 | name = "kernel32-sys" 403 | version = "0.2.2" 404 | source = "registry+https://github.com/rust-lang/crates.io-index" 405 | checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" 406 | dependencies = [ 407 | "winapi 0.2.8", 408 | "winapi-build", 409 | ] 410 | 411 | [[package]] 412 | name = "lazy_static" 413 | version = "1.4.0" 414 | source = "registry+https://github.com/rust-lang/crates.io-index" 415 | checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" 416 | 417 | [[package]] 418 | name = "libc" 419 | version = "0.2.107" 420 | source = "registry+https://github.com/rust-lang/crates.io-index" 421 | checksum = "fbe5e23404da5b4f555ef85ebed98fb4083e55a00c317800bc2a50ede9f3d219" 422 | 423 | [[package]] 424 | name = "lock_api" 425 | version = "0.3.4" 426 | source = "registry+https://github.com/rust-lang/crates.io-index" 427 | checksum = "c4da24a77a3d8a6d4862d95f72e6fdb9c09a643ecdb402d754004a557f2bec75" 428 | dependencies = [ 429 | "scopeguard", 430 | ] 431 | 432 | [[package]] 433 | name = "lock_api" 434 | version = "0.4.5" 435 | source = "registry+https://github.com/rust-lang/crates.io-index" 436 | checksum = "712a4d093c9976e24e7dbca41db895dabcbac38eb5f4045393d17a95bdfb1109" 437 | dependencies = [ 438 | "scopeguard", 439 | ] 440 | 441 | [[package]] 442 | name = "log" 443 | version = "0.4.14" 444 | source = "registry+https://github.com/rust-lang/crates.io-index" 445 | checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" 446 | dependencies = [ 447 | "cfg-if 1.0.0", 448 | ] 449 | 450 | [[package]] 451 | name = "maybe-uninit" 452 | version = "2.0.0" 453 | source = "registry+https://github.com/rust-lang/crates.io-index" 454 | checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" 455 | 456 | [[package]] 457 | name = "memchr" 458 | version = "2.4.1" 459 | source = "registry+https://github.com/rust-lang/crates.io-index" 460 | checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" 461 | 462 | [[package]] 463 | name = "memoffset" 464 | version = "0.6.4" 465 | source = "registry+https://github.com/rust-lang/crates.io-index" 466 | checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9" 467 | dependencies = [ 468 | "autocfg", 469 | ] 470 | 471 | [[package]] 472 | name = "minimal-lexical" 473 | version = "0.2.1" 474 | source = "registry+https://github.com/rust-lang/crates.io-index" 475 | checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" 476 | 477 | [[package]] 478 | name = "miniz_oxide" 479 | version = "0.4.4" 480 | source = "registry+https://github.com/rust-lang/crates.io-index" 481 | checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b" 482 | dependencies = [ 483 | "adler", 484 | "autocfg", 485 | ] 486 | 487 | [[package]] 488 | name = "mio" 489 | version = "0.6.23" 490 | source = "registry+https://github.com/rust-lang/crates.io-index" 491 | checksum = "4afd66f5b91bf2a3bc13fad0e21caedac168ca4c707504e75585648ae80e4cc4" 492 | dependencies = [ 493 | "cfg-if 0.1.10", 494 | "fuchsia-zircon", 495 | "fuchsia-zircon-sys", 496 | "iovec", 497 | "kernel32-sys", 498 | "libc", 499 | "log", 500 | "miow 0.2.2", 501 | "net2", 502 | "slab", 503 | "winapi 0.2.8", 504 | ] 505 | 506 | [[package]] 507 | name = "mio" 508 | version = "0.7.14" 509 | source = "registry+https://github.com/rust-lang/crates.io-index" 510 | checksum = "8067b404fe97c70829f082dec8bcf4f71225d7eaea1d8645349cb76fa06205cc" 511 | dependencies = [ 512 | "libc", 513 | "log", 514 | "miow 0.3.7", 515 | "ntapi", 516 | "winapi 0.3.9", 517 | ] 518 | 519 | [[package]] 520 | name = "miow" 521 | version = "0.2.2" 522 | source = "registry+https://github.com/rust-lang/crates.io-index" 523 | checksum = "ebd808424166322d4a38da87083bfddd3ac4c131334ed55856112eb06d46944d" 524 | dependencies = [ 525 | "kernel32-sys", 526 | "net2", 527 | "winapi 0.2.8", 528 | "ws2_32-sys", 529 | ] 530 | 531 | [[package]] 532 | name = "miow" 533 | version = "0.3.7" 534 | source = "registry+https://github.com/rust-lang/crates.io-index" 535 | checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21" 536 | dependencies = [ 537 | "winapi 0.3.9", 538 | ] 539 | 540 | [[package]] 541 | name = "net2" 542 | version = "0.2.37" 543 | source = "registry+https://github.com/rust-lang/crates.io-index" 544 | checksum = "391630d12b68002ae1e25e8f974306474966550ad82dac6886fb8910c19568ae" 545 | dependencies = [ 546 | "cfg-if 0.1.10", 547 | "libc", 548 | "winapi 0.3.9", 549 | ] 550 | 551 | [[package]] 552 | name = "nix" 553 | version = "0.22.2" 554 | source = "registry+https://github.com/rust-lang/crates.io-index" 555 | checksum = "d3bb9a13fa32bc5aeb64150cd3f32d6cf4c748f8f8a417cce5d2eb976a8370ba" 556 | dependencies = [ 557 | "bitflags", 558 | "cc", 559 | "cfg-if 1.0.0", 560 | "libc", 561 | "memoffset", 562 | ] 563 | 564 | [[package]] 565 | name = "nom" 566 | version = "7.1.0" 567 | source = "registry+https://github.com/rust-lang/crates.io-index" 568 | checksum = "1b1d11e1ef389c76fe5b81bcaf2ea32cf88b62bc494e19f493d0b30e7a930109" 569 | dependencies = [ 570 | "memchr", 571 | "minimal-lexical", 572 | "version_check", 573 | ] 574 | 575 | [[package]] 576 | name = "ntapi" 577 | version = "0.3.6" 578 | source = "registry+https://github.com/rust-lang/crates.io-index" 579 | checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44" 580 | dependencies = [ 581 | "winapi 0.3.9", 582 | ] 583 | 584 | [[package]] 585 | name = "num_cpus" 586 | version = "1.13.0" 587 | source = "registry+https://github.com/rust-lang/crates.io-index" 588 | checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" 589 | dependencies = [ 590 | "hermit-abi", 591 | "libc", 592 | ] 593 | 594 | [[package]] 595 | name = "object" 596 | version = "0.27.1" 597 | source = "registry+https://github.com/rust-lang/crates.io-index" 598 | checksum = "67ac1d3f9a1d3616fd9a60c8d74296f22406a238b6a72f5cc1e6f314df4ffbf9" 599 | dependencies = [ 600 | "memchr", 601 | ] 602 | 603 | [[package]] 604 | name = "once_cell" 605 | version = "1.8.0" 606 | source = "registry+https://github.com/rust-lang/crates.io-index" 607 | checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56" 608 | 609 | [[package]] 610 | name = "owning_ref" 611 | version = "0.3.3" 612 | source = "registry+https://github.com/rust-lang/crates.io-index" 613 | checksum = "cdf84f41639e037b484f93433aa3897863b561ed65c6e59c7073d7c561710f37" 614 | dependencies = [ 615 | "stable_deref_trait", 616 | ] 617 | 618 | [[package]] 619 | name = "parking_lot" 620 | version = "0.5.5" 621 | source = "registry+https://github.com/rust-lang/crates.io-index" 622 | checksum = "d4d05f1349491390b1730afba60bb20d55761bef489a954546b58b4b34e1e2ac" 623 | dependencies = [ 624 | "owning_ref", 625 | "parking_lot_core 0.2.14", 626 | ] 627 | 628 | [[package]] 629 | name = "parking_lot" 630 | version = "0.9.0" 631 | source = "registry+https://github.com/rust-lang/crates.io-index" 632 | checksum = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252" 633 | dependencies = [ 634 | "lock_api 0.3.4", 635 | "parking_lot_core 0.6.2", 636 | "rustc_version 0.2.3", 637 | ] 638 | 639 | [[package]] 640 | name = "parking_lot" 641 | version = "0.11.2" 642 | source = "registry+https://github.com/rust-lang/crates.io-index" 643 | checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" 644 | dependencies = [ 645 | "instant", 646 | "lock_api 0.4.5", 647 | "parking_lot_core 0.8.5", 648 | ] 649 | 650 | [[package]] 651 | name = "parking_lot_core" 652 | version = "0.2.14" 653 | source = "registry+https://github.com/rust-lang/crates.io-index" 654 | checksum = "4db1a8ccf734a7bce794cc19b3df06ed87ab2f3907036b693c68f56b4d4537fa" 655 | dependencies = [ 656 | "libc", 657 | "rand", 658 | "smallvec 0.6.14", 659 | "winapi 0.3.9", 660 | ] 661 | 662 | [[package]] 663 | name = "parking_lot_core" 664 | version = "0.6.2" 665 | source = "registry+https://github.com/rust-lang/crates.io-index" 666 | checksum = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b" 667 | dependencies = [ 668 | "cfg-if 0.1.10", 669 | "cloudabi", 670 | "libc", 671 | "redox_syscall 0.1.57", 672 | "rustc_version 0.2.3", 673 | "smallvec 0.6.14", 674 | "winapi 0.3.9", 675 | ] 676 | 677 | [[package]] 678 | name = "parking_lot_core" 679 | version = "0.8.5" 680 | source = "registry+https://github.com/rust-lang/crates.io-index" 681 | checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" 682 | dependencies = [ 683 | "cfg-if 1.0.0", 684 | "instant", 685 | "libc", 686 | "redox_syscall 0.2.10", 687 | "smallvec 1.7.0", 688 | "winapi 0.3.9", 689 | ] 690 | 691 | [[package]] 692 | name = "pest" 693 | version = "2.1.3" 694 | source = "registry+https://github.com/rust-lang/crates.io-index" 695 | checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53" 696 | dependencies = [ 697 | "ucd-trie", 698 | ] 699 | 700 | [[package]] 701 | name = "pin-project-lite" 702 | version = "0.2.7" 703 | source = "registry+https://github.com/rust-lang/crates.io-index" 704 | checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443" 705 | 706 | [[package]] 707 | name = "pin-utils" 708 | version = "0.1.0" 709 | source = "registry+https://github.com/rust-lang/crates.io-index" 710 | checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" 711 | 712 | [[package]] 713 | name = "privsep" 714 | version = "0.0.2" 715 | source = "registry+https://github.com/rust-lang/crates.io-index" 716 | checksum = "1134dbefd384bae523003d7970ee01e08b64c568693d361ad793e3699d20b57e" 717 | dependencies = [ 718 | "arrayvec", 719 | "async-trait", 720 | "bincode", 721 | "bytes 1.1.0", 722 | "cfg-if 1.0.0", 723 | "close_fds", 724 | "derive_more", 725 | "libc", 726 | "nix", 727 | "parking_lot 0.11.2", 728 | "privsep-derive", 729 | "privsep-log", 730 | "serde", 731 | "serde_derive", 732 | "tokio", 733 | "zerocopy", 734 | ] 735 | 736 | [[package]] 737 | name = "privsep-derive" 738 | version = "0.0.1" 739 | source = "registry+https://github.com/rust-lang/crates.io-index" 740 | checksum = "093edbec8cdd24ecd706f2162197ef21786c74ee42490cea922ac3357fb2653a" 741 | dependencies = [ 742 | "convert_case", 743 | "proc-macro2", 744 | "quote", 745 | "syn", 746 | ] 747 | 748 | [[package]] 749 | name = "privsep-log" 750 | version = "0.0.1" 751 | source = "registry+https://github.com/rust-lang/crates.io-index" 752 | checksum = "8a3810056d4b4a655c4cced1dceb33c088fe3fa879cd08ab8d249d774a6a208a" 753 | dependencies = [ 754 | "derive_more", 755 | "lazy_static", 756 | "libc", 757 | "log", 758 | "serde", 759 | "serde_derive", 760 | "slog", 761 | "slog-scope", 762 | "slog-stdlog", 763 | "tokio", 764 | ] 765 | 766 | [[package]] 767 | name = "proc-macro-hack" 768 | version = "0.5.19" 769 | source = "registry+https://github.com/rust-lang/crates.io-index" 770 | checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" 771 | 772 | [[package]] 773 | name = "proc-macro-nested" 774 | version = "0.1.7" 775 | source = "registry+https://github.com/rust-lang/crates.io-index" 776 | checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086" 777 | 778 | [[package]] 779 | name = "proc-macro2" 780 | version = "1.0.32" 781 | source = "registry+https://github.com/rust-lang/crates.io-index" 782 | checksum = "ba508cc11742c0dc5c1659771673afbab7a0efab23aa17e854cbab0837ed0b43" 783 | dependencies = [ 784 | "unicode-xid", 785 | ] 786 | 787 | [[package]] 788 | name = "quote" 789 | version = "1.0.10" 790 | source = "registry+https://github.com/rust-lang/crates.io-index" 791 | checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05" 792 | dependencies = [ 793 | "proc-macro2", 794 | ] 795 | 796 | [[package]] 797 | name = "rand" 798 | version = "0.4.6" 799 | source = "registry+https://github.com/rust-lang/crates.io-index" 800 | checksum = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" 801 | dependencies = [ 802 | "fuchsia-cprng", 803 | "libc", 804 | "rand_core 0.3.1", 805 | "rdrand", 806 | "winapi 0.3.9", 807 | ] 808 | 809 | [[package]] 810 | name = "rand_core" 811 | version = "0.3.1" 812 | source = "registry+https://github.com/rust-lang/crates.io-index" 813 | checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" 814 | dependencies = [ 815 | "rand_core 0.4.2", 816 | ] 817 | 818 | [[package]] 819 | name = "rand_core" 820 | version = "0.4.2" 821 | source = "registry+https://github.com/rust-lang/crates.io-index" 822 | checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" 823 | 824 | [[package]] 825 | name = "rdrand" 826 | version = "0.4.0" 827 | source = "registry+https://github.com/rust-lang/crates.io-index" 828 | checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" 829 | dependencies = [ 830 | "rand_core 0.3.1", 831 | ] 832 | 833 | [[package]] 834 | name = "redox_syscall" 835 | version = "0.1.57" 836 | source = "registry+https://github.com/rust-lang/crates.io-index" 837 | checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" 838 | 839 | [[package]] 840 | name = "redox_syscall" 841 | version = "0.2.10" 842 | source = "registry+https://github.com/rust-lang/crates.io-index" 843 | checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff" 844 | dependencies = [ 845 | "bitflags", 846 | ] 847 | 848 | [[package]] 849 | name = "relayd" 850 | version = "0.1.0" 851 | dependencies = [ 852 | "arc-swap", 853 | "derive_more", 854 | "futures 0.3.17", 855 | "getopts", 856 | "log", 857 | "nix", 858 | "nom", 859 | "privsep", 860 | "privsep-derive", 861 | "privsep-log", 862 | "serde", 863 | "serde_with", 864 | "tokio", 865 | "tokio-ping", 866 | ] 867 | 868 | [[package]] 869 | name = "rustc-demangle" 870 | version = "0.1.21" 871 | source = "registry+https://github.com/rust-lang/crates.io-index" 872 | checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" 873 | 874 | [[package]] 875 | name = "rustc_version" 876 | version = "0.2.3" 877 | source = "registry+https://github.com/rust-lang/crates.io-index" 878 | checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" 879 | dependencies = [ 880 | "semver 0.9.0", 881 | ] 882 | 883 | [[package]] 884 | name = "rustc_version" 885 | version = "0.3.3" 886 | source = "registry+https://github.com/rust-lang/crates.io-index" 887 | checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" 888 | dependencies = [ 889 | "semver 0.11.0", 890 | ] 891 | 892 | [[package]] 893 | name = "rustversion" 894 | version = "1.0.5" 895 | source = "registry+https://github.com/rust-lang/crates.io-index" 896 | checksum = "61b3909d758bb75c79f23d4736fac9433868679d3ad2ea7a61e3c25cfda9a088" 897 | 898 | [[package]] 899 | name = "scopeguard" 900 | version = "1.1.0" 901 | source = "registry+https://github.com/rust-lang/crates.io-index" 902 | checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" 903 | 904 | [[package]] 905 | name = "semver" 906 | version = "0.9.0" 907 | source = "registry+https://github.com/rust-lang/crates.io-index" 908 | checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" 909 | dependencies = [ 910 | "semver-parser 0.7.0", 911 | ] 912 | 913 | [[package]] 914 | name = "semver" 915 | version = "0.11.0" 916 | source = "registry+https://github.com/rust-lang/crates.io-index" 917 | checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" 918 | dependencies = [ 919 | "semver-parser 0.10.2", 920 | ] 921 | 922 | [[package]] 923 | name = "semver-parser" 924 | version = "0.7.0" 925 | source = "registry+https://github.com/rust-lang/crates.io-index" 926 | checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" 927 | 928 | [[package]] 929 | name = "semver-parser" 930 | version = "0.10.2" 931 | source = "registry+https://github.com/rust-lang/crates.io-index" 932 | checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" 933 | dependencies = [ 934 | "pest", 935 | ] 936 | 937 | [[package]] 938 | name = "serde" 939 | version = "1.0.130" 940 | source = "registry+https://github.com/rust-lang/crates.io-index" 941 | checksum = "f12d06de37cf59146fbdecab66aa99f9fe4f78722e3607577a5375d66bd0c913" 942 | dependencies = [ 943 | "serde_derive", 944 | ] 945 | 946 | [[package]] 947 | name = "serde_derive" 948 | version = "1.0.130" 949 | source = "registry+https://github.com/rust-lang/crates.io-index" 950 | checksum = "d7bc1a1ab1961464eae040d96713baa5a724a8152c1222492465b54322ec508b" 951 | dependencies = [ 952 | "proc-macro2", 953 | "quote", 954 | "syn", 955 | ] 956 | 957 | [[package]] 958 | name = "serde_with" 959 | version = "1.11.0" 960 | source = "registry+https://github.com/rust-lang/crates.io-index" 961 | checksum = "ad6056b4cb69b6e43e3a0f055def223380baecc99da683884f205bf347f7c4b3" 962 | dependencies = [ 963 | "rustversion", 964 | "serde", 965 | "serde_with_macros", 966 | ] 967 | 968 | [[package]] 969 | name = "serde_with_macros" 970 | version = "1.5.1" 971 | source = "registry+https://github.com/rust-lang/crates.io-index" 972 | checksum = "12e47be9471c72889ebafb5e14d5ff930d89ae7a67bbdb5f8abb564f845a927e" 973 | dependencies = [ 974 | "darling", 975 | "proc-macro2", 976 | "quote", 977 | "syn", 978 | ] 979 | 980 | [[package]] 981 | name = "signal-hook-registry" 982 | version = "1.4.0" 983 | source = "registry+https://github.com/rust-lang/crates.io-index" 984 | checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" 985 | dependencies = [ 986 | "libc", 987 | ] 988 | 989 | [[package]] 990 | name = "slab" 991 | version = "0.4.5" 992 | source = "registry+https://github.com/rust-lang/crates.io-index" 993 | checksum = "9def91fd1e018fe007022791f865d0ccc9b3a0d5001e01aabb8b40e46000afb5" 994 | 995 | [[package]] 996 | name = "slog" 997 | version = "2.7.0" 998 | source = "registry+https://github.com/rust-lang/crates.io-index" 999 | checksum = "8347046d4ebd943127157b94d63abb990fcf729dc4e9978927fdf4ac3c998d06" 1000 | 1001 | [[package]] 1002 | name = "slog-scope" 1003 | version = "4.4.0" 1004 | source = "registry+https://github.com/rust-lang/crates.io-index" 1005 | checksum = "2f95a4b4c3274cd2869549da82b57ccc930859bdbf5bcea0424bc5f140b3c786" 1006 | dependencies = [ 1007 | "arc-swap", 1008 | "lazy_static", 1009 | "slog", 1010 | ] 1011 | 1012 | [[package]] 1013 | name = "slog-stdlog" 1014 | version = "4.1.0" 1015 | source = "registry+https://github.com/rust-lang/crates.io-index" 1016 | checksum = "8228ab7302adbf4fcb37e66f3cda78003feb521e7fd9e3847ec117a7784d0f5a" 1017 | dependencies = [ 1018 | "log", 1019 | "slog", 1020 | "slog-scope", 1021 | ] 1022 | 1023 | [[package]] 1024 | name = "smallvec" 1025 | version = "0.6.14" 1026 | source = "registry+https://github.com/rust-lang/crates.io-index" 1027 | checksum = "b97fcaeba89edba30f044a10c6a3cc39df9c3f17d7cd829dd1446cab35f890e0" 1028 | dependencies = [ 1029 | "maybe-uninit", 1030 | ] 1031 | 1032 | [[package]] 1033 | name = "smallvec" 1034 | version = "1.7.0" 1035 | source = "registry+https://github.com/rust-lang/crates.io-index" 1036 | checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309" 1037 | 1038 | [[package]] 1039 | name = "socket2" 1040 | version = "0.3.19" 1041 | source = "registry+https://github.com/rust-lang/crates.io-index" 1042 | checksum = "122e570113d28d773067fab24266b66753f6ea915758651696b6e35e49f88d6e" 1043 | dependencies = [ 1044 | "cfg-if 1.0.0", 1045 | "libc", 1046 | "winapi 0.3.9", 1047 | ] 1048 | 1049 | [[package]] 1050 | name = "stable_deref_trait" 1051 | version = "1.2.0" 1052 | source = "registry+https://github.com/rust-lang/crates.io-index" 1053 | checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" 1054 | 1055 | [[package]] 1056 | name = "strsim" 1057 | version = "0.10.0" 1058 | source = "registry+https://github.com/rust-lang/crates.io-index" 1059 | checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" 1060 | 1061 | [[package]] 1062 | name = "syn" 1063 | version = "1.0.81" 1064 | source = "registry+https://github.com/rust-lang/crates.io-index" 1065 | checksum = "f2afee18b8beb5a596ecb4a2dce128c719b4ba399d34126b9e4396e3f9860966" 1066 | dependencies = [ 1067 | "proc-macro2", 1068 | "quote", 1069 | "unicode-xid", 1070 | ] 1071 | 1072 | [[package]] 1073 | name = "synstructure" 1074 | version = "0.12.6" 1075 | source = "registry+https://github.com/rust-lang/crates.io-index" 1076 | checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" 1077 | dependencies = [ 1078 | "proc-macro2", 1079 | "quote", 1080 | "syn", 1081 | "unicode-xid", 1082 | ] 1083 | 1084 | [[package]] 1085 | name = "tokio" 1086 | version = "1.14.0" 1087 | source = "registry+https://github.com/rust-lang/crates.io-index" 1088 | checksum = "70e992e41e0d2fb9f755b37446f20900f64446ef54874f40a60c78f021ac6144" 1089 | dependencies = [ 1090 | "autocfg", 1091 | "bytes 1.1.0", 1092 | "libc", 1093 | "memchr", 1094 | "mio 0.7.14", 1095 | "num_cpus", 1096 | "once_cell", 1097 | "pin-project-lite", 1098 | "signal-hook-registry", 1099 | "tokio-macros", 1100 | "winapi 0.3.9", 1101 | ] 1102 | 1103 | [[package]] 1104 | name = "tokio-executor" 1105 | version = "0.1.10" 1106 | source = "registry+https://github.com/rust-lang/crates.io-index" 1107 | checksum = "fb2d1b8f4548dbf5e1f7818512e9c406860678f29c300cdf0ebac72d1a3a1671" 1108 | dependencies = [ 1109 | "crossbeam-utils", 1110 | "futures 0.1.31", 1111 | ] 1112 | 1113 | [[package]] 1114 | name = "tokio-io" 1115 | version = "0.1.13" 1116 | source = "registry+https://github.com/rust-lang/crates.io-index" 1117 | checksum = "57fc868aae093479e3131e3d165c93b1c7474109d13c90ec0dda2a1bbfff0674" 1118 | dependencies = [ 1119 | "bytes 0.4.12", 1120 | "futures 0.1.31", 1121 | "log", 1122 | ] 1123 | 1124 | [[package]] 1125 | name = "tokio-macros" 1126 | version = "1.6.0" 1127 | source = "registry+https://github.com/rust-lang/crates.io-index" 1128 | checksum = "c9efc1aba077437943f7515666aa2b882dfabfbfdf89c819ea75a8d6e9eaba5e" 1129 | dependencies = [ 1130 | "proc-macro2", 1131 | "quote", 1132 | "syn", 1133 | ] 1134 | 1135 | [[package]] 1136 | name = "tokio-ping" 1137 | version = "0.3.0" 1138 | source = "registry+https://github.com/rust-lang/crates.io-index" 1139 | checksum = "ac5dff47c58fc7d4db81e71345f797554f4a8ce167ffcd0bc7f509e780b12cfd" 1140 | dependencies = [ 1141 | "failure", 1142 | "futures 0.1.31", 1143 | "libc", 1144 | "mio 0.6.23", 1145 | "parking_lot 0.5.5", 1146 | "rand", 1147 | "socket2", 1148 | "tokio-executor", 1149 | "tokio-reactor", 1150 | "tokio-timer", 1151 | ] 1152 | 1153 | [[package]] 1154 | name = "tokio-reactor" 1155 | version = "0.1.12" 1156 | source = "registry+https://github.com/rust-lang/crates.io-index" 1157 | checksum = "09bc590ec4ba8ba87652da2068d150dcada2cfa2e07faae270a5e0409aa51351" 1158 | dependencies = [ 1159 | "crossbeam-utils", 1160 | "futures 0.1.31", 1161 | "lazy_static", 1162 | "log", 1163 | "mio 0.6.23", 1164 | "num_cpus", 1165 | "parking_lot 0.9.0", 1166 | "slab", 1167 | "tokio-executor", 1168 | "tokio-io", 1169 | "tokio-sync", 1170 | ] 1171 | 1172 | [[package]] 1173 | name = "tokio-sync" 1174 | version = "0.1.8" 1175 | source = "registry+https://github.com/rust-lang/crates.io-index" 1176 | checksum = "edfe50152bc8164fcc456dab7891fa9bf8beaf01c5ee7e1dd43a397c3cf87dee" 1177 | dependencies = [ 1178 | "fnv", 1179 | "futures 0.1.31", 1180 | ] 1181 | 1182 | [[package]] 1183 | name = "tokio-timer" 1184 | version = "0.2.13" 1185 | source = "registry+https://github.com/rust-lang/crates.io-index" 1186 | checksum = "93044f2d313c95ff1cb7809ce9a7a05735b012288a888b62d4434fd58c94f296" 1187 | dependencies = [ 1188 | "crossbeam-utils", 1189 | "futures 0.1.31", 1190 | "slab", 1191 | "tokio-executor", 1192 | ] 1193 | 1194 | [[package]] 1195 | name = "ucd-trie" 1196 | version = "0.1.3" 1197 | source = "registry+https://github.com/rust-lang/crates.io-index" 1198 | checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" 1199 | 1200 | [[package]] 1201 | name = "unicode-width" 1202 | version = "0.1.9" 1203 | source = "registry+https://github.com/rust-lang/crates.io-index" 1204 | checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" 1205 | 1206 | [[package]] 1207 | name = "unicode-xid" 1208 | version = "0.2.2" 1209 | source = "registry+https://github.com/rust-lang/crates.io-index" 1210 | checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" 1211 | 1212 | [[package]] 1213 | name = "version_check" 1214 | version = "0.9.3" 1215 | source = "registry+https://github.com/rust-lang/crates.io-index" 1216 | checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" 1217 | 1218 | [[package]] 1219 | name = "winapi" 1220 | version = "0.2.8" 1221 | source = "registry+https://github.com/rust-lang/crates.io-index" 1222 | checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" 1223 | 1224 | [[package]] 1225 | name = "winapi" 1226 | version = "0.3.9" 1227 | source = "registry+https://github.com/rust-lang/crates.io-index" 1228 | checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" 1229 | dependencies = [ 1230 | "winapi-i686-pc-windows-gnu", 1231 | "winapi-x86_64-pc-windows-gnu", 1232 | ] 1233 | 1234 | [[package]] 1235 | name = "winapi-build" 1236 | version = "0.1.1" 1237 | source = "registry+https://github.com/rust-lang/crates.io-index" 1238 | checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" 1239 | 1240 | [[package]] 1241 | name = "winapi-i686-pc-windows-gnu" 1242 | version = "0.4.0" 1243 | source = "registry+https://github.com/rust-lang/crates.io-index" 1244 | checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 1245 | 1246 | [[package]] 1247 | name = "winapi-x86_64-pc-windows-gnu" 1248 | version = "0.4.0" 1249 | source = "registry+https://github.com/rust-lang/crates.io-index" 1250 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 1251 | 1252 | [[package]] 1253 | name = "ws2_32-sys" 1254 | version = "0.2.1" 1255 | source = "registry+https://github.com/rust-lang/crates.io-index" 1256 | checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" 1257 | dependencies = [ 1258 | "winapi 0.2.8", 1259 | "winapi-build", 1260 | ] 1261 | 1262 | [[package]] 1263 | name = "zerocopy" 1264 | version = "0.6.1" 1265 | source = "registry+https://github.com/rust-lang/crates.io-index" 1266 | checksum = "332f188cc1bcf1fe1064b8c58d150f497e697f49774aa846f2dc949d9a25f236" 1267 | dependencies = [ 1268 | "byteorder", 1269 | "zerocopy-derive", 1270 | ] 1271 | 1272 | [[package]] 1273 | name = "zerocopy-derive" 1274 | version = "0.3.1" 1275 | source = "registry+https://github.com/rust-lang/crates.io-index" 1276 | checksum = "a0fbc82b82efe24da867ee52e015e58178684bd9dd64c34e66bdf21da2582a9f" 1277 | dependencies = [ 1278 | "proc-macro2", 1279 | "syn", 1280 | "synstructure", 1281 | ] 1282 | --------------------------------------------------------------------------------