Commit
+229 -0 +/-8 browse
1 | diff --git a/Cargo.lock b/Cargo.lock |
2 | new file mode 100644 |
3 | index 0000000..162e1b5 |
4 | --- /dev/null |
5 | +++ b/Cargo.lock |
6 | @@ -0,0 +1,74 @@ |
7 | + # This file is automatically @generated by Cargo. |
8 | + # It is not intended for manual editing. |
9 | + version = 3 |
10 | + |
11 | + [[package]] |
12 | + name = "maitred" |
13 | + version = "0.1.0" |
14 | + dependencies = [ |
15 | + "smtp-proto", |
16 | + ] |
17 | + |
18 | + [[package]] |
19 | + name = "proc-macro2" |
20 | + version = "1.0.86" |
21 | + source = "registry+https://github.com/rust-lang/crates.io-index" |
22 | + checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" |
23 | + dependencies = [ |
24 | + "unicode-ident", |
25 | + ] |
26 | + |
27 | + [[package]] |
28 | + name = "quote" |
29 | + version = "1.0.36" |
30 | + source = "registry+https://github.com/rust-lang/crates.io-index" |
31 | + checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" |
32 | + dependencies = [ |
33 | + "proc-macro2", |
34 | + ] |
35 | + |
36 | + [[package]] |
37 | + name = "serde" |
38 | + version = "1.0.204" |
39 | + source = "registry+https://github.com/rust-lang/crates.io-index" |
40 | + checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" |
41 | + dependencies = [ |
42 | + "serde_derive", |
43 | + ] |
44 | + |
45 | + [[package]] |
46 | + name = "serde_derive" |
47 | + version = "1.0.204" |
48 | + source = "registry+https://github.com/rust-lang/crates.io-index" |
49 | + checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" |
50 | + dependencies = [ |
51 | + "proc-macro2", |
52 | + "quote", |
53 | + "syn", |
54 | + ] |
55 | + |
56 | + [[package]] |
57 | + name = "smtp-proto" |
58 | + version = "0.1.5" |
59 | + source = "registry+https://github.com/rust-lang/crates.io-index" |
60 | + checksum = "51b8ad3dd187f0d4debab02ad65405a9919d6a4f7bce25bd64a258781063a53a" |
61 | + dependencies = [ |
62 | + "serde", |
63 | + ] |
64 | + |
65 | + [[package]] |
66 | + name = "syn" |
67 | + version = "2.0.72" |
68 | + source = "registry+https://github.com/rust-lang/crates.io-index" |
69 | + checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" |
70 | + dependencies = [ |
71 | + "proc-macro2", |
72 | + "quote", |
73 | + "unicode-ident", |
74 | + ] |
75 | + |
76 | + [[package]] |
77 | + name = "unicode-ident" |
78 | + version = "1.0.12" |
79 | + source = "registry+https://github.com/rust-lang/crates.io-index" |
80 | + checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" |
81 | diff --git a/Cargo.toml b/Cargo.toml |
82 | new file mode 100644 |
83 | index 0000000..44744d4 |
84 | --- /dev/null |
85 | +++ b/Cargo.toml |
86 | @@ -0,0 +1,11 @@ |
87 | + [package] |
88 | + name = "maitred" |
89 | + version = "0.1.0" |
90 | + edition = "2021" |
91 | + |
92 | + [dependencies] |
93 | + smtp-proto = { version = "0.1.5", features = ["serde", "serde_support"] } |
94 | + |
95 | + [[bin]] |
96 | + name = "maitred-debug" |
97 | + path = "cmd/matrid-debug/src/main.rs" |
98 | diff --git a/README.md b/README.md |
99 | new file mode 100644 |
100 | index 0000000..a3a1312 |
101 | --- /dev/null |
102 | +++ b/README.md |
103 | @@ -0,0 +1,4 @@ |
104 | + # maitred |
105 | + |
106 | + Lightweight embeddable SMTP [RFC5321](https://www.rfc-editor.org/rfc/rfc5321.html) |
107 | + server for use in applications that need to receive e-mail. |
108 | diff --git a/cmd/matrid-debug/.gitignore b/cmd/matrid-debug/.gitignore |
109 | new file mode 100644 |
110 | index 0000000..ea8c4bf |
111 | --- /dev/null |
112 | +++ b/cmd/matrid-debug/.gitignore |
113 | @@ -0,0 +1 @@ |
114 | + /target |
115 | diff --git a/cmd/matrid-debug/Cargo.lock b/cmd/matrid-debug/Cargo.lock |
116 | new file mode 100644 |
117 | index 0000000..df8a777 |
118 | --- /dev/null |
119 | +++ b/cmd/matrid-debug/Cargo.lock |
120 | @@ -0,0 +1,81 @@ |
121 | + # This file is automatically @generated by Cargo. |
122 | + # It is not intended for manual editing. |
123 | + version = 3 |
124 | + |
125 | + [[package]] |
126 | + name = "maitred" |
127 | + version = "0.1.0" |
128 | + dependencies = [ |
129 | + "smtp-proto", |
130 | + ] |
131 | + |
132 | + [[package]] |
133 | + name = "matrid-debug" |
134 | + version = "0.1.0" |
135 | + dependencies = [ |
136 | + "maitred", |
137 | + ] |
138 | + |
139 | + [[package]] |
140 | + name = "proc-macro2" |
141 | + version = "1.0.86" |
142 | + source = "registry+https://github.com/rust-lang/crates.io-index" |
143 | + checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" |
144 | + dependencies = [ |
145 | + "unicode-ident", |
146 | + ] |
147 | + |
148 | + [[package]] |
149 | + name = "quote" |
150 | + version = "1.0.36" |
151 | + source = "registry+https://github.com/rust-lang/crates.io-index" |
152 | + checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" |
153 | + dependencies = [ |
154 | + "proc-macro2", |
155 | + ] |
156 | + |
157 | + [[package]] |
158 | + name = "serde" |
159 | + version = "1.0.204" |
160 | + source = "registry+https://github.com/rust-lang/crates.io-index" |
161 | + checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" |
162 | + dependencies = [ |
163 | + "serde_derive", |
164 | + ] |
165 | + |
166 | + [[package]] |
167 | + name = "serde_derive" |
168 | + version = "1.0.204" |
169 | + source = "registry+https://github.com/rust-lang/crates.io-index" |
170 | + checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" |
171 | + dependencies = [ |
172 | + "proc-macro2", |
173 | + "quote", |
174 | + "syn", |
175 | + ] |
176 | + |
177 | + [[package]] |
178 | + name = "smtp-proto" |
179 | + version = "0.1.5" |
180 | + source = "registry+https://github.com/rust-lang/crates.io-index" |
181 | + checksum = "51b8ad3dd187f0d4debab02ad65405a9919d6a4f7bce25bd64a258781063a53a" |
182 | + dependencies = [ |
183 | + "serde", |
184 | + ] |
185 | + |
186 | + [[package]] |
187 | + name = "syn" |
188 | + version = "2.0.72" |
189 | + source = "registry+https://github.com/rust-lang/crates.io-index" |
190 | + checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" |
191 | + dependencies = [ |
192 | + "proc-macro2", |
193 | + "quote", |
194 | + "unicode-ident", |
195 | + ] |
196 | + |
197 | + [[package]] |
198 | + name = "unicode-ident" |
199 | + version = "1.0.12" |
200 | + source = "registry+https://github.com/rust-lang/crates.io-index" |
201 | + checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" |
202 | diff --git a/cmd/matrid-debug/Cargo.toml b/cmd/matrid-debug/Cargo.toml |
203 | new file mode 100644 |
204 | index 0000000..3f093fa |
205 | --- /dev/null |
206 | +++ b/cmd/matrid-debug/Cargo.toml |
207 | @@ -0,0 +1,8 @@ |
208 | + [package] |
209 | + name = "matrid-debug" |
210 | + version = "0.1.0" |
211 | + edition = "2021" |
212 | + |
213 | + [dependencies] |
214 | + |
215 | + maitred = {path = "../../"} |
216 | diff --git a/cmd/matrid-debug/src/main.rs b/cmd/matrid-debug/src/main.rs |
217 | new file mode 100644 |
218 | index 0000000..2ad2084 |
219 | --- /dev/null |
220 | +++ b/cmd/matrid-debug/src/main.rs |
221 | @@ -0,0 +1,5 @@ |
222 | + use maitred::serve; |
223 | + |
224 | + fn main() { |
225 | + serve() |
226 | + } |
227 | diff --git a/src/lib.rs b/src/lib.rs |
228 | new file mode 100644 |
229 | index 0000000..41c3ef1 |
230 | --- /dev/null |
231 | +++ b/src/lib.rs |
232 | @@ -0,0 +1,45 @@ |
233 | + use smtp_proto::{request::receiver::RequestReceiver, Request}; |
234 | + |
235 | + pub fn serve() { |
236 | + let stdin = std::io::stdin(); |
237 | + let mut r = RequestReceiver::default(); |
238 | + let mut requests: Vec<Request<String>> = Vec::new(); |
239 | + let mut is_data_req = false; |
240 | + let mut data: Vec<u8> = Vec::new(); |
241 | + for line in stdin.lines() { |
242 | + if is_data_req { |
243 | + let line = line.unwrap(); |
244 | + data.extend(line.bytes()); |
245 | + if line == "." { |
246 | + break; |
247 | + } |
248 | + continue; |
249 | + } |
250 | + let line = line.unwrap(); |
251 | + let line = line + "\n"; |
252 | + let mut bytes = line.as_bytes().iter(); |
253 | + match r.ingest(&mut bytes, line.as_bytes()) { |
254 | + Ok(request) => { |
255 | + println!("Request: {:?}", request); |
256 | + match request { |
257 | + Request::Data => { |
258 | + println!("Enter .<CR> to end the transaction"); |
259 | + is_data_req = true; |
260 | + continue; |
261 | + } |
262 | + Request::Quit => { |
263 | + println!("quit"); |
264 | + break; |
265 | + } |
266 | + _ => {} |
267 | + } |
268 | + requests.push(request); |
269 | + } |
270 | + Err(err) => { |
271 | + println!("cannot process request: {}", err); |
272 | + break; |
273 | + } |
274 | + } |
275 | + } |
276 | + println!("shutting down"); |
277 | + } |