|
1 | | -""" |
2 | | - Tor2web |
3 | | - Copyright (C) 2012 Hermes No Profit Association - GlobaLeaks Project |
4 | | -
|
5 | | - This program is free software: you can redistribute it and/or modify |
6 | | - it under the terms of the GNU Affero General Public License as published by |
7 | | - the Free Software Foundation, either version 3 of the License, or |
8 | | - (at your option) any later version. |
9 | | -
|
10 | | - This program is distributed in the hope that it will be useful, |
11 | | - but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | | - GNU Affero General Public License for more details. |
14 | | -
|
15 | | - You should have received a copy of the GNU Affero General Public License |
16 | | - along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | | -""" |
18 | | - |
19 | 1 | """ |
20 | 2 |
|
21 | 3 | :mod:`Tor2Web` |
|
64 | 46 | from twisted.python.compat import networkString, intToBytes |
65 | 47 | from twisted.python.failure import Failure |
66 | 48 | from twisted.python.filepath import FilePath |
67 | | -from twisted.python.log import err |
68 | 49 | from twisted.internet.task import LoopingCall |
69 | 50 | from tor2web import __version__ |
70 | 51 | from tor2web.utils.config import Config |
@@ -231,7 +212,7 @@ def spawnT2W(father, childFDs, fds_https, fds_http): |
231 | 212 | childFDs=childFDs) |
232 | 213 |
|
233 | 214 |
|
234 | | -class Tor2webObj(): |
| 215 | +class Tor2webObj(object): |
235 | 216 | def __init__(self): |
236 | 217 | # The destination hidden service identifier |
237 | 218 | self.onion = None |
@@ -439,12 +420,6 @@ def __init__(self, channel, queued, reactor=reactor): |
439 | 420 |
|
440 | 421 | self.translation_rexp = {} |
441 | 422 |
|
442 | | - def finish(self): |
443 | | - try: |
444 | | - http.Request.finish() |
445 | | - except Exception: |
446 | | - pass |
447 | | - |
448 | 423 | def getRequestHostname(self): |
449 | 424 | """ |
450 | 425 | Function overload to fix ipv6 bug: |
@@ -496,7 +471,7 @@ def getForwarders(self): |
496 | 471 | port)) |
497 | 472 | else: |
498 | 473 | raise Exception |
499 | | - except: |
| 474 | + except Exception: |
500 | 475 | return [] |
501 | 476 |
|
502 | 477 | return forwarders |
@@ -841,7 +816,7 @@ def process(self): |
841 | 816 | ctype = ctype[0] |
842 | 817 |
|
843 | 818 | if self.method == b"POST" and ctype: |
844 | | - key, pdict = parse_header(ctype) |
| 819 | + key, _ = parse_header(ctype) |
845 | 820 | if key == b'application/x-www-form-urlencoded': |
846 | 821 | args.update(parse_qs(content, 1)) |
847 | 822 | # ################################################################ |
@@ -923,7 +898,7 @@ def process(self): |
923 | 898 |
|
924 | 899 | else: |
925 | 900 | if type(antanistaticmap[staticpath]) == str: |
926 | | - filename, ext = os.path.splitext(staticpath) |
| 901 | + _, ext = os.path.splitext(staticpath) |
927 | 902 | self.setHeader(b'content-type', mimetypes.types_map[ext]) |
928 | 903 | content = antanistaticmap[staticpath] |
929 | 904 | defer.returnValue(self.contentFinish(content)) |
@@ -1560,7 +1535,7 @@ def daemon_shutdown(self): |
1560 | 1535 | t2w_daemon.daemon_shutdown = daemon_shutdown |
1561 | 1536 | t2w_daemon.rpc_server = T2WRPCServer(config) |
1562 | 1537 |
|
1563 | | - t2w_daemon.run(config) |
| 1538 | + t2w_daemon.run() |
1564 | 1539 |
|
1565 | 1540 | else: |
1566 | 1541 | set_proctitle("tor2web-worker") |
|
0 commit comments