Compare commits
3 Commits
f121e3fd55
...
b05a87cc9c
Author | SHA1 | Date |
---|---|---|
_ | b05a87cc9c | |
_ | 354a74aeaa | |
_ | d9fd0fd29d |
|
@ -0,0 +1,3 @@
|
||||||
|
[submodule "vendored/directories"]
|
||||||
|
path = vendored/directories
|
||||||
|
url = git@github.com:ReactorScram/directories-rs.git
|
|
@ -35,8 +35,6 @@ checksum = "06821ea598337a8412cf47c5b71c3bc694a7f0aed188ac28b836fab164a2c202"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "directories"
|
name = "directories"
|
||||||
version = "4.0.1"
|
version = "4.0.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f51c5d4ddabd36886dd3e1438cb358cdcb0d7c499cb99cb4ac2e38e18b5cb210"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dirs-sys",
|
"dirs-sys",
|
||||||
]
|
]
|
||||||
|
|
|
@ -13,7 +13,7 @@ version = "0.1.6"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
configparser = "3.0.0"
|
configparser = "3.0.0"
|
||||||
directories = "4.0.1"
|
directories = { path = "vendored/directories" }
|
||||||
mac_address = "1.1.2"
|
mac_address = "1.1.2"
|
||||||
rand = "0.8.4"
|
rand = "0.8.4"
|
||||||
thiserror = "1.0.30"
|
thiserror = "1.0.30"
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
type Mac = [u8; 6];
|
||||||
|
|
||||||
|
pub fn debug () {
|
||||||
|
for input in [
|
||||||
|
[0, 0, 0, 0, 0, 0],
|
||||||
|
[0, 0, 0, 0, 0, 1],
|
||||||
|
[1, 0, 0, 0, 0, 0],
|
||||||
|
[1, 0, 0, 0, 0, 1],
|
||||||
|
] {
|
||||||
|
assert_eq! (unmix (mix (input)), input);
|
||||||
|
}
|
||||||
|
|
||||||
|
println! ("Passed");
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOT intended for any cryptography or security. This is TRIVIALLY reversible.
|
||||||
|
// It's just to make it easier for humans to tell apart MACs where only a couple
|
||||||
|
// numbers differ.
|
||||||
|
|
||||||
|
fn mix (i: Mac) -> Mac {
|
||||||
|
[
|
||||||
|
i [0] ^ i [5],
|
||||||
|
i [1] ^ i [4],
|
||||||
|
i [2] ^ i [3],
|
||||||
|
i [3],
|
||||||
|
i [4],
|
||||||
|
i [5],
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
fn unmix (i: Mac) -> Mac {
|
||||||
|
[
|
||||||
|
i [0] ^ i [5],
|
||||||
|
i [1] ^ i [4],
|
||||||
|
i [2] ^ i [3],
|
||||||
|
i [3],
|
||||||
|
i [4],
|
||||||
|
i [5],
|
||||||
|
]
|
||||||
|
}
|
|
@ -165,7 +165,7 @@ fn load_config_file () -> ConfigFile {
|
||||||
|
|
||||||
if let Some (proj_dirs) = find_project_dirs () {
|
if let Some (proj_dirs) = find_project_dirs () {
|
||||||
let mut ini = Ini::new_cs ();
|
let mut ini = Ini::new_cs ();
|
||||||
let path = proj_dirs.config_dir ().join ("client.ini");
|
let path = proj_dirs.config_local_dir ().join ("client.ini");
|
||||||
if ini.load (&path).is_ok () {
|
if ini.load (&path).is_ok () {
|
||||||
let map_ref = ini.get_map_ref ();
|
let map_ref = ini.get_map_ref ();
|
||||||
if let Some (x) = map_ref.get ("nicknames") {
|
if let Some (x) = map_ref.get ("nicknames") {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use prelude::*;
|
use prelude::*;
|
||||||
|
|
||||||
pub mod app_common;
|
pub mod app_common;
|
||||||
|
mod avalanche;
|
||||||
mod client;
|
mod client;
|
||||||
mod ip;
|
mod ip;
|
||||||
pub mod message;
|
pub mod message;
|
||||||
|
@ -31,6 +32,7 @@ async fn async_main () -> Result <(), AppError> {
|
||||||
Some ("--version") => println! ("lookaround v{}", LOOKAROUND_VERSION),
|
Some ("--version") => println! ("lookaround v{}", LOOKAROUND_VERSION),
|
||||||
Some ("client") => client::client (args).await?,
|
Some ("client") => client::client (args).await?,
|
||||||
Some ("config") => config (),
|
Some ("config") => config (),
|
||||||
|
Some ("debug-avalanche") => avalanche::debug (),
|
||||||
Some ("find-nick") => client::find_nick (args).await?,
|
Some ("find-nick") => client::find_nick (args).await?,
|
||||||
Some ("my-ips") => my_ips ()?,
|
Some ("my-ips") => my_ips ()?,
|
||||||
Some ("server") => server::server (args).await?,
|
Some ("server") => server::server (args).await?,
|
||||||
|
@ -42,7 +44,7 @@ async fn async_main () -> Result <(), AppError> {
|
||||||
|
|
||||||
fn config () {
|
fn config () {
|
||||||
if let Some (proj_dirs) = ProjectDirs::from ("", "ReactorScram", "LookAround") {
|
if let Some (proj_dirs) = ProjectDirs::from ("", "ReactorScram", "LookAround") {
|
||||||
println! ("Using config dir {:?}", proj_dirs.config_dir ());
|
println! ("Using config dir {:?}", proj_dirs.config_local_dir ());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
println! ("Can't detect config dir.");
|
println! ("Can't detect config dir.");
|
||||||
|
|
|
@ -41,7 +41,7 @@ fn configure <I: Iterator <Item=String>> (mut args: I) -> Result <Params, AppErr
|
||||||
|
|
||||||
if let Some (proj_dirs) = find_project_dirs () {
|
if let Some (proj_dirs) = find_project_dirs () {
|
||||||
let mut ini = Ini::new_cs ();
|
let mut ini = Ini::new_cs ();
|
||||||
let path = proj_dirs.config_dir ().join ("server.ini");
|
let path = proj_dirs.config_local_dir ().join ("server.ini");
|
||||||
if ini.load (&path).is_ok () {
|
if ini.load (&path).is_ok () {
|
||||||
if let Some (x) = ini.get ("server", "nickname") {
|
if let Some (x) = ini.get ("server", "nickname") {
|
||||||
nickname = x;
|
nickname = x;
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 6b95e6319cb69933c07dba98e6af26d7145e0bd9
|
Loading…
Reference in New Issue