Skip to content

Commit

Permalink
feat: rename host to domain
Browse files Browse the repository at this point in the history
  • Loading branch information
thewh1teagle committed Oct 4, 2023
1 parent 8e4a4b3 commit b5a8f1a
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion bindings/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ Bindings for [rookie](https://github.com/thewh1teagle/rookie)
from rookiepy import chrome
cookies = chrome()
for cookie in cookies:
print(cookie.host, cookie.name, cookie.value)
print(cookie.domain, cookie.name, cookie.value)
```
4 changes: 2 additions & 2 deletions bindings/python/rookiepy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def create_cookie(host, path, secure, expires, name, value, http_only):
def to_dict(cookies: List[Any]):
return [
{'name': c.name,
'host': c.host,
'domain': c.domain,
'path': c.path,
'secure': c.secure,
'expires': c.expires,
Expand All @@ -72,7 +72,7 @@ def to_cookiejar(cookies: List[Any]):

for cookie_obj in cookies:
c = create_cookie(
cookie_obj.host,
cookie_obj.domain,
cookie_obj.path,
cookie_obj.secure,
cookie_obj.expires,
Expand Down
4 changes: 2 additions & 2 deletions bindings/python/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ pub struct PyCookie {
#[pymethods]
impl PyCookie {
#[getter]
fn host(&self) -> &str {
&self.inner.host
fn domain(&self) -> &str {
&self.inner.domain
}

#[getter]
Expand Down
2 changes: 1 addition & 1 deletion examples/all_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

cookies = load()
for cookie in cookies:
print(f'host: {cookie.host} name: {cookie.name}, value: {cookie.value}')
print(f'domain: {cookie.domain} name: {cookie.name}, value: {cookie.value}')
2 changes: 1 addition & 1 deletion rookie-rs/src/chromium.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ fn query_cookies(v10_key: Vec<u8>, db_path: PathBuf, domains: Option<Vec<&str>>)

let same_site: i64 = row.get(8)?;
let cookie = Cookie {
host: host_key.to_string(),
domain: host_key.to_string(),
path: path.to_string(),
secure: is_secure,
expires,
Expand Down
6 changes: 3 additions & 3 deletions rookie-rs/src/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::{fmt::{self}, time::SystemTime};

#[derive(Debug)]
pub struct Cookie {
pub host: String,
pub domain: String,
pub path: String,
pub secure: bool,
pub expires: SystemTime,
Expand All @@ -17,15 +17,15 @@ impl fmt::Display for Cookie {
write!(
f,
"Cookie:\n\
- Host: {}\n\
- Domain: {}\n\
- Path: {}\n\
- Secure: {}\n\
- Expires: {:?}\n\
- Name: {}\n\
- Value: {}\n\
- Http Only: {}\n\
- Same Site: {}",
self.host, self.path, self.secure, self.expires, self.name, self.value, self.http_only, self.same_site
self.domain, self.path, self.secure, self.expires, self.name, self.value, self.http_only, self.same_site
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion rookie-rs/src/internet_explorer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub fn internet_explorer_based(db_path: PathBuf, domains: Option<Vec<&str>>) ->

let should_append = domains.is_none() || domains.iter().any(|d| d.contains(&host));
if should_append {
cookies.push(Cookie { host: host.to_string(), path: path.to_string(), secure, expires: epoch_to_systemtime_micros(expires), name, value, http_only, same_site })
cookies.push(Cookie { domain: host.to_string(), path: path.to_string(), secure, expires: epoch_to_systemtime_micros(expires), name, value, http_only, same_site })
}

}
Expand Down
2 changes: 1 addition & 1 deletion rookie-rs/src/mozilla.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub fn firefox_based(db_path: PathBuf, domains: Option<Vec<&str>>) -> Result<Vec

let same_site: i64 = row.get(7)?;
let cookie = Cookie {
host: host.to_string(),
domain: host.to_string(),
path: path.to_string(),
secure: is_secure,
expires,
Expand Down
4 changes: 2 additions & 2 deletions rookie-rs/src/safari.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ fn parse_cookie<T: ByteOrder>(bs: &[u8]) -> io::Result<Cookie> {
// Non-efficient workaround for println! broken pipes with | head.
let cookie = Cookie {
expires: unix_timestamp_to_system_time(expiry as i64),
host: url,
domain: url,
http_only: is_http_only,
name,
path,
Expand Down Expand Up @@ -187,7 +187,7 @@ pub fn safari_based(
domain_filters.iter().any(|&domain| {
// Implement your domain matching logic here
// For example, you can use the `.ends_with` method to check if the cookie's domain ends with the specified domain.
cookie.host.ends_with(domain)
cookie.domain.ends_with(domain)
})
})
.collect();
Expand Down

0 comments on commit b5a8f1a

Please sign in to comment.