- Use BeaconDB as a drop-in replacement for defunct MLS WiFi
geolocation, and contribute to coverage (<https://codeberg.org/beacondb/beacondb/issues/5#issuecomment-2504311>) - Add 0001-ichnaea-include-ssid.patch: * MLS/Ichnaea: Include SSID for geolocate and submission requests - Add 0002-ichnaea-replace-user-agent.patch: * MLS/Ichnaea: Replace rather than append User-Agent - Add 0003-user-agent-os-info.patch: * Set User-Agent on Soup Session Construction * Add OS Info to user-agent OBS-URL: https://build.opensuse.org/package/show/Application:Geo/geoclue2?expand=0&rev=107
This commit is contained in:
parent
cc9eb048a9
commit
5baad8fc40
50
0001-ichnaea-include-ssid.patch
Normal file
50
0001-ichnaea-include-ssid.patch
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
From: Chris Talbot <chris@talbothome.com>
|
||||||
|
Date: Sun, 1 Dec 2024 21:33:38 -0700
|
||||||
|
Subject: Mozilla: Include SSID for geolocate and submission requests
|
||||||
|
|
||||||
|
---
|
||||||
|
src/gclue-mozilla.c | 10 ++++++++++
|
||||||
|
1 file changed, 10 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/src/gclue-mozilla.c b/src/gclue-mozilla.c
|
||||||
|
index 9e8feb1..abb2280 100644
|
||||||
|
--- a/src/gclue-mozilla.c
|
||||||
|
+++ b/src/gclue-mozilla.c
|
||||||
|
@@ -257,6 +257,7 @@ gclue_mozilla_create_query (GClueMozilla *mozilla,
|
||||||
|
for (iter = bss_list; iter != NULL; iter = iter->next) {
|
||||||
|
WPABSS *bss = WPA_BSS (iter->data);
|
||||||
|
char mac[BSSID_STR_LEN + 1] = { 0 };
|
||||||
|
+ char ssid[MAX_SSID_LEN + 1] = { 0 };
|
||||||
|
gint16 strength_dbm;
|
||||||
|
guint age_ms;
|
||||||
|
|
||||||
|
@@ -269,6 +270,10 @@ gclue_mozilla_create_query (GClueMozilla *mozilla,
|
||||||
|
get_bssid_from_bss (bss, mac);
|
||||||
|
json_builder_add_string_value (builder, mac);
|
||||||
|
|
||||||
|
+ json_builder_set_member_name (builder, "ssid");
|
||||||
|
+ get_ssid_from_bss (bss, ssid);
|
||||||
|
+ json_builder_add_string_value (builder, ssid);
|
||||||
|
+
|
||||||
|
json_builder_set_member_name (builder, "signalStrength");
|
||||||
|
strength_dbm = wpa_bss_get_signal (bss);
|
||||||
|
json_builder_add_int_value (builder, strength_dbm);
|
||||||
|
@@ -486,6 +491,7 @@ gclue_mozilla_create_submit_query (GClueMozilla *mozilla,
|
||||||
|
for (iter = bss_list; iter != NULL; iter = iter->next) {
|
||||||
|
WPABSS *bss = WPA_BSS (iter->data);
|
||||||
|
char mac[BSSID_STR_LEN + 1] = { 0 };
|
||||||
|
+ char ssid[MAX_SSID_LEN + 1] = { 0 };
|
||||||
|
gint16 strength_dbm;
|
||||||
|
guint16 frequency;
|
||||||
|
guint age_ms;
|
||||||
|
@@ -499,6 +505,10 @@ gclue_mozilla_create_submit_query (GClueMozilla *mozilla,
|
||||||
|
get_bssid_from_bss (bss, mac);
|
||||||
|
json_builder_add_string_value (builder, mac);
|
||||||
|
|
||||||
|
+ json_builder_set_member_name (builder, "ssid");
|
||||||
|
+ get_ssid_from_bss (bss, ssid);
|
||||||
|
+ json_builder_add_string_value (builder, ssid);
|
||||||
|
+
|
||||||
|
json_builder_set_member_name (builder, "signalStrength");
|
||||||
|
strength_dbm = wpa_bss_get_signal (bss);
|
||||||
|
json_builder_add_int_value (builder, strength_dbm);
|
31
0002-ichnaea-replace-user-agent.patch
Normal file
31
0002-ichnaea-replace-user-agent.patch
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
From: Chris Talbot <chris@talbothome.com>
|
||||||
|
Date: Sun, 1 Dec 2024 21:34:44 -0700
|
||||||
|
Subject: Mozilla: replace rather than append User-Agent
|
||||||
|
|
||||||
|
It won't actually attach if you don't do this
|
||||||
|
---
|
||||||
|
src/gclue-mozilla.c | 4 ++--
|
||||||
|
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/gclue-mozilla.c b/src/gclue-mozilla.c
|
||||||
|
index abb2280..2b3467d 100644
|
||||||
|
--- a/src/gclue-mozilla.c
|
||||||
|
+++ b/src/gclue-mozilla.c
|
||||||
|
@@ -301,7 +301,7 @@ gclue_mozilla_create_query (GClueMozilla *mozilla,
|
||||||
|
uri = gclue_mozilla_get_locate_url (mozilla);
|
||||||
|
ret = soup_message_new ("POST", uri);
|
||||||
|
request_headers = soup_message_get_request_headers (ret);
|
||||||
|
- soup_message_headers_append (request_headers, "User-Agent", USER_AGENT);
|
||||||
|
+ soup_message_headers_replace (request_headers, "User-Agent", USER_AGENT);
|
||||||
|
body = g_bytes_new_take (data, data_len);
|
||||||
|
soup_message_set_request_body_from_bytes (ret, "application/json", body);
|
||||||
|
g_debug ("Sending following request to '%s':\n%s", uri, data);
|
||||||
|
@@ -566,7 +566,7 @@ gclue_mozilla_create_submit_query (GClueMozilla *mozilla,
|
||||||
|
|
||||||
|
ret = soup_message_new ("POST", url);
|
||||||
|
request_headers = soup_message_get_request_headers (ret);
|
||||||
|
- soup_message_headers_append (request_headers, "User-Agent", USER_AGENT);
|
||||||
|
+ soup_message_headers_replace (request_headers, "User-Agent", USER_AGENT);
|
||||||
|
if (nick != NULL && nick[0] != '\0')
|
||||||
|
soup_message_headers_append (request_headers,
|
||||||
|
"X-Nickname",
|
110
0003-user-agent-os-info.patch
Normal file
110
0003-user-agent-os-info.patch
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
From 32101976945e51536aff3b6945c12ec4d15dd203 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Chris Talbot <chris@talbothome.com>
|
||||||
|
Date: Thu, 5 Dec 2024 06:58:48 -0700
|
||||||
|
Subject: [PATCH] Web-Source: Set User-Agent on Soup Session Construction
|
||||||
|
|
||||||
|
Also add OS Info to user-agent
|
||||||
|
---
|
||||||
|
src/gclue-mozilla.c | 6 ------
|
||||||
|
src/gclue-web-source.c | 30 ++++++++++++++++++++++++++++++
|
||||||
|
2 files changed, 30 insertions(+), 6 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/gclue-mozilla.c b/src/gclue-mozilla.c
|
||||||
|
index 2b3467d4..5680e451 100644
|
||||||
|
--- a/src/gclue-mozilla.c
|
||||||
|
+++ b/src/gclue-mozilla.c
|
||||||
|
@@ -174,8 +174,6 @@ towertec_to_radiotype (GClueTowerTec tec,
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
-#define USER_AGENT (PACKAGE_NAME "/" PACKAGE_VERSION)
|
||||||
|
-
|
||||||
|
SoupMessage *
|
||||||
|
gclue_mozilla_create_query (GClueMozilla *mozilla,
|
||||||
|
gboolean skip_tower,
|
||||||
|
@@ -185,7 +183,6 @@ gclue_mozilla_create_query (GClueMozilla *mozilla,
|
||||||
|
{
|
||||||
|
gboolean has_tower = FALSE, has_bss = FALSE;
|
||||||
|
SoupMessage *ret = NULL;
|
||||||
|
- SoupMessageHeaders *request_headers;
|
||||||
|
JsonBuilder *builder;
|
||||||
|
g_autoptr(GList) bss_list = NULL;
|
||||||
|
JsonGenerator *generator;
|
||||||
|
@@ -300,8 +297,6 @@ gclue_mozilla_create_query (GClueMozilla *mozilla,
|
||||||
|
|
||||||
|
uri = gclue_mozilla_get_locate_url (mozilla);
|
||||||
|
ret = soup_message_new ("POST", uri);
|
||||||
|
- request_headers = soup_message_get_request_headers (ret);
|
||||||
|
- soup_message_headers_replace (request_headers, "User-Agent", USER_AGENT);
|
||||||
|
body = g_bytes_new_take (data, data_len);
|
||||||
|
soup_message_set_request_body_from_bytes (ret, "application/json", body);
|
||||||
|
g_debug ("Sending following request to '%s':\n%s", uri, data);
|
||||||
|
@@ -566,7 +561,6 @@ gclue_mozilla_create_submit_query (GClueMozilla *mozilla,
|
||||||
|
|
||||||
|
ret = soup_message_new ("POST", url);
|
||||||
|
request_headers = soup_message_get_request_headers (ret);
|
||||||
|
- soup_message_headers_replace (request_headers, "User-Agent", USER_AGENT);
|
||||||
|
if (nick != NULL && nick[0] != '\0')
|
||||||
|
soup_message_headers_append (request_headers,
|
||||||
|
"X-Nickname",
|
||||||
|
diff --git a/src/gclue-web-source.c b/src/gclue-web-source.c
|
||||||
|
index 92d94b88..56d511bd 100644
|
||||||
|
--- a/src/gclue-web-source.c
|
||||||
|
+++ b/src/gclue-web-source.c
|
||||||
|
@@ -28,6 +28,7 @@
|
||||||
|
#include "gclue-error.h"
|
||||||
|
#include "gclue-location.h"
|
||||||
|
#include "gclue-mozilla.h"
|
||||||
|
+#include "config.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SECTION:gclue-web-source
|
||||||
|
@@ -402,16 +403,45 @@ gclue_web_source_finalize (GObject *gsource)
|
||||||
|
G_OBJECT_CLASS (gclue_web_source_parent_class)->finalize (gsource);
|
||||||
|
}
|
||||||
|
|
||||||
|
+static char *
|
||||||
|
+get_os_info (void)
|
||||||
|
+{
|
||||||
|
+ g_autofree char *pretty_name = NULL;
|
||||||
|
+ g_autofree char *os_name = g_get_os_info (G_OS_INFO_KEY_NAME);
|
||||||
|
+ g_autofree char *os_version = g_get_os_info (G_OS_INFO_KEY_VERSION);
|
||||||
|
+
|
||||||
|
+ if (os_name && os_version)
|
||||||
|
+ return g_strdup_printf ("%s; %s", os_name, os_version);
|
||||||
|
+
|
||||||
|
+ pretty_name = g_get_os_info (G_OS_INFO_KEY_PRETTY_NAME);
|
||||||
|
+ if (pretty_name)
|
||||||
|
+ return g_steal_pointer (&pretty_name);
|
||||||
|
+
|
||||||
|
+ /* Translators: Not marked as translatable as debug output should stay English */
|
||||||
|
+ return g_strdup ("Unknown");
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+#define USER_AGENT (PACKAGE_NAME "/" PACKAGE_VERSION)
|
||||||
|
+
|
||||||
|
+static char *
|
||||||
|
+get_user_agent (void)
|
||||||
|
+{
|
||||||
|
+ g_autofree char *os_info = get_os_info ();
|
||||||
|
+ return g_strdup_printf ("%s (%s)", USER_AGENT, os_info);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
static void
|
||||||
|
gclue_web_source_constructed (GObject *object)
|
||||||
|
{
|
||||||
|
GNetworkMonitor *monitor;
|
||||||
|
GClueWebSourcePrivate *priv = GCLUE_WEB_SOURCE (object)->priv;
|
||||||
|
+ g_autofree char *user_agent = get_user_agent ();
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (gclue_web_source_parent_class)->constructed (object);
|
||||||
|
|
||||||
|
priv->soup_session = soup_session_new ();
|
||||||
|
soup_session_set_proxy_resolver (priv->soup_session, NULL);
|
||||||
|
+ soup_session_set_user_agent (priv->soup_session, user_agent);
|
||||||
|
|
||||||
|
monitor = g_network_monitor_get_default ();
|
||||||
|
priv->network_changed_id =
|
||||||
|
--
|
||||||
|
GitLab
|
||||||
|
|
@ -1,3 +1,17 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Sat Dec 21 16:11:01 UTC 2024 - Enrico Belleri <kilgore.trout@idesmi.eu>
|
||||||
|
|
||||||
|
- Use BeaconDB as a drop-in replacement for defunct MLS WiFi
|
||||||
|
geolocation, and contribute to coverage
|
||||||
|
(<https://codeberg.org/beacondb/beacondb/issues/5#issuecomment-2504311>)
|
||||||
|
- Add 0001-ichnaea-include-ssid.patch:
|
||||||
|
* MLS/Ichnaea: Include SSID for geolocate and submission requests
|
||||||
|
- Add 0002-ichnaea-replace-user-agent.patch:
|
||||||
|
* MLS/Ichnaea: Replace rather than append User-Agent
|
||||||
|
- Add 0003-user-agent-os-info.patch:
|
||||||
|
* Set User-Agent on Soup Session Construction
|
||||||
|
* Add OS Info to user-agent
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Fri Dec 13 06:34:35 UTC 2024 - ming li <mli@suse.com>
|
Fri Dec 13 06:34:35 UTC 2024 - ming li <mli@suse.com>
|
||||||
|
|
||||||
|
@ -29,8 +29,13 @@ Source0: %{url}/-/archive/%{version}/geoclue-%{version}.tar.bz2
|
|||||||
Source1: srvGeoClue.conf
|
Source1: srvGeoClue.conf
|
||||||
Source99: geoclue2-rpmlintrc
|
Source99: geoclue2-rpmlintrc
|
||||||
|
|
||||||
|
# Compliance with BeaconDB
|
||||||
|
Patch0: 0001-ichnaea-include-ssid.patch
|
||||||
|
Patch1: 0002-ichnaea-replace-user-agent.patch
|
||||||
|
Patch2: 0003-user-agent-os-info.patch
|
||||||
|
|
||||||
BuildRequires: intltool >= 0.40.0
|
BuildRequires: intltool >= 0.40.0
|
||||||
BuildRequires: meson >= 0.47.2
|
BuildRequires: meson >= 0.60.0
|
||||||
BuildRequires: pkgconfig
|
BuildRequires: pkgconfig
|
||||||
BuildRequires: systemd-rpm-macros
|
BuildRequires: systemd-rpm-macros
|
||||||
BuildRequires: sysuser-tools
|
BuildRequires: sysuser-tools
|
||||||
@ -38,8 +43,8 @@ BuildRequires: vala
|
|||||||
BuildRequires: perl(XML::Parser)
|
BuildRequires: perl(XML::Parser)
|
||||||
BuildRequires: pkgconfig(avahi-client) >= 0.6.10
|
BuildRequires: pkgconfig(avahi-client) >= 0.6.10
|
||||||
BuildRequires: pkgconfig(avahi-glib) >= 0.6.10
|
BuildRequires: pkgconfig(avahi-glib) >= 0.6.10
|
||||||
BuildRequires: pkgconfig(gio-2.0) >= 2.68.0
|
BuildRequires: pkgconfig(gio-2.0) >= 2.74.0
|
||||||
BuildRequires: pkgconfig(gio-unix-2.0) >= 2.68.0
|
BuildRequires: pkgconfig(gio-unix-2.0) >= 2.74.0
|
||||||
BuildRequires: pkgconfig(glib-2.0) >= 2.74.0
|
BuildRequires: pkgconfig(glib-2.0) >= 2.74.0
|
||||||
BuildRequires: pkgconfig(gobject-introspection-1.0)
|
BuildRequires: pkgconfig(gobject-introspection-1.0)
|
||||||
BuildRequires: pkgconfig(json-glib-1.0) >= 0.14
|
BuildRequires: pkgconfig(json-glib-1.0) >= 0.14
|
||||||
@ -95,6 +100,8 @@ communication mechanism to provide location information
|
|||||||
-Dgtk-doc=false \
|
-Dgtk-doc=false \
|
||||||
-Ddbus-srv-user=srvGeoClue \
|
-Ddbus-srv-user=srvGeoClue \
|
||||||
-Ddbus-sys-dir=%{_datadir}/dbus-1/system.d \
|
-Ddbus-sys-dir=%{_datadir}/dbus-1/system.d \
|
||||||
|
-Ddefault-wifi-url="https://api.beacondb.net/v1/geolocate" \
|
||||||
|
-Ddefault-wifi-submit-url="https://api.beacondb.net/v2/geosubmit" \
|
||||||
%{nil}
|
%{nil}
|
||||||
%meson_build
|
%meson_build
|
||||||
%sysusers_generate_pre %{SOURCE1} srvGeoClue system-user-srvGeoClue.conf
|
%sysusers_generate_pre %{SOURCE1} srvGeoClue system-user-srvGeoClue.conf
|
||||||
|
Loading…
x
Reference in New Issue
Block a user