Skip to content

Commit

Permalink
use a more readable url scheme for the redirect mode; fix two small b…
Browse files Browse the repository at this point in the history
…ugs in server.js and redirect.js
  • Loading branch information
Bo Zhu committed Jul 22, 2014
1 parent 98b7568 commit 6e5ebbd
Show file tree
Hide file tree
Showing 17 changed files with 11 additions and 27 deletions.
6 changes: 3 additions & 3 deletions chrome/config.js
@@ -1,5 +1,4 @@
/*
* Allow you smoothly surf on many websites blocking non-mainland visitors.
* Copyright (C) 2012 - 2014 Bo Zhu http://zhuzhu.org
*
* This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -27,8 +26,9 @@
var unblock_youku = unblock_youku || {}; // namespace

// only for redirect mode
unblock_youku.default_server = 'www.yōukù.com/proxy.php';
unblock_youku.backup_server = 'bak.yōukù.com/proxy.php';
unblock_youku.default_server = 'www.yōukù.com/proxy';
// unblock_youku.default_server = '127.0.0.1:8888/proxy';
unblock_youku.backup_server = 'bak.yōukù.com/proxy';

unblock_youku.normal_url_list = unblock_youku.common_urls.concat(unblock_youku.chrome_extra_urls);
unblock_youku.redirect_url_list = unblock_youku.common_urls;
Expand Down
1 change: 0 additions & 1 deletion chrome/content/links.js
@@ -1,5 +1,4 @@
/*
* Allow you smoothly surf on many websites blocking non-mainland visitors.
* Copyright (C) 2012 - 2014 Bo Zhu http://zhuzhu.org
*
* This program is free software: you can redistribute it and/or modify
Expand Down
1 change: 0 additions & 1 deletion chrome/content/play.baidu.css
@@ -1,5 +1,4 @@
/*
* Allow you smoothly surf on many websites blocking non-mainland visitors.
* Copyright (C) 2012 - 2014 Bo Zhu http://zhuzhu.org
*
* This program is free software: you can redistribute it and/or modify
Expand Down
1 change: 0 additions & 1 deletion chrome/content/play.baidu.js
@@ -1,5 +1,4 @@
/*
* Allow you smoothly surf on many websites blocking non-mainland visitors.
* Copyright (C) 2012 - 2014 Bo Zhu http://zhuzhu.org
*
* This program is free software: you can redistribute it and/or modify
Expand Down
1 change: 0 additions & 1 deletion chrome/content/tudou.js
@@ -1,5 +1,4 @@
/*
* Allow you smoothly surf on many websites blocking non-mainland visitors.
* Copyright (C) 2012 - 2014 Bo Zhu http://zhuzhu.org
*
* This program is free software: you can redistribute it and/or modify
Expand Down
1 change: 0 additions & 1 deletion chrome/header.js
@@ -1,5 +1,4 @@
/*
* Allow you smoothly surf on many websites blocking non-mainland visitors.
* Copyright (C) 2012 - 2014 Bo Zhu http://zhuzhu.org
*
* This program is free software: you can redistribute it and/or modify
Expand Down
1 change: 0 additions & 1 deletion chrome/pages/css/popup.css
@@ -1,5 +1,4 @@
/*
* Allow you smoothly surf on many websites blocking non-mainland visitors.
* Copyright (C) 2012 - 2014 Bo Zhu http://zhuzhu.org
*
* This program is free software: you can redistribute it and/or modify
Expand Down
1 change: 0 additions & 1 deletion chrome/pages/js/analytics.js
@@ -1,5 +1,4 @@
/*
* Allow you smoothly surf on many websites blocking non-mainland visitors.
* Copyright (C) 2012 - 2014 Bo Zhu http://zhuzhu.org
*
* This program is free software: you can redistribute it and/or modify
Expand Down
1 change: 0 additions & 1 deletion chrome/pages/js/options.js
@@ -1,5 +1,4 @@
/*
* Allow you smoothly surf on many websites blocking non-mainland visitors.
* Copyright (C) 2012 - 2014 Bo Zhu http://zhuzhu.org
*
* This program is free software: you can redistribute it and/or modify
Expand Down
1 change: 0 additions & 1 deletion chrome/pages/js/popup.js
@@ -1,5 +1,4 @@
/*
* Allow you smoothly surf on many websites blocking non-mainland visitors.
* Copyright (C) 2012 - 2014 Bo Zhu http://zhuzhu.org
*
* This program is free software: you can redistribute it and/or modify
Expand Down
1 change: 0 additions & 1 deletion chrome/proxy.js
@@ -1,5 +1,4 @@
/*
* Allow you smoothly surf on many websites blocking non-mainland visitors.
* Copyright (C) 2012 - 2014 Bo Zhu http://zhuzhu.org
*
* This program is free software: you can redistribute it and/or modify
Expand Down
16 changes: 7 additions & 9 deletions chrome/redirect.js
@@ -1,5 +1,4 @@
/*
* Allow you smoothly surf on many websites blocking non-mainland visitors.
* Copyright (C) 2012 - 2014 Bo Zhu http://zhuzhu.org
*
* This program is free software: you can redistribute it and/or modify
Expand All @@ -18,15 +17,10 @@

/*jslint browser: true */
/*global chrome: false, unblock_youku: false, btoa: false */
/*global ga_report_error */
/*global ga_report_error: false, string_starts_with: false */
"use strict";


