diff options
author | Shav Kinderlehrer <[email protected]> | 2024-04-07 14:44:03 -0400 |
---|---|---|
committer | Shav Kinderlehrer <[email protected]> | 2024-04-07 14:44:03 -0400 |
commit | 1075ab0ed187a10f2eb3faf1247da8661531bbdb (patch) | |
tree | f600db86af21a63da67114a30c9825fd0ea75971 /src/main.rs | |
parent | a29d68aed7a1fbfbeb3d60df55f28fdee9fb9ca1 (diff) | |
download | chela-1075ab0ed187a10f2eb3faf1247da8661531bbdb.tar.gz chela-1075ab0ed187a10f2eb3faf1247da8661531bbdb.zip |
Add proxy support
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs index ac16eb4..ccad3e8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -23,6 +23,7 @@ pub struct ServerState { pub host: String, pub sqids: Sqids, pub main_page_redirect: Option<Url>, + pub behind_proxy: bool, } #[derive(Debug, Clone, sqlx::FromRow, PartialEq, Eq)] @@ -53,11 +54,13 @@ async fn main() -> eyre::Result<()> { .blocklist(["create".to_string()].into()) .build()?; let main_page_redirect = std::env::var("CHELA_MAIN_PAGE_REDIRECT").unwrap_or_default(); + let behind_proxy = std::env::var("CHELA_BEHIND_PROXY").is_ok(); let server_state = ServerState { db_pool, host, sqids, main_page_redirect: Url::parse(&main_page_redirect).ok(), + behind_proxy, }; let address = std::env::var("CHELA_LISTEN_ADDRESS").unwrap_or("0.0.0.0".to_string()); @@ -108,7 +111,7 @@ CREATE TABLE IF NOT EXISTS chela.urls ( CREATE TABLE IF NOT EXISTS chela.tracking ( timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP, id TEXT NOT NULL, - ip TEXT NOT NULL, + ip TEXT, referrer TEXT, user_agent TEXT ) |