mirror of
https://github.com/valmojr/armatak.git
synced 2026-06-13 16:03:31 +00:00
removed test callback
This commit is contained in:
@@ -38,7 +38,6 @@ pub fn init() -> Extension {
|
|||||||
)
|
)
|
||||||
.command("local_ip", util::get_local_address)
|
.command("local_ip", util::get_local_address)
|
||||||
.command("uuid", util::get_uuid)
|
.command("uuid", util::get_uuid)
|
||||||
.command("callback", util::test_callback)
|
|
||||||
.command("log", util::log_info)
|
.command("log", util::log_info)
|
||||||
.group(
|
.group(
|
||||||
"cot_router",
|
"cot_router",
|
||||||
|
|||||||
21
src/util.rs
21
src/util.rs
@@ -1,14 +1,13 @@
|
|||||||
use arma_rs::Context;
|
use crate::structs::LogPayload;
|
||||||
use log::{error, info, warn};
|
use log::{error, info, warn};
|
||||||
use std::net::{IpAddr, UdpSocket};
|
use std::net::{IpAddr, UdpSocket};
|
||||||
use crate::structs::LogPayload;
|
|
||||||
|
|
||||||
pub fn log_info(data: LogPayload) -> String {
|
pub fn log_info(data: LogPayload) -> String {
|
||||||
match data.status.as_str() {
|
match data.status.as_str() {
|
||||||
"info" => info!("{}", data.message),
|
"info" => info!("{}", data.message),
|
||||||
"warn" => warn!("{}", data.message),
|
"warn" => warn!("{}", data.message),
|
||||||
"error" => error!("{}", data.message),
|
"error" => error!("{}", data.message),
|
||||||
_ => error!("{}","Wrong log call")
|
_ => error!("{}", "Wrong log call"),
|
||||||
}
|
}
|
||||||
"logged".to_string()
|
"logged".to_string()
|
||||||
}
|
}
|
||||||
@@ -18,15 +17,13 @@ pub fn get_uuid() -> String {
|
|||||||
|
|
||||||
let id = Uuid::new_v4().to_string();
|
let id = Uuid::new_v4().to_string();
|
||||||
|
|
||||||
return id
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_local_address() -> String {
|
pub fn get_local_address() -> String {
|
||||||
fn get_local_ip() -> Result<IpAddr, String> {
|
fn get_local_ip() -> Result<IpAddr, String> {
|
||||||
let socket = UdpSocket::bind("0.0.0.0:0").map_err(|e| e.to_string())?;
|
let socket = UdpSocket::bind("0.0.0.0:0").map_err(|e| e.to_string())?;
|
||||||
socket
|
socket.connect("8.8.8.8:80").map_err(|e| e.to_string())?;
|
||||||
.connect("8.8.8.8:80")
|
|
||||||
.map_err(|e| e.to_string())?;
|
|
||||||
socket
|
socket
|
||||||
.local_addr()
|
.local_addr()
|
||||||
.map(|addr| addr.ip())
|
.map(|addr| addr.ip())
|
||||||
@@ -38,15 +35,9 @@ pub fn get_local_address() -> String {
|
|||||||
match parsed_data {
|
match parsed_data {
|
||||||
Ok(ip) => {
|
Ok(ip) => {
|
||||||
return format!("ws://{}:4152", ip.to_string());
|
return format!("ws://{}:4152", ip.to_string());
|
||||||
},
|
}
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
return "not provided".to_string();
|
return "not provided".to_string();
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn test_callback(ctx: Context) -> &'static str {
|
|
||||||
let _ = ctx.callback_data("armatak_test_callback", "123", "321");
|
|
||||||
|
|
||||||
"Testing Callback"
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user