diff options
-rw-r--r-- | README | 9 | ||||
-rw-r--r-- | doc/connman.conf.5.in | 13 | ||||
-rw-r--r-- | src/main.c | 33 | ||||
-rw-r--r-- | src/main.conf | 14 | ||||
-rw-r--r-- | src/wispr.c | 14 |
5 files changed, 68 insertions, 15 deletions
@@ -408,8 +408,17 @@ from ipv4.connman.net (for IPv4 connectivity) and ipv6.connman.net (for IPv6 connectivity). The used URL looks like this http://ipv{4|6}.connman.net/online/status.html +When an online check request fails, another one is triggered after a +longer interval. The intervals follow the square series of numbers +in a specific range, by default [1, 12], corresponding to the following +intervals, in seconds: 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121 and 144. + See connman.conf(5) for the EnableOnlineCheck option, if you need to disable the feature. +It is also possible to specify other URLs via OnlineCheckIPv4URL and +OnlineCheckIPv6URL options. +The range of intervals between two online check requests can be fine-tuned +via OnlineCheckInitialInterval and OnlineCheckMaxInterval options. During the online check procedure, ConnMan will temporarily install a host route to both the ipv4.connman.net and ipv6.connman.net so that diff --git a/doc/connman.conf.5.in b/doc/connman.conf.5.in index 2e06b3ef..82cceb72 100644 --- a/doc/connman.conf.5.in +++ b/doc/connman.conf.5.in @@ -167,13 +167,16 @@ transitioned to ONLINE state. If this setting is false, the default service will remain in READY state. Default value is true. .TP +.BI OnlineCheckIPv4URL= url, OnlineCheckIPv6URL= url +Urls (IPv4 and IPv6 respectively) used during the online status check. +Please refer to the README for more detailed information. +Default values are http://ipv4.connman.net/online/status.html and +http://ipv6.connman.net/online/status.html respectively. +.TP .BI OnlineCheckInitialInterval= secs, OnlineCheckMaxInterval= secs Range of intervals between two online check requests. -When an online check request fails, another one is triggered after a -longer interval. The intervals follow the power of two series of numbers -between OnlineCheckInitialInterval and OnlineCheckMaxInterval. -Default range is [1, 12], corresponding to the following intervals, in -seconds: 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121 and 144. +Please refer to the README for more detailed information. +Default values are 1 and 12 respectively. .TP .BI EnableOnlineToReadyTransition=true\ \fR|\fB\ false WARNING: Experimental feature!!! @@ -44,6 +44,9 @@ #define DEFAULT_INPUT_REQUEST_TIMEOUT (120 * 1000) #define DEFAULT_BROWSER_LAUNCH_TIMEOUT (300 * 1000) +#define DEFAULT_ONLINE_CHECK_IPV4_URL "http://ipv4.connman.net/online/status.html" +#define DEFAULT_ONLINE_CHECK_IPV6_URL "http://ipv6.connman.net/online/status.html" + /* * We set the integer to 1 sec so that we have a chance to get * necessary IPv6 router advertisement messages that might have @@ -97,6 +100,8 @@ static struct { char *vendor_class_id; bool enable_online_check; bool enable_online_to_ready_transition; + char *online_check_ipv4_url; + char *online_check_ipv6_url; unsigned int online_check_initial_interval; unsigned int online_check_max_interval; bool auto_connect_roaming_services; @@ -122,6 +127,8 @@ static struct { .vendor_class_id = NULL, .enable_online_check = true, .enable_online_to_ready_transition = false, + .online_check_ipv4_url = DEFAULT_ONLINE_CHECK_IPV4_URL, + .online_check_ipv6_url = DEFAULT_ONLINE_CHECK_IPV6_URL, .online_check_initial_interval = DEFAULT_ONLINE_CHECK_INITIAL_INTERVAL, .online_check_max_interval = DEFAULT_ONLINE_CHECK_MAX_INTERVAL, .auto_connect_roaming_services = false, @@ -148,6 +155,8 @@ static struct { #define CONF_VENDOR_CLASS_ID "VendorClassID" #define CONF_ENABLE_ONLINE_CHECK "EnableOnlineCheck" #define CONF_ENABLE_ONLINE_TO_READY_TRANSITION "EnableOnlineToReadyTransition" +#define CONF_ONLINE_CHECK_IPV4_URL "OnlineCheckIPv4URL" +#define CONF_ONLINE_CHECK_IPV6_URL "OnlineCheckIPv6URL" #define CONF_ONLINE_CHECK_INITIAL_INTERVAL "OnlineCheckInitialInterval" #define CONF_ONLINE_CHECK_MAX_INTERVAL "OnlineCheckMaxInterval" #define CONF_AUTO_CONNECT_ROAMING_SERVICES "AutoConnectRoamingServices" @@ -174,6 +183,8 @@ static const char *supported_options[] = { CONF_VENDOR_CLASS_ID, CONF_ENABLE_ONLINE_CHECK, CONF_ENABLE_ONLINE_TO_READY_TRANSITION, + CONF_ONLINE_CHECK_IPV4_URL, + CONF_ONLINE_CHECK_IPV6_URL, CONF_ONLINE_CHECK_INITIAL_INTERVAL, CONF_ONLINE_CHECK_MAX_INTERVAL, CONF_AUTO_CONNECT_ROAMING_SERVICES, @@ -488,6 +499,20 @@ static void parse_config(GKeyFile *config) g_clear_error(&error); + string = __connman_config_get_string(config, "General", + CONF_ONLINE_CHECK_IPV4_URL, &error); + if (!error) + connman_settings.online_check_ipv4_url = string; + + g_clear_error(&error); + + string = __connman_config_get_string(config, "General", + CONF_ONLINE_CHECK_IPV6_URL, &error); + if (!error) + connman_settings.online_check_ipv6_url = string; + + g_clear_error(&error); + integer = g_key_file_get_integer(config, "General", CONF_ONLINE_CHECK_INITIAL_INTERVAL, &error); if (!error && integer >= 0) @@ -710,6 +735,12 @@ char *connman_setting_get_string(const char *key) if (g_str_equal(key, CONF_VENDOR_CLASS_ID)) return connman_settings.vendor_class_id; + if (g_str_equal(key, CONF_ONLINE_CHECK_IPV4_URL)) + return connman_settings.online_check_ipv4_url; + + if (g_str_equal(key, CONF_ONLINE_CHECK_IPV6_URL)) + return connman_settings.online_check_ipv6_url; + if (g_strcmp0(key, "wifi") == 0) { if (!option_wifi) return "nl80211,wext"; @@ -991,6 +1022,8 @@ int main(int argc, char *argv[]) g_strfreev(connman_settings.blacklisted_interfaces); g_strfreev(connman_settings.tethering_technologies); g_free(connman_settings.vendor_class_id); + g_free(connman_settings.online_check_ipv4_url); + g_free(connman_settings.online_check_ipv6_url); g_free(option_debug); g_free(option_wifi); diff --git a/src/main.conf b/src/main.conf index df70e178..ddd57996 100644 --- a/src/main.conf +++ b/src/main.conf @@ -125,12 +125,16 @@ # Default value is true. # EnableOnlineCheck = false +# Urls (IPv4 and IPv6 respectively) used during the online status check. +# Please refer to the README for more detailed information. +# Default values are http://ipv4.connman.net/online/status.html and +# http://ipv6.connman.net/online/status.html respectively. +# OnlineCheckIPv4URL= http://ipv4.connman.net/online/status.html +# OnlineCheckIPv6URL= http://ipv6.connman.net/online/status.html + # Range of intervals between two online check requests. -# When an online check request fails, another one is triggered after a -# longer interval. The intervals follow the power of two series of numbers -# between OnlineCheckInitialInterval and OnlineCheckMaxInterval. -# Default range is [1, 12], corresponding to the following intervals, in -# seconds: 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121 and 144. +# Please refer to the README for more detailed information. +# Default values are 1 and 12 respectively. # OnlineCheckInitialInterval = 1 # OnlineCheckMaxInterval = 12 diff --git a/src/wispr.c b/src/wispr.c index c63dc819..56007a37 100644 --- a/src/wispr.c +++ b/src/wispr.c @@ -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 { bool has_error; const char *current_element; @@ -96,6 +93,8 @@ static bool wispr_portal_web_result(GWebResult *result, gpointer user_data); static GHashTable *wispr_portal_list = NULL; +static char *online_check_ipv4_url = NULL; +static char *online_check_ipv6_url = NULL; static bool enable_online_to_ready_transition = false; static void connman_wispr_message_init(struct connman_wispr_message *msg) @@ -910,10 +909,10 @@ 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 = online_check_ipv4_url; } else { g_web_set_address_family(wp_context->web, AF_INET6); - wp_context->status_url = STATUS_URL_IPV6; + wp_context->status_url = online_check_ipv6_url; } for (i = 0; nameservers[i]; i++) @@ -1036,6 +1035,11 @@ int __connman_wispr_init(void) g_direct_equal, NULL, free_connman_wispr_portal); + online_check_ipv4_url = + connman_setting_get_string("OnlineCheckIPv4URL"); + online_check_ipv6_url = + connman_setting_get_string("OnlineCheckIPv6URL"); + enable_online_to_ready_transition = connman_setting_get_bool("EnableOnlineToReadyTransition"); |