9 files changed
+42
-42
Cargo.lock
+5
-5
@@ -1209,7 +1209,7 @@ checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0"
1209
1210
[[package]]
1211
name = "smbpndk-cli"
1212
-version = "0.3.5"
1212
+version = "0.3.6"
1213
dependencies = [
1214
"anyhow",
1215
"clap",
@@ -1239,7 +1239,7 @@ dependencies = [
1239
1240
[[package]]
1241
name = "smbpndk-model"
1242
-version = "0.3.5"
1242
+version = "0.3.6"
1243
dependencies = [
1244
"chrono",
1245
"serde",
@@ -1249,7 +1249,7 @@ dependencies = [
1249
1250
[[package]]
1251
name = "smbpndk-networking"
1252
-version = "0.3.5"
1252
+version = "0.3.6"
1253
dependencies = [
1254
"anyhow",
1255
"async-trait",
@@ -1267,7 +1267,7 @@ dependencies = [
1267
1268
[[package]]
1269
name = "smbpndk-networking-project"
1270
-version = "0.3.5"
1270
+version = "0.3.6"
1271
dependencies = [
1272
"anyhow",
1273
"async-trait",
@@ -1285,7 +1285,7 @@ dependencies = [
1285
1286
[[package]]
1287
name = "smbpndk-utils"
1288
-version = "0.3.5"
1288
+version = "0.3.6"
1289
dependencies = [
1290
"anyhow",
1291
"dirs",
smbpndk-cli/Cargo.toml
+1
-1
@@ -1,6 +1,6 @@
1
[package]
2
name = "smbpndk-cli"
3
-version = "0.3.5"
3
+version = "0.3.6"
4
edition = "2021"
5
authors = ["Seto Elkahfi <hej@setoelkahfi.se>"]
6
description = "Command line tool for creating and managing SmbPndk resources."
smbpndk-cli/src/account/404.html
deleted
-14
@@ -1,14 +0,0 @@
1
-<!DOCTYPE html>
2
-<html lang="en">
3
-
4
-<head>
5
- <meta charset="utf-8">
6
- <title>404 Not found</title>
7
-</head>
8
-
9
-<body>
10
- <h1>Oops!</h1>
11
- <p>Sorry, I don't know what you're asking for.</p>
12
-</body>
13
-
14
-</html>
\ No newline at end of file
smbpndk-cli/src/account/hello.html
deleted
-11
@@ -1,11 +0,0 @@
1
-<!DOCTYPE html>
2
-
3
-<head>
4
- <meta charset="utf-8">
5
- <title>Hello!</title>
6
-</head>
7
-
8
-<body>
9
- <h1>Authenticated!</h1>
10
- <p>Back to the terminal console to finish your registration.</p>
11
-</body>
\ No newline at end of file
smbpndk-cli/src/account/lib.rs
+32
-7
@@ -13,7 +13,7 @@ use smbpndk_networking::{
13
use spinners::Spinner;
14
use std::{
15
fmt::{Display, Formatter},
16
- fs::{self, create_dir_all, OpenOptions},
16
+ fs::{create_dir_all, OpenOptions},
17
io::{BufRead, BufReader, Write},
18
net::{TcpListener, TcpStream},
19
sync::mpsc::{self, Receiver, Sender},
@@ -123,7 +123,7 @@ fn handle_connection(mut stream: TcpStream, tx: Sender<String>) {
123
124
let code_regex = Regex::new(r"code=([^&]*)").unwrap();
125
126
- let (status_line, filename) = match code_regex.captures(request_line) {
126
+ let (status_line, contents) = match code_regex.captures(request_line) {
127
Some(group) => {
128
let code = group.get(1).unwrap().as_str();
129
debug!("Code: {:#?}", code);
@@ -137,20 +137,45 @@ fn handle_connection(mut stream: TcpStream, tx: Sender<String>) {
137
debug!("Failed to send code to channel: {e}");
138
}
139
}
140
- ("HTTP/1.1 200 OK", "./smbpndk-cli/src/account/hello.html")
140
+ (
141
+ "HTTP/1.1 200 OK",
142
+ "<!DOCTYPE html>
143
+
144
+ <head>
145
+ <meta charset='utf-8'>
146
+ <title>Hello!</title>
147
+ </head>
148
+
149
+ <body>
150
+ <h1>Authenticated!</h1>
151
+ <p>Back to the terminal console to finish your registration.</p>
152
+ </body>",
153
+ )
154
}
155
None => {
156
debug!("Code not found.");
157
(
158
"HTTP/1.1 404 NOT FOUND",
146
- "./smbpndk-cli/src/account/404.html",
159
+ "<!DOCTYPE html>
160
+ <html lang='en'>
161
+
162
+ <head>
163
+ <meta charset='utf-8'>
164
+ <title>404 Not found</title>
165
+ </head>
166
+
167
+ <body>
168
+ <h1>Oops!</h1>
169
+ <p>Sorry, I don't know what you're asking for.</p>
170
+ </body>
171
+
172
+ </html>",
173
)
174
}
175
};
176
151
- let contents = fs::read_to_string(filename).unwrap();
152
- let length = contents.len();
153
- let response = format!("{status_line}\r\nContent-Length: {length}\r\n\r\n{contents}");
177
+ debug!("Contents: {:#?}", &contents);
178
+ let response = format!("{status_line}\r\n\r\n{contents}");
179
stream.write_all(response.as_bytes()).unwrap();
180
stream.flush().unwrap();
181
}
smbpndk-model/Cargo.toml
+1
-1
@@ -1,6 +1,6 @@
1
[package]
2
name = "smbpndk-model"
3
-version = "0.3.5"
3
+version = "0.3.6"
4
edition = "2021"
5
authors = ["Seto Elkahfi <hej@setoelkahfi.se>"]
6
description = "Command line tool for creating and managing SmbPndk resources."
smbpndk-networking-project/Cargo.toml
+1
-1
@@ -1,6 +1,6 @@
1
[package]
2
name = "smbpndk-networking-project"
3
-version = "0.3.5"
3
+version = "0.3.6"
4
edition = "2021"
5
authors = ["Seto Elkahfi <hej@setoelkahfi.se>"]
6
description = "Command line tool for creating and managing SmbPndk resources."
smbpndk-networking/Cargo.toml
+1
-1
@@ -1,6 +1,6 @@
1
[package]
2
name = "smbpndk-networking"
3
-version = "0.3.5"
3
+version = "0.3.6"
4
edition = "2021"
5
readme = "README.md"
6
authors = ["Seto Elkahfi <hej@setoelkahfi.se>"]
smbpndk-utils/Cargo.toml
+1
-1
@@ -1,6 +1,6 @@
1
[package]
2
name = "smbpndk-utils"
3
-version = "0.3.5"
3
+version = "0.3.6"
4
edition = "2021"
5
authors = ["Seto Elkahfi <hej@setoelkahfi.se>"]
6
description = "Command line tool for creating and managing SmbPndk resources."