2020-11-02 03:34:50 +00:00
|
|
|
use std::{
|
|
|
|
error::Error,
|
|
|
|
fs::File,
|
|
|
|
};
|
2020-10-30 22:53:03 +00:00
|
|
|
|
|
|
|
#[tokio::main]
|
|
|
|
async fn main () -> Result <(), Box <dyn Error>> {
|
2020-11-02 03:34:50 +00:00
|
|
|
use std::io::Read;
|
|
|
|
|
2020-11-02 13:37:08 +00:00
|
|
|
let config_file = {
|
|
|
|
let config_file_path = "ptth_relay.toml";
|
|
|
|
|
|
|
|
let mut f = File::open (config_file_path).expect (&format! ("Can't open {:?}", config_file_path));
|
|
|
|
let mut buffer = vec! [0u8; 4096];
|
|
|
|
let bytes_read = f.read (&mut buffer).expect (&format! ("Can't read {:?}", config_file_path));
|
|
|
|
buffer.truncate (bytes_read);
|
|
|
|
|
|
|
|
let config_s = String::from_utf8 (buffer).expect (&format! ("Can't parse {:?} as UTF-8", config_file_path));
|
|
|
|
toml::from_str (&config_s).expect (&format! ("Can't parse {:?} as TOML", config_file_path))
|
|
|
|
};
|
2020-11-02 03:34:50 +00:00
|
|
|
|
2020-11-02 18:07:34 +00:00
|
|
|
eprintln! ("ptth_relay Git version: {:?}", ptth::git_version::GIT_VERSION);
|
|
|
|
|
2020-11-02 03:34:50 +00:00
|
|
|
ptth::relay::main (config_file).await
|
2020-10-30 22:53:03 +00:00
|
|
|
}
|