67 lines
1.7 KiB
Rust
67 lines
1.7 KiB
Rust
// Copyright (C) 2022-2099 The crate authors.
|
|
//
|
|
// This program is free software: you can redistribute it and/or modify it
|
|
// under the terms of the GNU Affero General Public License as published by the
|
|
// Free Software Foundation, either version 3 of the License, or (at your
|
|
// option) any later version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful, but WITHOUT
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License
|
|
// for more details.
|
|
//
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
#![feature(let_chains)]
|
|
#![feature(once_cell)]
|
|
// Maybe change that someday?
|
|
#![allow(clippy::result_large_err)]
|
|
|
|
mod component;
|
|
mod error;
|
|
mod handlers;
|
|
mod occupant;
|
|
mod presence;
|
|
mod room;
|
|
mod session;
|
|
|
|
#[cfg(test)]
|
|
mod tests;
|
|
|
|
use crate::component::Component;
|
|
use crate::error::Error;
|
|
use crate::handlers::handle_stanza;
|
|
use crate::room::Room;
|
|
|
|
use std::collections::HashMap;
|
|
use std::env::args;
|
|
use std::process::exit;
|
|
|
|
use log::info;
|
|
use xmpp_parsers::BareJid;
|
|
|
|
#[tokio::main]
|
|
async fn main() -> Result<(), Error> {
|
|
let args: Vec<String> = args().collect();
|
|
if args.len() != 3 {
|
|
println!("Usage: {} <jid> <password>", args[0]);
|
|
exit(1);
|
|
}
|
|
|
|
let jid = &args[1];
|
|
let passwd = &args[2];
|
|
let server = "::1";
|
|
let port = 5347u16;
|
|
|
|
env_logger::init();
|
|
|
|
let mut component = Component::new(jid, passwd, server, port).await.unwrap();
|
|
info!("Online as {}!", component.jid);
|
|
|
|
let mut rooms: HashMap<BareJid, Room> = HashMap::new();
|
|
|
|
handle_stanza(&mut component, &mut rooms).await?;
|
|
|
|
Ok(())
|
|
}
|