Skip to content

Commit

Permalink
fix geoip
Browse files Browse the repository at this point in the history
  • Loading branch information
blind-oracle committed Jul 3, 2024
1 parent cbef16e commit cf0436d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ env:

jobs:
test:
runs-on: bazel-runner-small
runs-on: dind-small
container:
image: ghcr.io/catthehacker/ubuntu:full-22.04
image: ghcr.io/catthehacker/ubuntu:rust-22.04

steps:
- uses: actions/checkout@v4

- uses: Swatinem/rust-cache@v2

- name: Install protoc
run: sudo apt-get update && sudo apt-get install protobuf-compiler
run: sudo apt-get update && sudo apt-get -y install protobuf-compiler

- name: Run tests
run: cargo test
1 change: 0 additions & 1 deletion src/policy/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
pub mod denylist;
pub mod domain_canister;
mod test;

use std::{fs, path::PathBuf};

Expand Down
Empty file removed src/policy/test.rs
Empty file.
12 changes: 10 additions & 2 deletions src/routing/middleware/geoip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,16 @@ pub async fn middleware(
) -> Response {
// Lookup code
let country_code = geoip.lookup(conn_info.remote_addr.ip());
request.extensions_mut().insert(country_code.clone());

if let Some(v) = &country_code {
request.extensions_mut().insert(v.clone());
}

let mut response = next.run(request).await;
response.extensions_mut().insert(country_code);

if let Some(v) = country_code {
response.extensions_mut().insert(v);
}

response
}

0 comments on commit cf0436d

Please sign in to comment.