Commit f3c9364c authored by Lorn Potter's avatar Lorn Potter

[connman] add configurable online status url

With this patch, can add something
in main.conf:
Ipv4StatusUrl = http://someurl.com/status.html
Ipv6StatusUrl = http://someurl.com/status.html

default connman's url are at:
http://ipv4.connman.net/online/status.html
http://ipv6.connman.net/online/status.html
even if nothing is set in config file
parent 842f4ec9
......@@ -28,6 +28,9 @@
extern "C" {
#endif
#define CONF_STATUS_URL_IPV6 "Ipv6StatusUrl"
#define CONF_STATUS_URL_IPV4 "Ipv4StatusUrl"
connman_bool_t connman_setting_get_bool(const char *key);
char **connman_setting_get_string_list(const char *key);
unsigned int *connman_setting_get_uint_list(const char *key);
......
......@@ -53,8 +53,6 @@ static unsigned int newlink_watch;
static unsigned int newlink_flags;
static int newlink_timeout_id;
#define STATUS_URL "http://ipv6.connman.net/online/status.html"
#ifndef IP_DF
#define IP_DF 0x4000 /* Flag: "Don't Fragment" */
#endif
......@@ -315,7 +313,9 @@ static void tun_newlink(unsigned flags, unsigned change, void *user_data)
if (getenv("CONNMAN_WEB_DEBUG"))
g_web_set_debug(web, web_debug, "6to4");
web_request_id = g_web_request_get(web, STATUS_URL,
const char *url = connman_option_get_string(CONF_STATUS_URL_IPV6);
web_request_id = g_web_request_get(web, url,
web_result, NULL, NULL);
newlink_timeout(NULL);
......
......@@ -72,7 +72,9 @@ static struct {
connman_bool_t single_tech;
char **tethering_technologies;
connman_bool_t persistent_tethering_mode;
connman_bool_t start_session;
connman_bool_t start_session;
char **ipv6_status_url;
char **ipv4_status_url;
} connman_settings = {
.bg_scan = TRUE,
.pref_timeservers = NULL,
......@@ -86,7 +88,9 @@ static struct {
.single_tech = FALSE,
.tethering_technologies = NULL,
.persistent_tethering_mode = FALSE,
.start_session = FALSE,
.start_session = FALSE,
.ipv4_status_url = NULL,
.ipv6_status_url = NULL,
};
#define CONF_BG_SCAN "BackgroundScanning"
......@@ -101,7 +105,10 @@ static struct {
#define CONF_SINGLE_TECH "SingleConnectedTechnology"
#define CONF_TETHERING_TECHNOLOGIES "TetheringTechnologies"
#define CONF_PERSISTENT_TETHERING_MODE "PersistentTetheringMode"
#define CONF_START_SESSION "StartSession"
#define CONF_START_SESSION "StartSession"
#define CONF_STATUS_URL_IPV6 "Ipv6StatusUrl"
#define CONF_STATUS_URL_IPV4 "Ipv4StatusUrl"
static const char *supported_options[] = {
CONF_BG_SCAN,
......@@ -116,7 +123,9 @@ static const char *supported_options[] = {
CONF_SINGLE_TECH,
CONF_TETHERING_TECHNOLOGIES,
CONF_PERSISTENT_TETHERING_MODE,
CONF_START_SESSION,
CONF_START_SESSION,
CONF_STATUS_URL_IPV4,
CONF_STATUS_URL_IPV6,
NULL
};
......@@ -238,6 +247,8 @@ static void parse_config(GKeyFile *config)
char **interfaces;
char **str_list;
char **tethering;
char **ipv4url;
char **ipv6url;
gsize len;
int timeout;
......@@ -361,6 +372,24 @@ static void parse_config(GKeyFile *config)
connman_settings.persistent_tethering_mode = boolean;
g_clear_error(&error);
ipv4url = g_key_file_get_string(config, "General", CONF_STATUS_URL_IPV4, &error);
if (error == NULL)
connman_settings.ipv4_status_url = ipv4url;
else
connman_settings.ipv4_status_url = "http://ipv4.connman.net/online/status.html";
g_clear_error(&error);
ipv6url = g_key_file_get_string(config, "General", CONF_STATUS_URL_IPV6, &error);
if (error == NULL)
connman_settings.ipv6_status_url = ipv6url;
else
connman_settings.ipv6_status_url = "http://ipv6.connman.net/online/status.html";
g_clear_error(&error);
}
static int config_init(const char *file)
......@@ -510,13 +539,18 @@ static GOptionEntry options[] = {
};
const char *connman_option_get_string(const char *key)
{
{
if (g_strcmp0(key, "wifi") == 0) {
if (option_wifi == NULL)
return "nl80211,wext";
else
return option_wifi;
}
if (g_str_equal(key, CONF_STATUS_URL_IPV4) == TRUE) {
return connman_settings.ipv4_status_url;
}
if (g_str_equal(key, CONF_STATUS_URL_IPV6) == TRUE)
return connman_settings.ipv6_status_url;
return NULL;
}
......
......@@ -95,3 +95,7 @@
# re-enabling a technology, and after restarts and reboots.
# Default value is false.
# PersistentTetheringMode = false
# set the online status url
Ipv4StatusUrl = http://ipv4.connman.net/online/status.html
Ipv6StatusUrl = http://ipv6.connman.net/online/status.html
......@@ -30,9 +30,6 @@
#include "connman.h"
#define STATUS_URL_IPV4 "http://ipv4.connman.net/online/status.html"
#define STATUS_URL_IPV6 "http://ipv6.connman.net/online/status.html"
struct connman_wispr_message {
gboolean has_error;
const char *current_element;
......@@ -864,10 +861,11 @@ static int wispr_portal_detect(struct connman_wispr_portal_context *wp_context)
if (wp_context->type == CONNMAN_IPCONFIG_TYPE_IPV4) {
g_web_set_address_family(wp_context->web, AF_INET);
wp_context->status_url = STATUS_URL_IPV4;
wp_context->status_url = connman_option_get_string(CONF_STATUS_URL_IPV4);
} else {
g_web_set_address_family(wp_context->web, AF_INET6);
wp_context->status_url = STATUS_URL_IPV6;
wp_context->status_url = connman_option_get_string(CONF_STATUS_URL_IPV6);
}
for (i = 0; nameservers[i] != NULL; i++)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment