Skip to content

Commit

Permalink
Add support for Onion Services V3 (#353)
Browse files Browse the repository at this point in the history
  • Loading branch information
evilaliv3 committed Sep 29, 2019
1 parent 396f956 commit 42f93d0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions tor2web/t2w.py
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,7 @@ def process(self):
else:
self.var['basehost'] = config.basehost

rexp['w2t'] = re.compile(b'(http:|https:)?//([a-z0-9\.]*[a-z0-9]{16})\.' + self.var['basehost'].encode('utf-8'), re.I)
rexp['w2t'] = re.compile(b'(http:|https:)?//([a-z0-9\.]*[a-z0-9]{56})\.' + self.var['basehost'].encode('utf-8'), re.I)

# the requested resource is remote, we act as proxy
if config.mode == 'TRANSLATION' and request.host in hosts_map:
Expand Down Expand Up @@ -1349,10 +1349,10 @@ def umask(mask):

rexp = {
'body': re.compile(b'(<body.*?\s*>)', re.I),
'w2t': re.compile(b'(http:|https:)?\/\/([a-z0-9\.]*[a-z0-9]{16})' + config.basehost.encode('utf-8'), re.I),
't2w': re.compile(b'(http:|https:)?\/\/([a-z0-9\.]*[a-z0-9]{16})\.onion', re.I),
'set_cookie_t2w': re.compile(b'domain=([a-z0-9\.]*[a-z0-9]{16})\.onion', re.I),
'html_t2w': re.compile( b'(archive|background|cite|classid|codebase|data|formaction|href|icon|longdesc|manifest|poster|profile|src|url|usemap|)([\s]*=[\s]*[\'\"]?)(?:http:|https:)?\/\/([a-z0-9\.]*[a-z0-9]{16})\.onion([\ \'\"\/])', re.I)
'w2t': re.compile(b'(http:|https:)?\/\/([a-z0-9\.]*[a-z0-9]{16,56})' + config.basehost.encode('utf-8'), re.I),
't2w': re.compile(b'(http:|https:)?\/\/([a-z0-9\.]*[a-z0-9]{16,56})\.onion', re.I),
'set_cookie_t2w': re.compile(b'domain=([a-z0-9\.]*[a-z0-9]{16,56})\.onion', re.I),
'html_t2w': re.compile( b'(archive|background|cite|classid|codebase|data|formaction|href|icon|longdesc|manifest|poster|profile|src|url|usemap|)([\s]*=[\s]*[\'\"]?)(?:http:|https:)?\/\/([a-z0-9\.]*[a-z0-9]{16,56})\.onion([\ \'\"\/])', re.I)
}

# ##############################################################################
Expand Down
2 changes: 1 addition & 1 deletion tor2web/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,5 @@ def is_onion(hostname):
Check to see if the address is a .onion.
returns the onion address as a string if True else returns False
"""
pattern = re.compile('^([0-9a-z]){16}.onion$')
pattern = re.compile('^([a-z0-9]){16,56}.onion$')
return pattern.match(hostname) != None

0 comments on commit 42f93d0

Please sign in to comment.