-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
422 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
layout node | ||
use nix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[package] | ||
name="cheap-ichnaea" | ||
version="0.2.1" | ||
edition="2021" | ||
|
||
[dependencies] | ||
actix-web = "4" | ||
async-std = "1.13.0" | ||
clap = { version = "4.5.18", features = ["derive"] } | ||
env_logger = "0.11.5" | ||
log = "0.4.22" | ||
reqwest = { version = "0.12.7", features = ["blocking"] } | ||
serde = { version = "1.0", features = ["derive"] } | ||
serde_json = "1.0.128" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# What is good for? | ||
|
||
As a geolocation service to feed geloclue2. I only use geoclue2 to update the | ||
timezone information on my device. | ||
With the retirement of the Mozilla Location Service | ||
(https://github.com/mozilla/ichnaea/issues/2065) the only option was to move | ||
to Google Location Service. | ||
|
||
I don't need accurate location data for timezone, the | ||
[ip-api](https://ip-api.com service) service suits well enough. | ||
So I build this local service. | ||
|
||
# How to use it? | ||
Start the service and adjust the `url` in `/etc/geoclue/geoclue.conf` | ||
|
||
``` | ||
url=http://localhost:8080/v1/geolocate | ||
``` | ||
|
||
``` | ||
Usage: cheap-ichnaea [OPTIONS] | ||
Options: | ||
-p, --port <PORT> The port number to listen on [default: 8080] | ||
-t, --ttl-cache <TTL_CACHE> Cache TTL in seconds [default: 1800] | ||
-h, --help Print help | ||
-V, --version Print version | ||
``` | ||
|
||
# Features | ||
|
||
- Caching of responses (`--ttl-cache 3200`) | ||
- Retrying to connect, when connection fails |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
{ lib | ||
, rustPlatform | ||
, openssl | ||
, pkg-config | ||
}: | ||
let | ||
fs = lib.fileset; | ||
# sourceFiles = ./.; | ||
# sourceFiles = fs.gitTracked ./.; | ||
sourceFiles = fs.unions [ | ||
./Cargo.toml | ||
./Cargo.lock | ||
./src/main.rs | ||
# (fs.fileFilter | ||
# (file: file.hasExt "rs") | ||
# ./src | ||
# ) | ||
]; | ||
in | ||
rustPlatform.buildRustPackage { | ||
pname = "cheap-ichnaea"; | ||
version = "0.2.1"; | ||
|
||
src = fs.toSource { | ||
root = ./.; | ||
fileset = sourceFiles; | ||
}; | ||
|
||
# cargoHash = lib.fakeHash; | ||
cargoLock = { | ||
lockFile = ./Cargo.lock; | ||
}; | ||
|
||
nativeBuildInputs = [ | ||
pkg-config | ||
]; | ||
|
||
buildInputs = [ | ||
openssl | ||
]; | ||
|
||
installPhase = '' | ||
runHook preInstall | ||
find . | ||
install -D -t $out/bin target/x86_64-unknown-linux-gnu/release/cheap-ichnaea | ||
runHook postInstall | ||
''; | ||
#doCheck = false; | ||
|
||
meta = with lib; { | ||
description = "Cheap ichnaea service"; | ||
license = licenses.mit; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#with ( import <nixpkgs> {}); | ||
#{ nodeEnv, fetchgit, pkgs ? import <nixpkgs> {} }: | ||
{ pkgs ? import <nixpkgs> {} }: | ||
|
||
pkgs.mkShell { | ||
buildInputs = [ | ||
pkgs.cargo | ||
pkgs.pkg-config | ||
pkgs.openssl | ||
]; | ||
|
||
shellHook = '' | ||
echo "cat countries.json | jq '.[] | {iso2, latitude, longitude}' | jq -c -s . > countries_opt.json" | ||
''; | ||
} |
Oops, something went wrong.