aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2024-07-05 02:57:37 +0200
committermetamuffin <metamuffin@disroot.org>2024-07-05 02:57:37 +0200
commit6de0a5e827b0b18f589c28f489b4ff88169f156c (patch)
treecc6923484b77b5654fe1ca09bf6694fda7a894a2
parent384ddd782b989218ceb55b7147aa8698425d1464 (diff)
downloadsip-rs-6de0a5e827b0b18f589c28f489b4ff88169f156c.tar
sip-rs-6de0a5e827b0b18f589c28f489b4ff88169f156c.tar.bz2
sip-rs-6de0a5e827b0b18f589c28f489b4ff88169f156c.tar.zst
this wont work
-rw-r--r--Cargo.lock14
-rw-r--r--Cargo.toml2
-rw-r--r--src/encoding/headermap.rs2
-rw-r--r--src/encoding/headers.rs31
-rw-r--r--src/encoding/method.rs6
-rw-r--r--src/encoding/request.rs2
-rw-r--r--src/encoding/uri.rs2
7 files changed, 53 insertions, 6 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 68e3129..7d7e46b 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -185,6 +185,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024"
[[package]]
+name = "hex"
+version = "0.4.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
+
+[[package]]
name = "humantime"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -219,6 +225,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24"
[[package]]
+name = "md5"
+version = "0.7.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "490cc448043f947bae3cbee9c203358d62dbee0db12107a74be5c30ccfd09771"
+
+[[package]]
name = "memchr"
version = "2.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -413,7 +425,9 @@ dependencies = [
"anyhow",
"base64",
"env_logger",
+ "hex",
"log",
+ "md5",
"rand",
"tokio",
]
diff --git a/Cargo.toml b/Cargo.toml
index e9dcc23..826367f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -9,6 +9,8 @@ anyhow = "1.0.86"
log = "0.4.22"
rand = "0.9.0-alpha.1"
base64 = "0.22.1"
+md5 = "0.7.0"
+hex = "0.4.3"
[dev-dependencies]
env_logger = "0.11.3"
diff --git a/src/encoding/headermap.rs b/src/encoding/headermap.rs
index 2f9f097..65ef8d2 100644
--- a/src/encoding/headermap.rs
+++ b/src/encoding/headermap.rs
@@ -2,7 +2,7 @@ use super::headers::Header;
use anyhow::Result;
use std::fmt::Display;
-#[derive(Debug)]
+#[derive(Debug, Clone)]
pub struct HeaderMap(pub Vec<(String, String)>);
impl HeaderMap {
diff --git a/src/encoding/headers.rs b/src/encoding/headers.rs
index 6bffc7e..e9196d1 100644
--- a/src/encoding/headers.rs
+++ b/src/encoding/headers.rs
@@ -103,3 +103,34 @@ impl FromStr for WWWAuthenticate {
})
}
}
+
+#[derive(Debug)]
+pub struct Authorization {
+ pub username: String,
+ pub realm: String,
+ pub nonce: String,
+ pub response: String,
+}
+impl Header for Authorization {
+ const NAME: &'static str = "Authorization";
+}
+impl Display for Authorization {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ let Self {
+ username,
+ realm,
+ nonce,
+ response,
+ } = self;
+ write!(
+ f,
+ "Digest username={username:?} realm={realm:?}, nonce={nonce:?}, response={response:?}"
+ )
+ }
+}
+impl FromStr for Authorization {
+ type Err = anyhow::Error;
+ fn from_str(_s: &str) -> Result<Self, Self::Err> {
+ todo!()
+ }
+}
diff --git a/src/encoding/method.rs b/src/encoding/method.rs
index 73829b0..6d38cab 100644
--- a/src/encoding/method.rs
+++ b/src/encoding/method.rs
@@ -6,7 +6,7 @@ pub enum Method {
Register,
Invite,
Ack,
- Option,
+ Options,
Cancel,
Bye,
}
@@ -17,7 +17,7 @@ impl Display for Method {
Method::Register => "REGISTER",
Method::Invite => "INVITE",
Method::Ack => "ACK",
- Method::Option => "OPTION",
+ Method::Options => "OPTIONS",
Method::Cancel => "CANCEL",
Method::Bye => "BYE",
})
@@ -30,7 +30,7 @@ impl FromStr for Method {
"REGISTER" => Method::Register,
"INVITE" => Method::Invite,
"ACK" => Method::Ack,
- "OPTION" => Method::Option,
+ "OPTIONS" => Method::Options,
"CANCEL" => Method::Cancel,
"BYE" => Method::Bye,
_ => bail!("unknown method"),
diff --git a/src/encoding/request.rs b/src/encoding/request.rs
index 124522c..aecd006 100644
--- a/src/encoding/request.rs
+++ b/src/encoding/request.rs
@@ -1,7 +1,7 @@
use super::{headermap::HeaderMap, method::Method, uri::Uri};
use std::fmt::Display;
-#[derive(Debug)]
+#[derive(Debug, Clone)]
pub struct Request {
pub method: Method,
pub uri: Uri,
diff --git a/src/encoding/uri.rs b/src/encoding/uri.rs
index 64572ba..7aeefdb 100644
--- a/src/encoding/uri.rs
+++ b/src/encoding/uri.rs
@@ -1,6 +1,6 @@
use std::fmt::Display;
-#[derive(Debug)]
+#[derive(Debug,Clone)]
pub struct Uri {
pub content: String,
}