function urlsafe_b64encode(str) {
return btoa(str).replace('+', '-').replace('/', '_');
}


function http_redirector(details) {
console.log('original url: ' + details.url);
if (details.url.slice(-15) === 'crossdomain.xml') {
Expand Down Expand Up @@ -59,7 +53,11 @@ function http_redirector(details) {
}

//var redirect_url = 'http://127.0.0.1.xip.io:8080/?url=' + urlsafe_b64encode(details.url);
redirect_url = 'http://' + backend_server + '?url=' + urlsafe_b64encode(details.url);
if (string_starts_with(details.url, 'http://')) {
redirect_url = 'http://' + backend_server + '/http/' + details.url.substring('http://'.length);
} else if (string_starts_with(details.url, 'https://')) {
redirect_url = 'http://' + backend_server + '/https/' + details.url.substring('https://'.length);
}
console.log('redirect url: ' + redirect_url);

if (redirect_url !== null) {
Expand All @@ -79,7 +77,7 @@ function check_redirect_server(server_addr, success_callback, failure_callback)
failure_callback('Timeout');
}, 10000); // 10s

xhr.open('GET', 'http://' + server_addr.match(/^(.[^:\/]+)/)[1] + '/status', true);
xhr.open('GET', 'http://' + server_addr.match(/^(.[^\/]+)/)[1] + '/status', true);
xhr.timeout = 12000; // 12s
xhr.onreadystatechange = function() {
if (xhr.readyState === 4) {
Expand Down
1 change: 0 additions & 1 deletion chrome/storage.js
@@ -1,5 +1,4 @@
/*
* Allow you smoothly surf on many websites blocking non-mainland visitors.
* Copyright (C) 2012 - 2014 Bo Zhu http://zhuzhu.org
*
* This program is free software: you can redistribute it and/or modify
Expand Down
2 changes: 1 addition & 1 deletion server/server.js
Expand Up @@ -247,7 +247,7 @@ if (cluster.isMaster) {
console.log(('Using the backup proxy: ' + opts.bak_proxy).green);
}
if (opts.pac_proxy) {
console.log(('The PAC file uses the proxy: ' + opts.bak_proxy).green);
console.log(('The PAC file uses the proxy: ' + opts.pac_proxy).green);
}

} else if (cluster.isWorker) {
Expand Down
1 change: 0 additions & 1 deletion server/utils.js
@@ -1,5 +1,4 @@
/*
* Allow you smoothly surf on many websites blocking non-mainland visitors.
* Copyright (C) 2012 - 2014 Bo Zhu http://zhuzhu.org
*
* This program is free software: you can redistribute it and/or modify
Expand Down
1 change: 0 additions & 1 deletion shared/tools.js
@@ -1,5 +1,4 @@
/*
* Allow you smoothly surf on many websites blocking non-mainland visitors.
* Copyright (C) 2012 - 2014 Bo Zhu http://zhuzhu.org
*
* This program is free software: you can redistribute it and/or modify
Expand Down
1 change: 0 additions & 1 deletion shared/urls.js
@@ -1,5 +1,4 @@
/*
* Allow you smoothly surf on many websites blocking non-mainland visitors.
* Copyright (C) 2012 - 2013 Bo Zhu http://zhuzhu.org
*
* This program is free software: you can redistribute it and/or modify
Expand Down

0 comments on commit 6e5ebbd

Please sign in to comment.