summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorportix <portix@gmx.net>2012-05-23 18:06:11 +0200
committerportix <portix@gmx.net>2012-05-23 18:06:11 +0200
commit551f934e06616e34bcaeb9eb6c927fe73378b6d8 (patch)
tree2b1f9acb648f8f4546e1c6fea7af4a876d4fad7c
parentf28de757befe22ba77584534e79063b19e3c4351 (diff)
downloaddwb-551f934e06616e34bcaeb9eb6c927fe73378b6d8.zip
New option addressbar-dns-lookup, closing 171
-rw-r--r--doc/dwb.111
-rw-r--r--src/callback.c14
-rw-r--r--src/callback.h1
-rw-r--r--src/config.h2
-rw-r--r--src/dwb.c52
-rw-r--r--src/dwb.h4
-rw-r--r--src/view.c4
-rw-r--r--util/settings.pre1
8 files changed, 68 insertions, 21 deletions
diff --git a/doc/dwb.1 b/doc/dwb.1
index 90b8c411..9ea81d0c 100644
--- a/doc/dwb.1
+++ b/doc/dwb.1
@@ -2,12 +2,12 @@
.\" Title: dwb
.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author]
.\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
-.\" Date: 05/18/2012
+.\" Date: 05/23/2012
.\" Manual: \ \&
.\" Source: \ \&
.\" Language: English
.\"
-.TH "DWB" "1" "05/18/2012" "\ \&" "\ \&"
+.TH "DWB" "1" "05/23/2012" "\ \&" "\ \&"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
@@ -66,7 +66,7 @@ Load configuration for profile
\fIprofilename\fR\&.
.RE
.PP
-\fB\-r, \-\-profile\fR=\fIsessionname\fR
+\fB\-r, \-\-restore\fR=\fIsessionname\fR
.RS 4
Restore session with name
\fIsessionname\fR
@@ -2948,6 +2948,11 @@ A path to a adblock plus compatible filterlist for the adblocker\&. Default valu
\fINULL\fR\&.
.RE
.PP
+\fBaddressbar\-dns\-lookup\fR
+.RS 4
+Whether to perform an dns lookup for text typed into the address bar\&. If set to true dwb performs a dns lookup for all text that does not have a valid scheme and does not contain whitespaces\&. Default value: false\&.
+.RE
+.PP
\fBbackground\-color\fR
.RS 4
The background color of the statusbar\&. Possible values: an rgb color\-string, default value:
diff --git a/src/callback.c b/src/callback.c
index 91c87ac5..e5208f5b 100644
--- a/src/callback.c
+++ b/src/callback.c
@@ -211,3 +211,17 @@ callback_key_release(GtkWidget *w, GdkEventKey *e) {
}
return false;
}/*}}}*/
+
+void
+callback_dns_resolve(SoupAddress *address, guint status, GList *gl) {
+ char *uri = NULL;
+ View *v = VIEW(gl);
+ if (status == SOUP_STATUS_OK)
+ uri = g_strconcat("http://", v->status->request_uri, NULL);
+ else
+ uri = dwb_get_searchengine(v->status->request_uri);
+ webkit_web_view_load_uri(WEBKIT_WEB_VIEW(v->web), uri);
+ g_free(uri);
+ g_free(v->status->request_uri);
+ v->status->request_uri = NULL;
+}
diff --git a/src/callback.h b/src/callback.h
index 15b47780..04e92884 100644
--- a/src/callback.h
+++ b/src/callback.h
@@ -25,4 +25,5 @@ gboolean callback_entry_insert_text(GtkWidget *, GdkEventKey *);
gboolean callback_delete_event(GtkWidget *w);
gboolean callback_key_press(GtkWidget *w, GdkEventKey *e);
gboolean callback_key_release(GtkWidget *w, GdkEventKey *e);
+void callback_dns_resolve(SoupAddress *address, guint status, GList *gl);
#endif
diff --git a/src/config.h b/src/config.h
index c66601f7..019c16f3 100644
--- a/src/config.h
+++ b/src/config.h
@@ -1100,6 +1100,8 @@ static WebSettings DWB_SETTINGS[] = {
SETTING_GLOBAL, BOOLEAN, { .b = false }, (S_Func)dwb_set_adblock, },
{ { "adblocker-filterlist", "Path to a filterlist", },
SETTING_GLOBAL, CHAR, { .p = NULL }, NULL, },
+ { { "addressbar-dns-lookup", "Whether to perform a dns check for text typed into the address bar", },
+ SETTING_GLOBAL | SETTING_ONINIT, BOOLEAN, { .b = false }, (S_Func)dwb_set_dns_lookup, },
{ { "plugin-blocker", "Whether to block flash plugins and replace them with a clickable element", },
SETTING_PER_VIEW, BOOLEAN, { .b = true }, (S_Func)dwb_set_plugin_blocker, },
{ { "plugin-blocker", "Whether to block flash plugins and replace them with a clickable element", },
diff --git a/src/dwb.c b/src/dwb.c
index 0d69a236..f67c6425 100644
--- a/src/dwb.c
+++ b/src/dwb.c
@@ -70,6 +70,7 @@ static DwbStatus dwb_set_auto_insert_mode(GList *, WebSettings *);
static DwbStatus dwb_set_tabbar_delay(GList *, WebSettings *);
static DwbStatus dwb_set_ntlm(GList *gl, WebSettings *s);
static DwbStatus dwb_set_find_delay(GList *gl, WebSettings *s);
+static DwbStatus dwb_set_dns_lookup(GList *gl, WebSettings *s);
static DwbStatus dwb_init_hints(GList *gl, WebSettings *s);
static Navigation * dwb_get_search_completion_from_navigation(Navigation *);
@@ -178,6 +179,11 @@ dwb_set_find_delay(GList *gl, WebSettings *s) {
dwb.misc.find_delay = s->arg_local.i;
return STATUS_OK;
}
+static DwbStatus
+dwb_set_dns_lookup(GList *gl, WebSettings *s) {
+ dwb.misc.dns_lookup = s->arg_local.b;
+ return STATUS_OK;
+}
/* dwb_set_cookies {{{ */
static DwbStatus
@@ -1418,25 +1424,33 @@ dwb_get_search_engine_uri(const char *uri, const char *text) {
return ret;
}/* }}} */
+char *
+dwb_get_searchengine(const char *uri) {
+ char *ret = NULL;
+ char **token = g_strsplit(uri, " ", 2);
+ for (GList *l = dwb.fc.searchengines; l; l=l->next) {
+ Navigation *n = l->data;
+ if (!g_strcmp0(token[0], n->first)) {
+ ret = dwb_get_search_engine_uri(n->second, token[1]);
+ break;
+ }
+ }
+ if (!ret) {
+ ret = dwb_get_search_engine_uri(dwb.misc.default_search, uri);
+ }
+ g_strfreev(token);
+ return ret;
+
+}
+
/* dwb_get_search_engine(const char *uri) {{{*/
char *
-dwb_get_search_engine(const char *uri, gboolean force) {
+dwb_check_searchengine(const char *uri, gboolean force) {
char *ret = NULL;
if (!strncmp(uri, "localhost", 9) && (uri[9] == ':' || uri[9] == '\0'))
return NULL;
- if ( force || !strchr(uri, '.') || strchr(uri, ' ') ) {
- char **token = g_strsplit(uri, " ", 2);
- for (GList *l = dwb.fc.searchengines; l; l=l->next) {
- Navigation *n = l->data;
- if (!g_strcmp0(token[0], n->first)) {
- ret = dwb_get_search_engine_uri(n->second, token[1]);
- break;
- }
- }
- if (!ret) {
- ret = dwb_get_search_engine_uri(dwb.misc.default_search, uri);
- }
- g_strfreev(token);
+ if ( force || !strchr(uri, '.') ) {
+ ret = dwb_get_searchengine(uri);
}
return ret;
}/*}}}*/
@@ -2079,7 +2093,15 @@ dwb_load_uri(GList *gl, const char *arg) {
if ( g_str_has_prefix(tmpuri, "http://") || g_str_has_prefix(tmpuri, "https://")) {
uri = g_strdup(tmpuri);
}
- else if (!(uri = dwb_get_search_engine(tmpuri, false))) {
+ else if (strchr(tmpuri, ' ')) {
+ uri = dwb_get_searchengine(tmpuri);
+ }
+ else if (dwb.misc.dns_lookup) {
+ VIEW(gl)->status->request_uri = g_strdup(tmpuri);
+ soup_session_prefetch_dns(dwb.misc.soupsession, tmpuri, NULL, (SoupAddressCallback)callback_dns_resolve, gl);
+ goto clean;
+ }
+ else if (!(uri = dwb_check_searchengine(tmpuri, false))) {
uri = g_strdup_printf("http://%s", tmpuri);
}
}
diff --git a/src/dwb.h b/src/dwb.h
index 1571da52..aeb45d9c 100644
--- a/src/dwb.h
+++ b/src/dwb.h
@@ -610,6 +610,7 @@ struct _ViewStatus {
SslState ssl;
ScriptState scripts;
char *hover_uri;
+ char *request_uri;
GSList *allowed_plugins;
unsigned int lockprotect;
WebKitDOMElement *style;
@@ -702,6 +703,7 @@ struct _Misc {
gint find_delay;
SoupSession *soupsession;
char *proxyuri;
+ gboolean dns_lookup;
GIOChannel *si_channel;
GList *userscripts;
@@ -871,7 +873,7 @@ DwbStatus dwb_toggle_setting(const char *, int );
DwbStatus dwb_open_startpage(GList *);
void dwb_init_scripts(void);
void dwb_reload_userscripts(void);
-char * dwb_get_search_engine(const char *uri, gboolean);
+char * dwb_get_searchengine(const char *uri);
char * dwb_get_stock_item_base64_encoded(const char *);
void dwb_remove_bookmark(const char *);
void dwb_remove_download(const char *);
diff --git a/src/view.c b/src/view.c
index abfd0fae..118277f4 100644
--- a/src/view.c
+++ b/src/view.c
@@ -680,7 +680,6 @@ view_load_error_cb(WebKitWebView *web, WebKitWebFrame *frame, char *uri, GError
|| weberror->code == WEBKIT_POLICY_ERROR_FRAME_LOAD_INTERRUPTED_BY_POLICY_CHANGE)
return false;
-
char *errorfile = util_get_data_file(ERROR_FILE, "lib");
if (errorfile == NULL)
return false;
@@ -698,7 +697,7 @@ view_load_error_cb(WebKitWebView *web, WebKitWebFrame *frame, char *uri, GError
tmp[strlen(tmp)-1] = '\0';
char *icon = dwb_get_stock_item_base64_encoded(GTK_STOCK_DIALOG_ERROR);
- if ((search = dwb_get_search_engine(tmp, true)) != NULL)
+ if ((search = dwb_get_searchengine(tmp)) != NULL)
site = g_strdup_printf(content, icon != NULL ? icon : "", uri, weberror->message, "visible", search);
else
site = g_strdup_printf(content, icon != NULL ? icon : "", uri, weberror->message, "hidden", "");
@@ -842,6 +841,7 @@ view_create_web_view() {
status->search_string = NULL;
status->downloads = NULL;
status->hover_uri = NULL;
+ status->request_uri = NULL;
status->progress = 0;
status->allowed_plugins = NULL;
status->style = NULL;
diff --git a/util/settings.pre b/util/settings.pre
index 1590960b..fc593ad8 100644
--- a/util/settings.pre
+++ b/util/settings.pre
@@ -14,6 +14,7 @@ zoom-level text The default zoom level
zoom-step text The zoom step
# session Network &amp Session
+addressbar-dns-lookup checkbox Whether to first perform a dns lookup for text typed in the addressbar before loading the site
cookies-accept-policy select @always @never @nothirdparty The cookies to accept, affects also session cookies
cookies-store-policy select @session @persistent @never The storage policy for cookies
enable-dns-prefetching checkbox Whether webkit prefetches domain names