Skip to content

added support for more HTTP response headers #227

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
677 changes: 677 additions & 0 deletions debian/changelog

Large diffs are not rendered by default.

33 changes: 33 additions & 0 deletions misc/checktor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
Copyright 2015 - Hermes Center - GlobaLeaks project
Author <giovanni.pellerano@evilaliv3.org>
Javascript CheckTor library
*/

function redirectIfOnTor(url, test_url) {
// Test if the user is using Tor and in that case
// redirects the user to provided url
try {
if (typeof(test_url) === 'undefined') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codacy has a fix for the issue: Replace (test_url)·===·'undefined' with ·test_url·===·"undefined"

Suggested change
if (typeof(test_url) === 'undefined') {
if (typeof test_url === "undefined") {

var test_url = 'https://antani.tor2web.org/checktor';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codacy has a fix for the issue: Replace 'https://antani.tor2web.org/checktor' with "https://antani.tor2web.org/checktor"

Suggested change
var test_url = 'https://antani.tor2web.org/checktor';
var test_url = "https://antani.tor2web.org/checktor";

}
if (window.XMLHttpRequest) {
var xmlhttp = new XMLHttpRequest();

xmlhttp.onreadystatechange=function() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codacy has a fix for the issue: Replace =function with ·=·function·

Suggested change
xmlhttp.onreadystatechange=function() {
xmlhttp.onreadystatechange = function () {

if (xmlhttp.readyState==4 && xmlhttp.status==200) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codacy has a fix for the issue: Replace ==4·&&·xmlhttp.status== with ·==·4·&&·xmlhttp.status·==·

Suggested change
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {

if (xmlhttp.getResponseHeader("x-check-tor")) {
window.location.href = url;
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codacy has a fix for the issue: Insert ;

Suggested change
}
};


xmlhttp.open("GET", test_url, true);
xmlhttp.send();

}
} catch(err) {

}
}
12 changes: 9 additions & 3 deletions tor2web/t2w.py
Original file line number Diff line number Diff line change
@@ -1052,6 +1052,7 @@ def handleHeader(self, key, values):
# some headers does not allow multiple occurrences
# in case of multiple occurrences we evaluate only the first
valueLower = values[0].lower()
proto = 'http://' if config.transport == 'HTTP' else 'https://'

if keyLower == 'transfer-encoding' and valueLower == 'chunked':
return
@@ -1074,14 +1075,19 @@ def handleHeader(self, key, values):
values = [re_sub(rexp['set-cookie_t2w'],
r'domain=\1\2.' + config.basehost + r'\3', x) for x in values]

if keyLower in 'location':
elif keyLower == 'location':

if config.mode == 'TRANSLATION':
values = [re_sub(self.translation_rexp['from'], self.translation_rexp['to'], x) for x in values]

proto = 'http://' if config.transport == 'HTTP' else 'https://'

values = [re_sub(rexp['t2w'], proto + r'\2.' + config.basehost, x) for x in values]

# especially for headers 'link' and 'x-pingback', but lets cut to the chase and do
# the regex for all non-exempted headers
else:
values = [ re_sub(rexp['t2w'], config.proto + r'\2.' + config.basehost, x) for x in values ]


self.responseHeaders.setRawHeaders(key, values)

def processResponseHeaders(self, headers):
6 changes: 5 additions & 1 deletion tor2web/utils/mail.py
Original file line number Diff line number Diff line change
@@ -56,7 +56,11 @@ def sendmail(authenticationUsername, authenticationSecret, fromAddress, toAddres
@param smtpPort: the smtp port
"""
contextFactory = ClientContextFactory()
contextFactory.method = SSL.SSLv3_METHOD

# evilaliv3:
# in order to understand and before change this settings please
# read the comment inside tor2web.utils.ssl
contextFactory.method = SSL.SSLv23_METHOD

resultDeferred = defer.Deferred()

1 change: 0 additions & 1 deletion tor2web/utils/ssl.py
Original file line number Diff line number Diff line change
@@ -126,7 +126,6 @@ def __init__(self, privateKeyFileName, certificateChainFileName, dhFileName, cip
# This trick make openssl consider valid all TLS methods.
self.sslmethod = SSL.SSLv23_METHOD


self.dhFileName = dhFileName
self.cipherList = cipherList