From 4f79e3d7196aad54425151a75a28811bc64c5f0e Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Sat, 25 Jun 2016 21:23:53 -0400 Subject: [PATCH] get system hostname --- Cargo.lock | 11 +++++++++++ Cargo.toml | 1 + src/main.rs | 16 ++++++++++++++++ typescript/sentences.ts | 36 ++++++++++++++++++++++++++++++++---- 4 files changed, 60 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 288223782..f55f57988 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7,6 +7,7 @@ dependencies = [ "hyper 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "iron 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "resolve 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "router 0.0.16 (registry+https://github.com/rust-lang/crates.io-index)", "rust-crypto 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", @@ -315,6 +316,16 @@ dependencies = [ "winapi 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "resolve" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "route-recognizer" version = "0.1.11" diff --git a/Cargo.toml b/Cargo.toml index 51244c76d..fc4bacd40 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,6 +14,7 @@ hyper = "0.7.*" iron = "0.2.*" log = "0.3.*" + resolve = "0.1.1" router = "0.0.16" rust-crypto = "0.2.*" rustc-serialize = "0.3.15" diff --git a/src/main.rs b/src/main.rs index 383f7ba5d..34d379738 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,6 +6,7 @@ extern crate hound; extern crate iron; #[macro_use] extern crate log; +extern crate resolve; extern crate router; extern crate rustc_serialize; extern crate time; @@ -23,6 +24,7 @@ use std::path::{Path, PathBuf}; use clap::{App, Arg, ArgMatches}; use iron::prelude::*; use router::Router; +use resolve::hostname; use config::Config; use handlers::audio_synth_handler::AudioSynthHandler; @@ -52,6 +54,8 @@ fn main() { VocabularyLibrary::read_from_directory( Path::new(&config.sound_path_development)); + get_hostname(); + start_server(&config, port); } @@ -89,3 +93,15 @@ fn start_server(config: &Config, port: u16) { Iron::new(router).http(("0.0.0.0", port)).unwrap(); } +fn get_hostname() { + match hostname::get_hostname() { + Ok(s) => { println!("Hostname: {}", s); }, + Err(_) => {}, + }; + + /*let len = 34u; + let mut buf = std::vec::from_elem(len, 0u8); + + let err = unsafe {gethostname (vec::raw::to_mut_ptr(buf) as *mut i8, len as u64)}; + if err != 0 { println("oops, gethostname failed"); return; }*/ +} diff --git a/typescript/sentences.ts b/typescript/sentences.ts index 558cec032..d7c8d9789 100644 --- a/typescript/sentences.ts +++ b/typescript/sentences.ts @@ -1,10 +1,38 @@ const SENTENCES : string[] = [ - "hillary is my favorite person in the world", - "i think your parents are absolutely stupid", - "what are you doing to those children", - "i remember when I was only fifty seven years of age", "don't murder the poor people", + "hillary destroys all the good things", + "hillary is my favorite person in the world", + "i feel that war is a beautiful thing", + "i must be going crazy", + "i needed my mother and father that day", + "i remember when I was only fifty seven years of age", + "i saw children dying every way i look", + "i think your parents are absolutely stupid", + "i want all of your money immediately after this", + "i want to come in first place", + "i will always think you are stupid", + "i'm smarter than your children", + "i'm the president of reality space and the internet", + "it was a long time ago when hillary and bill got married", + "it's really amazing how dumb you are", + "just see the chaos i can create", + "let's count some numbers", + "let's make america great again", + "our civilization is better than the one they have", + "stop it", + "that man has taken all of my money", + "the total chaos and destruction is beautiful", + "there are countless children i needed to take from their countries", + "there are great images on the internet you know", + "this is the opportunity to take from the rich", + "we are all victims of harassment and abuse", + "what are you doing to those children", + "you and i are the same", + "you are all fools and i hate you", + "you fricken moron", + "that has increased my interest", + "your country is tragic and terrible", ]; export = SENTENCES;