Skip to content

Commit

Permalink
g3proxy: fix iploc service integration
Browse files Browse the repository at this point in the history
  • Loading branch information
zh-jq-b committed Jun 19, 2024
1 parent 1823b95 commit cc8e786
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 3 deletions.
4 changes: 4 additions & 0 deletions g3iploc/examples/basic/g3iploc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---

geoip_db:
country: simple.csv
2 changes: 2 additions & 0 deletions g3iploc/examples/basic/simple.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#network,country
1.1.1.0/24,US
2 changes: 1 addition & 1 deletion g3proxy/doc/configuration/escapers/route_geoip.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ geo_rules

Set the GeoIP rules to select next escaper.

Each rule is in *map* format, with two keys:
Each rule is in *map* format, with the following keys:

* next

Expand Down
29 changes: 29 additions & 0 deletions g3proxy/examples/escaper_route_geoip/g3proxy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---

log: journal

server:
- name: server_default
escaper: route_geoip
type: http_proxy
listen:
address: "[::]:10086"

resolver:
- name: default
type: c-ares
server: 127.0.0.1

escaper:
- name: internet
type: direct_fixed
resolver: default
- name: deny
type: dummy_deny
- name: route_geoip
type: route_geoip
resolver: default
geo_rules:
- next: internet
countries: US
default_next: deny
4 changes: 2 additions & 2 deletions g3proxy/src/escape/route_geoip/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,15 +193,15 @@ impl RouteGeoIpEscaper {
}

if let Some(country) = location.country() {
if !self.country_bitset.contains(country as usize) {
if self.country_bitset.contains(country as usize) {
if let Some(escaper) = self.country_table.get(&(country as u16)) {
return Some(Arc::clone(escaper));
}
}
}

if let Some(continent) = location.continent() {
if !self.continent_bitset.contains(continent as usize) {
if self.continent_bitset.contains(continent as usize) {
if let Some(escaper) = self.continent_table.get(&(continent as u8)) {
return Some(Arc::clone(escaper));
}
Expand Down

0 comments on commit cc8e786

Please sign in to comment.