Add an option to disable host blocking.
This commit is contained in:
parent
70ccdd86b2
commit
2f629befc3
@ -143,6 +143,7 @@
|
|||||||
|<<content-cookies-accept,cookies-accept>>|Whether to accept cookies.
|
|<<content-cookies-accept,cookies-accept>>|Whether to accept cookies.
|
||||||
|<<content-cookies-store,cookies-store>>|Whether to store cookies.
|
|<<content-cookies-store,cookies-store>>|Whether to store cookies.
|
||||||
|<<content-host-block-lists,host-block-lists>>|List of URLs of lists which contain hosts to block.
|
|<<content-host-block-lists,host-block-lists>>|List of URLs of lists which contain hosts to block.
|
||||||
|
|<<content-host-blocking-enabled,host-blocking-enabled>>|Whether host blocking is enabled.
|
||||||
|==============
|
|==============
|
||||||
|
|
||||||
.Quick reference for section ``hints''
|
.Quick reference for section ``hints''
|
||||||
@ -1235,6 +1236,17 @@ The file can be in one of the following formats:
|
|||||||
|
|
||||||
Default: +pass:[http://www.malwaredomainlist.com/hostslist/hosts.txt,http://someonewhocares.org/hosts/hosts,http://winhelp2002.mvps.org/hosts.zip,http://malwaredomains.lehigh.edu/files/justdomains.zip,http://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&mimetype=plaintext]+
|
Default: +pass:[http://www.malwaredomainlist.com/hostslist/hosts.txt,http://someonewhocares.org/hosts/hosts,http://winhelp2002.mvps.org/hosts.zip,http://malwaredomains.lehigh.edu/files/justdomains.zip,http://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&mimetype=plaintext]+
|
||||||
|
|
||||||
|
[[content-host-blocking-enabled]]
|
||||||
|
=== host-blocking-enabled
|
||||||
|
Whether host blocking is enabled.
|
||||||
|
|
||||||
|
Valid values:
|
||||||
|
|
||||||
|
* +true+
|
||||||
|
* +false+
|
||||||
|
|
||||||
|
Default: +pass:[true]+
|
||||||
|
|
||||||
== hints
|
== hints
|
||||||
Hinting settings.
|
Hinting settings.
|
||||||
|
|
||||||
|
@ -326,13 +326,17 @@ class NetworkManager(QNetworkAccessManager):
|
|||||||
elif scheme in self._scheme_handlers:
|
elif scheme in self._scheme_handlers:
|
||||||
return self._scheme_handlers[scheme].createRequest(
|
return self._scheme_handlers[scheme].createRequest(
|
||||||
op, req, outgoing_data)
|
op, req, outgoing_data)
|
||||||
|
|
||||||
|
host_blocker = objreg.get('host-blocker')
|
||||||
if (op == QNetworkAccessManager.GetOperation and
|
if (op == QNetworkAccessManager.GetOperation and
|
||||||
req.url().host() in objreg.get('host-blocker').blocked_hosts):
|
req.url().host() in host_blocker.blocked_hosts and
|
||||||
|
config.get('content', 'host-blocking-enabled')):
|
||||||
log.webview.info("Request to {} blocked by host blocker.".format(
|
log.webview.info("Request to {} blocked by host blocker.".format(
|
||||||
req.url().host()))
|
req.url().host()))
|
||||||
return networkreply.ErrorNetworkReply(
|
return networkreply.ErrorNetworkReply(
|
||||||
req, HOSTBLOCK_ERROR_STRING, QNetworkReply.ContentAccessDenied,
|
req, HOSTBLOCK_ERROR_STRING, QNetworkReply.ContentAccessDenied,
|
||||||
self)
|
self)
|
||||||
|
|
||||||
if config.get('network', 'do-not-track'):
|
if config.get('network', 'do-not-track'):
|
||||||
dnt = '1'.encode('ascii')
|
dnt = '1'.encode('ascii')
|
||||||
else:
|
else:
|
||||||
|
@ -622,6 +622,10 @@ DATA = collections.OrderedDict([
|
|||||||
"- One host per line\n"
|
"- One host per line\n"
|
||||||
"- A zip-file of any of the above, with either only one file, or a "
|
"- A zip-file of any of the above, with either only one file, or a "
|
||||||
"file named 'hosts' (with any extension)."),
|
"file named 'hosts' (with any extension)."),
|
||||||
|
|
||||||
|
('host-blocking-enabled',
|
||||||
|
SettingValue(typ.Bool(), 'true'),
|
||||||
|
"Whether host blocking is enabled."),
|
||||||
)),
|
)),
|
||||||
|
|
||||||
('hints', sect.KeyValue(
|
('hints', sect.KeyValue(
|
||||||
|
Loading…
Reference in New Issue
Block a user