Make navigator.geolocation coordinates configurable (#272)
The geolocation shim returned a fixed Frankfurt position. With the timezone now configurable, a deployment in another region would report a location that does not match its exit IP or timezone, the mismatch issue #228 describes. Set OBSCURA_GEOLOCATION="lat,lon" to override the reported coordinates; the value is range-checked and falls back to the Frankfurt default when unset or malformed. The existing positional jitter is preserved.
This commit is contained in:
1 parent
a23dad7cd9
commit
82b7a0baa8
3 files changed
+37
-4
No files matched your search
@@ -219,6 +219,20 @@ impl ObscuraJsRuntime {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Override the coordinates the navigator.geolocation shim reports. The
|
||||
/// values are injected as numeric globals the bootstrap reads; when unset it
|
||||
/// keeps the built-in default. Callers validate the range before calling.
|
||||
pub fn set_geolocation(&mut self, latitude: f64, longitude: f64) {
|
||||
let _ = self.runtime.execute_script(
|
||||
"<set-geo>",
|
||||
format!(
|
||||
"globalThis.__obscura_geo_lat={};globalThis.__obscura_geo_lon={};",
|
||||
latitude, longitude
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
pub fn evaluate(&mut self, expression: &str) -> Result<serde_json::Value, String> {
|
||||
let wrapped = Self::wrap_expression(expression);
|
||||
let result = self
|
||||
|
||||
Reference in new issue
Block a user