summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorSoniEx2 <endermoneymod@gmail.com>2021-06-13 13:43:43 -0300
committerSoniEx2 <endermoneymod@gmail.com>2021-06-13 13:43:43 -0300
commit7de445737af96368dc453e8d8c04d1063982b3fd (patch)
tree9095d5589f36d21fd7214e7a7c6216e43293ca7f
parentd976180a1b00dbf6b03fc00ea54a017041ca591e (diff)
Expose the IP as a pub const HEAD default
-rw-r--r--Cargo.toml2
-rw-r--r--src/bin/testserver-demo.rs13
-rw-r--r--src/lib.rs5
3 files changed, 14 insertions, 6 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 6291df5..6293a3a 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
 [package]
 name = "testserver"
-version = "0.1.2"
+version = "0.1.3"
 description = "Static HTTP webserver that stores resources as strings"
 readme = "README.md"
 authors = ["SoniEx2 <endermoneymod@gmail.com>"]
diff --git a/src/bin/testserver-demo.rs b/src/bin/testserver-demo.rs
index 447607f..447c76f 100644
--- a/src/bin/testserver-demo.rs
+++ b/src/bin/testserver-demo.rs
@@ -29,11 +29,14 @@ page.xhtml.t/   0           0     0     644     724       `
 	<body>
 		<main>
 			<h1>Testserver Demo</h1>
-			<p>Simple demo of the testserver. Check the source file for details.</p>
+			<p>Simple demo of the testserver. Check the source file for
+details.</p>
 		</main>
 		<footer>
 			<hr />
-			<p>The contents of this webpage are licensed under a <a rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/">Creative Commons Attribution-ShareAlike 4.0 International License</a>.</p>
+			<p>The contents of this webpage are licensed under a <a
+rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/">Creative
+Commons Attribution-ShareAlike 4.0 International License</a>.</p>
 		</footer>
 	</body>
 </html>
@@ -44,9 +47,11 @@ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQAAAAA3iMLMAAAAH0lEQVR4nGP4/59hbyPD3L1QtBaG
 tsLQThgCKvv/HwAu9hd9OeN5mQAAAABJRU5ErkJggg==
 "###;
 
+use testserver::{IP, serve};
+
 fn main() {
-    let server = testserver::serve(DEMO);
-    println!("Listening on http://127.74.137.226:{}/page.xhtml", server.port());
+    let server = serve(DEMO);
+    println!("Listening on http://{}:{}/page.xhtml", IP, server.port());
     println!("Type anything to exit.");
     let _ = std::io::stdin().read_line(&mut String::new());
     drop(server);
diff --git a/src/lib.rs b/src/lib.rs
index b40abad..052905f 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -55,6 +55,9 @@ impl Server {
     }
 }
 
+/// The IP address of the server. `"127.74.137.226"`.
+pub const IP: &'static str = "127.74.137.226";
+
 /// Decodes base64 as output by the `base64` utility. Properly handles
 /// 76-column base64.
 fn decode_base64(s: &'static str) -> Result<Vec<u8>, base64::DecodeError> {
@@ -79,7 +82,7 @@ fn decode_base64(s: &'static str) -> Result<Vec<u8>, base64::DecodeError> {
 pub fn serve(archive: &'static str) -> Server {
     // TODO cache!
     // "Soni" base64-decodes to 0x4a 0x89 0xe2
-    let server = Arc::new(Httpd::http("127.74.137.226:0").unwrap());
+    let server = Arc::new(Httpd::http((IP, 0u16)).unwrap());
     let sv = server.clone();
     std::thread::spawn(move || {
         let archive = Cursor::new(archive);