Merge pull request #17 from nymtech/feature/directory-server-option
presence: ability to configure local directory server
This commit is contained in:
+8
-3
@@ -57,7 +57,11 @@ fn main() {
|
||||
.help("Directory storing all packets for the clients")
|
||||
.takes_value(true)
|
||||
.required(true),
|
||||
),
|
||||
).arg(Arg::with_name("local")
|
||||
.long("local")
|
||||
.help("Flag to indicate whether the provider should run on a local deployment.")
|
||||
.takes_value(false)
|
||||
)
|
||||
)
|
||||
.get_matches();
|
||||
|
||||
@@ -69,6 +73,7 @@ fn main() {
|
||||
|
||||
fn run(matches: &ArgMatches) {
|
||||
println!("Running the service provider!");
|
||||
let is_local = matches.is_present("local");
|
||||
|
||||
let mix_host = matches.value_of("mixHost").unwrap_or("0.0.0.0");
|
||||
let mix_port = match matches.value_of("mixPort").unwrap().parse::<u16>() {
|
||||
@@ -124,8 +129,8 @@ fn run(matches: &ArgMatches) {
|
||||
);
|
||||
|
||||
// Start sending presence notifications in a separate thread
|
||||
thread::spawn(|| {
|
||||
let notifier = presence::Notifier::new();
|
||||
thread::spawn(move || {
|
||||
let notifier = presence::Notifier::new(is_local.clone());
|
||||
notifier.run();
|
||||
});
|
||||
|
||||
|
||||
@@ -13,10 +13,14 @@ pub struct Notifier {
|
||||
}
|
||||
|
||||
impl Notifier {
|
||||
pub fn new() -> Notifier {
|
||||
let config = directory::Config {
|
||||
base_url: "https://directory.nymtech.net/".to_string(),
|
||||
pub fn new(is_local: bool) -> Notifier {
|
||||
let url = if is_local {
|
||||
"http://localhost:8080".to_string()
|
||||
} else {
|
||||
"https://directory.nymtech.net".to_string()
|
||||
};
|
||||
|
||||
let config = directory::Config { base_url: url };
|
||||
let net_client = directory::Client::new(config);
|
||||
let presence = MixProviderPresence {
|
||||
host: "halpin.org:6666".to_string(),
|
||||
|
||||
Reference in New Issue
Block a user