File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+ Copyright 2015 - Hermes Center - GlobaLeaks project
3
+ Author <giovanni.pellerano@evilaliv3.org>
4
+
5
+ Javascript CheckTor library
6
+ */
7
+
8
+ function redirectIfOnTor ( url , test_url ) {
9
+ // Test if the user is using Tor and in that case
10
+ // redirects the user to provided url
11
+ try {
12
+ if ( typeof ( test_url ) === 'undefined' ) {
13
+ var test_url = 'https://antani.tor2web.org/checktor' ;
14
+ }
15
+ if ( window . XMLHttpRequest ) {
16
+ var xmlhttp = new XMLHttpRequest ( ) ;
17
+
18
+ xmlhttp . onreadystatechange = function ( ) {
19
+ if ( xmlhttp . readyState == 4 && xmlhttp . status == 200 ) {
20
+ if ( xmlhttp . getResponseHeader ( "x-check-tor" ) ) {
21
+ window . location . href = url ;
22
+ }
23
+ }
24
+ }
25
+
26
+ xmlhttp . open ( "GET" , test_url , true ) ;
27
+ xmlhttp . send ( ) ;
28
+
29
+ }
30
+ } catch ( err ) {
31
+
32
+ }
33
+ }
You can’t perform that action at this time.
0 commit comments