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5KJRH3EGRPIQC BQFOYJRTLAFIBZ3SOERSUB2ZXMXJUAROXOGMGWHJW4CVBRT4R5QAC F3IDYEIHR2FA7SCE2MYVQSUQ5SOPGJ5IKBTS2V3HLM52SWGQ322AC K3I54HXNNCTEA7L6UGWIVBFB5TPZVZZXDBRSR2YZDIKREXQVWRIQC 7RMAZDLQ6FEEQGUUAIVEM4X2VME7IUUZMEJMMV3H46U3UKO4BODQC VGCFXINBC7EXPRMSH642IDSRBDIR7DJ6WKKSNS4F4SDCEKATXXAAC LBG7DYYI7WCROF4GRYVXDXIV2465E5KPGQVZTFUPTZQBNZZ3LNYAC 2ZDRU4SSJJ4LJVQRQUZMD662TPJQTHQKDPZFMERPKTLNCHHDIUTQC [root]name = "elemeld"version = "0.1.0"
# This file is automatically @generated by Cargo.# It is not intended for manual editing.[[package]]name = "aho-corasick"version = "0.7.13"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "043164d8ba5c4c3035fec9bbee8647c0261d788f3474306f93bb65901cae0e86"
"bincode 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)","docopt 0.6.80 (registry+https://github.com/rust-lang/crates.io-index)","docopt_macros 0.6.84 (registry+https://github.com/rust-lang/crates.io-index)","dylib 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)","env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)","libc 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)","log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)","mio 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)","nix 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)","rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)","serde 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)","serde_json 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)","serde_macros 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)","ws 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)","x11-dl 2.4.0 (git+https://github.com/MetaDark/x11-rs.git)",
"memchr",
dependencies = ["memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",]
checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544"
"byteorder 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)","num-traits 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)","rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)","serde 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)",
"hermit-abi","libc","winapi 0.3.9",
dependencies = ["regex 0.1.71 (registry+https://github.com/rust-lang/crates.io-index)","rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)","strsim 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",]
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
name = "httparse"version = "1.1.2"source = "registry+https://github.com/rust-lang/crates.io-index"
name = "elemeld"version = "0.1.0"dependencies = ["dirs","env_logger","get_if_addrs","hostname","log","serde","serde_json",]
"winapi 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)","winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"atty","humantime","log","regex","termcolor",
[[package]]name = "matches"version = "0.1.2"source = "registry+https://github.com/rust-lang/crates.io-index"[[package]]name = "memchr"version = "0.1.11"source = "registry+https://github.com/rust-lang/crates.io-index"dependencies = ["libc 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",][[package]]name = "mio"version = "0.5.1"source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "abddb55a898d32925f3148bd281174a68eeb68bbfd9a5938a57b18f506ee4ef7"
"bytes 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)","libc 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)","log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)","miow 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)","net2 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)","nix 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)","slab 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)","time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)","winapi 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
"c_linked_list","get_if_addrs-sys","libc","winapi 0.2.8",
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)","net2 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)","winapi 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)","ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"gcc","libc",
"cfg-if 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)","kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)","libc 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)","winapi 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)","ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"cfg-if","libc","wasi",
"num-integer 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)","num-iter 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)","num-traits 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
"libc","match_cfg","winapi 0.3.9",
dependencies = ["num-integer 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)","num-traits 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",]
checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6"
dependencies = ["quasi_codegen 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",]
checksum = "ffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4"
dependencies = ["libc 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",]
checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400"
"aho-corasick 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)","memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)","regex-syntax 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)","thread_local 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)","utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-xid",
"aster 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)","quasi 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)","quasi_macros 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"getrandom","redox_syscall","rust-argon2",
dependencies = ["serde_codegen 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)",]
checksum = "26412eb97c6b088a6997e05f69403a802a92d520de2f8e63c2b65f9e0f47c4e8"
"matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)","rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)","unicode-bidi 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)","unicode-normalization 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)","uuid 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static",
dependencies = ["httparse 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)","log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)","mio 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)","rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)","sha1 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)","url 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)",]
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
name = "x11-dl"version = "2.4.0"source = "git+https://github.com/MetaDark/x11-rs.git#b582a8e605ef8281b4bca826b7403be137e78bd9"dependencies = ["dylib 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)","libc 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",]
name = "winapi-x86_64-pc-windows-gnu"version = "0.4.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
mio = "*"ws = "*"serde = "*"rustc-serialize = "*"serde_json = "*"bincode = "*"serde_macros = "*"x11-dl = { git = "https://github.com/MetaDark/x11-rs.git" }dylib = "*"libc = "*"nix = "*"log = "*"env_logger = "*"docopt = "*"docopt_macros = "*"
dirs = "3.0"env_logger = "0.7"get_if_addrs = "0.5"hostname = "0.3"log = "0.4"serde = { version = "1.0", features = ["derive"] }serde_json = "1.0"# mio = "*"# ws = "*"# serde = "*"# rustc-serialize = "*"# serde_json = "*"# bincode = "*"# serde_macros = "*"# x11-dl = { git = "https://github.com/MetaDark/x11-rs.git" }# dylib = "*"# libc = "*"# nix = "*"# log = "*"# docopt = "*"# docopt_macros = "*"
addrs: util::get_host_ips().unwrap().into_iter().filter_map(|addr| match addr {IpAddr::V4(addr) =>if !addr.is_loopback() {Some(SocketAddr::V4(SocketAddrV4::new(addr, port)))} else { None },IpAddr::V6(addr) =>if !addr.is_loopback() {Some(SocketAddr::V6(SocketAddrV6::new(addr, port, 0, 0)))} else { None },
addrs: util::get_host_ips().unwrap().filter_map(|addr| {if !addr.is_loopback() {Some(SocketAddr::new(addr, port))} else {None}
&self.addrs[0].0}}#[derive(Clone, PartialEq, Eq, Hash, Debug)]struct Addr(SocketAddr);impl serde::Serialize for Addr {fn serialize<S>(&self, serializer: &mut S) -> Result<(), S::Error>where S: serde::Serializer{serializer.serialize_str(&format!("{}", self.0))}}impl serde::Deserialize for Addr {fn deserialize<D>(deserializer: &mut D) -> Result<Self, D::Error>where D: serde::Deserializer{struct SocketAddrVisitor;impl serde::de::Visitor for SocketAddrVisitor {type Value = Addr;fn visit_str<E>(&mut self, val: &str) -> Result<Self::Value, E>where E: serde::de::Error,{match val.parse::<SocketAddr>() {Ok(addr) => Ok(Addr(addr)),Err(_) => Err(serde::de::Error::custom("expected socket address")),}}}deserializer.deserialize_string(SocketAddrVisitor)
&self.addrs[0]
#![feature(custom_derive, plugin)]#![plugin(serde_macros, docopt_macros)]// Used for utilextern crate libc;extern crate nix;extern crate mio;extern crate ws;extern crate serde;extern crate rustc_serialize;extern crate serde_json;extern crate bincode;extern crate x11_dl;#[macro_use]extern crate log;extern crate env_logger;extern crate docopt;mod hub;mod config_server;
use hub::Hub;use mio::IpAddr;use ip::{IpInterface, Config};use x11::X11Interface;docopt!(Args derive Debug, "Usage:elemeld [-b <bind_addr>] [-m <multicast_addr>] [-p <port>]elemeld -h | --helpelemeld --versionOptions:-b <bind_addr> Bind address [default: 0.0.0.0].-m <multicast_addr> Multicast address [default: 224.0.2.42].-p <port> Port [default: 24242].-h --help Show this screen.-v --version Show version.", flag_p: u16);
env_logger::init().unwrap();let args: Args = Args::docopt().decode().unwrap_or_else(|e| e.exit());if args.flag_version {println!("elemeld 0.1.0");return;};let host = X11Interface::open();let net = IpInterface::open(Config {server_addr: args.flag_b.parse::<IpAddr>().unwrap(),multicast_addr: args.flag_m.parse::<IpAddr>().unwrap(),port: args.flag_p,}).unwrap();let mut elemeld = Hub::new(host, net).unwrap();elemeld.run().unwrap();
use nix;use nix::errno::Errno;use nix::unistd::{gethostname};use nix::sys::socket::{Ipv4Addr, Ipv6Addr, sockaddr_in, sockaddr_in6};use std::{mem, ptr, net, env};use libc::{strlen, getifaddrs, freeifaddrs, AF_INET, AF_INET6};
use std::io;use std::net::IpAddr;
pub fn get_host_name() -> Result<String, nix::Error> {let mut buf = [0; 255];gethostname(&mut buf).map(|_| {let len = unsafe { strlen(mem::transmute(&buf as *const u8)) };String::from_utf8_lossy(&buf[..len]).into_owned()})
pub fn get_host_name() -> io::Result<String> {hostname::get()?.into_string().map_err(|_| io::Error::new(io::ErrorKind::InvalidData, "invalid utf-8"))
pub fn get_host_ips() -> Result<Vec<net::IpAddr>, nix::Error> {let mut addrs = Vec::new();unsafe {let mut list = ptr::null_mut();if getifaddrs(&mut list) != 0 {return Err(nix::Error::Sys(Errno::last()));}let mut ptr = list;while !ptr.is_null() {if !(*ptr).ifa_addr.is_null() {match (*(*ptr).ifa_addr).sa_family as i32 {AF_INET => {let sa = (*ptr).ifa_addr as *const sockaddr_in;addrs.push(net::IpAddr::V4(Ipv4Addr((*sa).sin_addr).to_std()));},AF_INET6 => {let sa = (*ptr).ifa_addr as *const sockaddr_in6;addrs.push(net::IpAddr::V6(Ipv6Addr((*sa).sin6_addr).to_std()));},_ => (),}}ptr = (*ptr).ifa_next;}freeifaddrs(list);};Ok(addrs)
pub fn get_host_ips() -> io::Result<impl Iterator<Item=IpAddr>> {Ok(get_if_addrs::get_if_addrs()?.into_iter().map(|interface| interface.addr.ip()))
env::home_dir().map(|base| {base.join(".config").join(name)})// I think this is what is needed for other// OSes but I can't test them right now://// Windows: %APPDATA%\<name>// Mac: ~/Library/Preferences/<name> or// ~/Library/Application Support/<name>//
Some(dirs::config_dir()?.join(name))