|
1 | 1 | /******************************************************************************* |
2 | 2 |
|
3 | | - uBlock - a browser extension to block requests. |
4 | | - Copyright (C) 2014 Raymond Hill |
| 3 | + uBlock Origin - a browser extension to block requests. |
| 4 | + Copyright (C) 2014-2016 Raymond Hill |
5 | 5 |
|
6 | 6 | This program is free software: you can redistribute it and/or modify |
7 | 7 | it under the terms of the GNU General Public License as published by |
|
19 | 19 | Home: https://github.com/gorhill/uBlock |
20 | 20 | */ |
21 | 21 |
|
22 | | -/* global punycode, µBlock */ |
| 22 | +/* global punycode */ |
23 | 23 | /* jshint bitwise: false */ |
24 | 24 |
|
| 25 | +'use strict'; |
| 26 | + |
25 | 27 | /******************************************************************************/ |
26 | 28 |
|
27 | 29 | µBlock.Firewall = (function() { |
28 | 30 |
|
29 | | -'use strict'; |
30 | | - |
31 | 31 | /******************************************************************************/ |
32 | 32 |
|
33 | 33 | var magicId = 'chmdgxwtetgu'; |
@@ -94,6 +94,10 @@ var isIPAddress = function(hostname) { |
94 | 94 |
|
95 | 95 | /******************************************************************************/ |
96 | 96 |
|
| 97 | +// TODO: Rearrange the code so as to avoid calling isIPAddress() from within |
| 98 | +// toBroaderHostname(). A hostname will never magically become an IP address |
| 99 | +// when broadened -- so no need to test for this condition each call. |
| 100 | + |
97 | 101 | var toBroaderHostname = function(hostname) { |
98 | 102 | if ( isIPAddress(hostname) ) { |
99 | 103 | return '*'; |
@@ -261,38 +265,10 @@ Matrix.prototype.unsetCell = function(srcHostname, desHostname, type) { |
261 | 265 | return true; |
262 | 266 | }; |
263 | 267 |
|
264 | | -/******************************************************************************/ |
265 | | - |
266 | | -Matrix.prototype.setCellZ = function(srcHostname, desHostname, type, action) { |
267 | | - this.evaluateCellZY(srcHostname, desHostname, type); |
268 | | - if ( this.r === action ) { |
269 | | - return false; |
270 | | - } |
271 | | - this.setCell(srcHostname, desHostname, type, 0); |
272 | | - this.evaluateCellZY(srcHostname, desHostname, type); |
273 | | - if ( this.r === action ) { |
274 | | - return true; |
275 | | - } |
276 | | - this.setCell(srcHostname, desHostname, type, action); |
277 | | - return true; |
278 | | -}; |
279 | | - |
280 | | -/******************************************************************************/ |
281 | | - |
282 | | -Matrix.prototype.blockCell = function(srcHostname, desHostname, type) { |
283 | | - return this.setCellZ(srcHostname, desHostname, type, 1); |
284 | | -}; |
285 | | - |
286 | 268 | // https://www.youtube.com/watch?v=Csewb_eIStY |
287 | 269 |
|
288 | 270 | /******************************************************************************/ |
289 | 271 |
|
290 | | -Matrix.prototype.allowCell = function(srcHostname, desHostname, type) { |
291 | | - return this.setCellZ(srcHostname, desHostname, type, 2); |
292 | | -}; |
293 | | - |
294 | | -/******************************************************************************/ |
295 | | - |
296 | 272 | Matrix.prototype.evaluateCell = function(srcHostname, desHostname, type) { |
297 | 273 | var key = srcHostname + ' ' + desHostname; |
298 | 274 | var bitmap = this.rules[key]; |
|
0 commit comments