commit 7210ef5a7d3b75541f784c3905a849414d05d3b8 Author: David Fifield david@bamsoftware.com Date: Mon Jan 11 12:55:02 2016 -0800
Remove the Chrome extension as it is unmaintained.
I don't know of anyone using it and I haven't tried it in a long time. We can bring it back if there is a need. --- README | 8 +-- chrome/README | 15 ---- chrome/app/background.js | 155 ---------------------------------------- chrome/app/manifest.json | 26 ------- chrome/extension/background.js | 130 --------------------------------- chrome/extension/manifest.json | 20 ------ 6 files changed, 4 insertions(+), 350 deletions(-)
diff --git a/README b/README index b79d761..b042827 100644 --- a/README +++ b/README @@ -34,8 +34,8 @@ with the --helper option pointing at a browser extension that has been set up separately. How it works is meek-client tells the browser what URL to request, the browser requests it and returns the payload to meek-client. The TLS implementation is that of the browser, so it better -blends in with allowed traffic. Browser extensions for Chrome and -Firefox are in the chrome and firefox directories. +blends in with allowed traffic. A browser extensions for Firefox is in +the firefox directory.
Here is a summary of the programs that appear in subdirectories.
@@ -45,8 +45,8 @@ copies requests and responses to an instance of meek-server somewhere. A public instance of the App Engine web app is at https://meek-reflect.appspot.com/.
-chrome, firefox: -Browser extensions for TLS camouflage. +firefox: +Browser extension for TLS camouflage.
meek-client: The client transport plugin, run by a censored client. diff --git a/chrome/README b/chrome/README deleted file mode 100644 index 940e555..0000000 --- a/chrome/README +++ /dev/null @@ -1,15 +0,0 @@ -meek helper extension for Chrome. - -To use, you must disable SPDY in Chrome by running it like this: - chrome --use-spdy=off -Start Chrome, then enter the Tools→Extensions screen. Click the "Load -unpacked extension" button and add the directory "app" in this -directory. Click the button again and add the directory "extension". -(You need to add both the app and the extension.) - -If the text under meek-browser-app reads "Inspect views: background page -(Inactive)", click the link in order to make it active. The extension -will be listening on localhost port 7000. Start tor with a torrc line -like this: - -ClientTransportPlugin meek exec ./meek-client --url=https://meek-reflect.appspot.com/ --front=www.google.com --log meek-client.log --helper 127.0.0.1:7000 diff --git a/chrome/app/background.js b/chrome/app/background.js deleted file mode 100644 index e26ab1b..0000000 --- a/chrome/app/background.js +++ /dev/null @@ -1,155 +0,0 @@ -const DEBUG = false; - -function debug(str) { - if (DEBUG) { console.debug(str); } -} - -function info(str) { - console.info(str); -} - -const IP = "127.0.0.1"; -const PORT = 7000; - -const STATE_READING_LENGTH = 1; -const STATE_READING_OBJECT = 2; - -var serverSocketId; -var state = STATE_READING_LENGTH; -var buf = new Uint8Array(4); -var bytesToRead = buf.length; - -chrome.runtime.onMessageExternal.addListener( - function onHeartbeat(id, sender, sendResponse) { - console.assert(id === sender.id, "Sender's ID is incorrect."); - EXTENSION_ID = id; - chrome.runtime.onMessageExternal.removeListener(onHeartbeat); - chrome.sockets.tcpServer.create({}, function(createInfo) { - listenAndAccept(createInfo.socketId); - }); - } -); - -function listenAndAccept(socketId) { - info("listenAndAccept " + socketId); - chrome.sockets.tcpServer.listen(socketId, - IP, PORT, function(resultCode) { - onListenCallback(socketId, resultCode) - }); -} - -function onListenCallback(socketId, resultCode) { - debug("onListenCallback " + socketId); - if (resultCode < 0) { - debug("Error listening:" + - chrome.runtime.lastError.message); - return; - } - serverSocketId = socketId; - chrome.sockets.tcpServer.onAccept.addListener(onAccept); - chrome.sockets.tcpServer.onAcceptError.addListener(function(info) { - debug("onAcceptError " + JSON.stringify(info)); - }); - chrome.sockets.tcp.onReceive.addListener(onReceive); - chrome.sockets.tcp.onReceiveError.addListener(function(info) { - chrome.sockets.tcp.close(info.socketId); - debug("onReceiveError " + JSON.stringify(info)); - }); -} - -function onAccept(info) { - debug("onAccept " + JSON.stringify(info)); - if (info.socketId != serverSocketId) - return; - - chrome.sockets.tcp.setPaused(info.clientSocketId, false); -} - -function readIntoBuf(data) { - debug("readIntoBuf " + "bytesToRead: " + bytesToRead + ", datalen: " + data.byteLength + ", buflen: " + buf.length); - var n = Math.min(data.byteLength, bytesToRead); - buf.set(new Uint8Array(data.slice(0, n)), buf.length - bytesToRead); - bytesToRead -= n; - return data.slice(n); -} - -function onReceive(info) { - debug("onReceive " + JSON.stringify(info) + " len: " + info.data.byteLength); - var data = info.data; - switch (state) { - case STATE_READING_LENGTH: - data = readIntoBuf(data); - if (bytesToRead > 0) - return; - - var b = buf; - bytesToRead = (b[0] << 24) | (b[1] << 16) | (b[2] << 8) | b[3]; - debug(bytesToRead); - buf = new Uint8Array(bytesToRead); - state = STATE_READING_OBJECT; - - case STATE_READING_OBJECT: - data = readIntoBuf(data); - if (bytesToRead > 0) - return; - - var str = ab2str(buf); - debug(str); - var request = JSON.parse(str); - makeRequest(request, info.socketId); - - state = STATE_READING_LENGTH; - buf = new Uint8Array(4); - bytesToRead = buf.length; - } -} - -function makeRequest(request, socketId) { - debug("makeRequest " + JSON.stringify(request)); - - port = chrome.runtime.connect(EXTENSION_ID); - port.onMessage.addListener(function(response) { - returnResponse(response, socketId); - port.disconnect(); - }); - port.onDisconnect.addListener(function() { - debug("onDisconnect"); - }); - port.postMessage(request); -} - -function returnResponse(response, socketId) { - debug("returnResponse " + JSON.stringify(response)); - var str = JSON.stringify(response); - var b = str2ab(str); - - var buf = new Uint8Array(4 + b.byteLength); - var len = b.byteLength; - buf[0] = (len >> 24) & 0xff; - buf[1] = (len >> 16) & 0xff; - buf[2] = (len >> 8) & 0xff; - buf[3] = len & 0xff; - buf.set(new Uint8Array(b), 4); - - chrome.sockets.tcp.send(socketId, buf.buffer, function(info) { - debug("send " + socketId); - if (info.resultCode != 0) - debug("Send failed " + info.resultCode); - }); -} - -function ab2str(buffer) { - var encodedString = String.fromCharCode.apply(null, buffer), - decodedString = decodeURIComponent(escape(encodedString)); - return decodedString; -} - -function str2ab(string) { - var string = unescape(encodeURIComponent(string)), - charList = string.split(''), - buf = []; - for (var i = 0; i < charList.length; i++) { - buf.push(charList[i].charCodeAt(0)); - } - return (new Uint8Array(buf)).buffer; -} diff --git a/chrome/app/manifest.json b/chrome/app/manifest.json deleted file mode 100644 index 6c288d2..0000000 --- a/chrome/app/manifest.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "manifest_version": 2, - "name": "meek-browser-app", - "minimum_chrome_version": "24", - "version": "0.1", - - "permissions": [ - "alarms" - ], - - "sockets": { - "tcp": { - "connect": "*" - }, - "tcpServer": { - "listen": "127.0.0.1:7000" - } - }, - - "app": { - "background": { - "scripts": ["background.js"], - "persistent": true - } - } -} diff --git a/chrome/extension/background.js b/chrome/extension/background.js deleted file mode 100644 index 836f022..0000000 --- a/chrome/extension/background.js +++ /dev/null @@ -1,130 +0,0 @@ -const DEBUG = false; - -function debug(str) { - if (DEBUG) { console.info(str); } -} - -chrome.alarms.create("heartbeat", {when: 5000, periodInMinutes: 1 }); -chrome.alarms.onAlarm.addListener(function(alarm) { - chrome.management.getAll(function(extensions) { - var app_id; - for (var i = 0; i < extensions.length; i++) { - if (extensions[i].name === "meek-browser-app") { - app_id = extensions[i].id; - break; - } - } - chrome.runtime.sendMessage(app_id, chrome.runtime.id); - }); -}); - -var host = 'meek-reflect.appspot.com'; - -function onBeforeSendHeadersCallback(details) { - var did_set = false; - for (var i = 0; i < details.requestHeaders.length; ++i) { - if (details.requestHeaders[i].name === 'Host') { - details.requestHeaders[i].value = host; - did_set = true; - } - } - if (!did_set) { - details.requestHeaders.push({ - name: 'Host', - value: host - }); - } - return { requestHeaders: details.requestHeaders }; -} - -chrome.runtime.onConnectExternal.addListener(function(port) { - debug("onConnectExternal"); - port.onMessage.addListener(function(request) { - debug("onMessage"); - var timeout = 2000; - var xhr = new XMLHttpRequest(); - xhr.responseType = "arraybuffer"; - xhr.ontimeout = function() { - console.error(url + "timed out."); - chrome.webRequest.onBeforeSendHeaders.removeListener(onBeforeSendHeadersCallback); - }; - xhr.onerror = function() { - chrome.webRequest.onBeforeSendHeaders.removeListener(onBeforeSendHeadersCallback); - var response = { error: xhr.statusText }; - sendResponse(response); - }; - xhr.onload = function() { - debug("onload " + xhr.response.byteLength); - chrome.webRequest.onBeforeSendHeaders.removeListener(onBeforeSendHeadersCallback); - var response = { - status: xhr.status, - body: _arrayBufferToBase64(xhr.response) - }; - port.postMessage(response); - debug("postMessage " + JSON.stringify(response)); - }; - var requestMethod = request.method; - var url = request.url; - xhr.open(requestMethod, url); - if (request.header != undefined) { - for (var key in request.header) { - if (key != "Host") { // TODO: Add more restricted header fields - xhr.setRequestHeader(key, request.header[key]); - } else { - host = request.header[key]; - } - } - } - var body = null; - if (request.body != undefined) { - body = _base64ToArrayBuffer(request.body); - xhr.overrideMimeType("Content-Type", "application/octet-stream"); - debug(body); - } - - chrome.webRequest.onBeforeSendHeaders.addListener(onBeforeSendHeadersCallback, { - urls: [url], - types: ['xmlhttprequest'] - }, ['requestHeaders', 'blocking']); - - xhr.send(body); - }); -}); - -function _base64ToArrayBuffer(base64) { - var binary_string = atob(base64); - var len = binary_string.length; - var bytes = new Uint8Array(len); - for (var i = 0; i < len; i++) { - bytes[i] = binary_string.charCodeAt(i); - } - return bytes; -} - -function _arrayBufferToBase64(buf) { - var bytes = new Uint8Array(buf); - debug(JSON.stringify(buf)); - var base64 = ''; - var encodings = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; - var chr1, chr2, chr3, enc1, enc2, enc3, enc4; - var i = 0; - while (i < bytes.length) { - chr1 = bytes[i++]; - chr2 = i < bytes.length ? bytes[i++] : Number.NaN; - chr3 = i < bytes.length ? bytes[i++] : Number.NaN; - - enc1 = chr1 >> 2; - enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); - enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); - enc4 = chr3 & 63; - - if (isNaN(chr2)) { - enc3 = enc4 = 64; - } else if (isNaN(chr3)) { - enc4 = 64; - } - base64 += encodings.charAt(enc1) + encodings.charAt(enc2) + - encodings.charAt(enc3) + encodings.charAt(enc4); - } - return base64; -} diff --git a/chrome/extension/manifest.json b/chrome/extension/manifest.json deleted file mode 100644 index c6bf6a3..0000000 --- a/chrome/extension/manifest.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "manifest_version": 2, - "name": "meek-browser-extension", - "minimum_chrome_version": "24", - "version": "0.1", - - "permissions": [ - "notifications", - "alarms", - "management", - "webRequest", - "webRequestBlocking", - "<all_urls>" - ], - - "background": { - "scripts": ["background.js"], - "persistent": true - } -}