From fb8a03ae229b17fcc9f90ae4be662d543e281f69 Mon Sep 17 00:00:00 2001 From: Andy Killorin <37423245+Speedy6451@users.noreply.github.com> Date: Sat, 16 Dec 2023 19:45:53 -0600 Subject: [PATCH] dynamic dns --- client/client.lua | 4 ---- server/Cargo.toml | 1 + server/Makefile | 9 +++++++++ server/src/main.rs | 3 ++- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/client/client.lua b/client/client.lua index a7749b5..9292668 100644 --- a/client/client.lua +++ b/client/client.lua @@ -1,7 +1,3 @@ --- wget run http://68.46.126.104:48228/turtle/client.lua - -local ipaddr = "68.46.126.104" - if not ipaddr then if fs.exists("/disk/ip") then local ipfile = fs.open("/disk/ip") diff --git a/server/Cargo.toml b/server/Cargo.toml index 0925011..dabc152 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -9,6 +9,7 @@ edition = "2021" anyhow = "1.0.75" axum = "0.7.2" bit-struct = "0.3.2" +const_format = "0.2.32" feistel_rs = "0.1.0" rstar = "0.11.0" rustmatica = "0.1.1" diff --git a/server/Makefile b/server/Makefile index a347ff7..d752709 100644 --- a/server/Makefile +++ b/server/Makefile @@ -1,3 +1,12 @@ +GLOBAL_IP=`dig +short @dns.toys -4 ip` + +.PHONY: server server-opt +server: surnames.txt names.txt + GLOBAL_IP=$(GLOBAL_IP) cargo run + +server-opt: surnames.txt names.txt + GLOBAL_IP=$(GLOBAL_IP) cargo run --release + surnames.txt: curl https://raw.githubusercontent.com/Hyneman/moby-project/672f6bdca054c42d375f065ffee87e8ceba0c242/moby/mwords/21986na.mes |\ iconv -f cp1252 - > surnames.txt diff --git a/server/src/main.rs b/server/src/main.rs index 75ff12e..6ff4d6b 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -13,6 +13,7 @@ use names::Name; use serde_json::Value; use tokio::sync::{Mutex, RwLock}; use serde::{Serialize, Deserialize}; +use const_format::formatcp; #[derive(Serialize, Deserialize)] enum Direction { @@ -172,5 +173,5 @@ struct TurtleResponse { } async fn client() -> &'static str { - include_str!("../../client/client.lua") + formatcp!("local ipaddr = {}\n{}", env!("GLOBAL_IP"), include_str!("../../client/client.lua")) }