Skip to content

Commit

Permalink
Merge pull request #1742 from uProxy/release-candidate
Browse files Browse the repository at this point in the history
Release v0.8.14
  • Loading branch information
iislucas committed Jul 15, 2015
2 parents 3e7d3ed + 40c18be commit c6f6454
Show file tree
Hide file tree
Showing 35 changed files with 346 additions and 340 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "uProxy",
"version": "0.8.13",
"version": "0.8.14",
"dependencies": {
"polymer": "^0.5.6",
"paper-elements": "Polymer/paper-elements#^0.5.6",
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "uProxy",
"description": "Share your pathway to the Internet",
"version": "0.8.13",
"version": "0.8.14",
"repository": {
"type": "git",
"url": "https://github.com/uproxy/uproxy"
Expand Down Expand Up @@ -47,7 +47,7 @@
"lodash": "^3.7.0",
"regex2dfa": "^0.1.6",
"tsd": "^0.5.7",
"uproxy-lib": "^27.2.5",
"uproxy-lib": "^28.0.0",
"utransformers": "^0.2.1",
"xregexp": "^2.0.0"
},
Expand Down
2 changes: 1 addition & 1 deletion src/chrome/app/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "__MSG_appName__",
"description": "__MSG_appDescription__",
"minimum_chrome_version": "41.0.2272.63",
"version": "0.8.13",
"version": "0.8.14",
"default_locale": "en",
"icons": {
"128": "icons/128_online.png"
Expand Down
2 changes: 1 addition & 1 deletion src/chrome/extension/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "__MSG_extName__",
"version": "0.8.13",
"version": "0.8.14",
"manifest_version": 2,
"description": "__MSG_extDescription__",
"minimum_chrome_version": "41.0.2272.63",
Expand Down
19 changes: 13 additions & 6 deletions src/chrome/extension/scripts/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@ import UiApi = require('../../../interfaces/ui');
import user_interface = require('../../../generic_ui/scripts/ui');
import CoreConnector = require('../../../generic_ui/scripts/core_connector');
import uproxy_core_api = require('../../../interfaces/uproxy_core_api');
import Constants = require('../../../generic_ui/scripts/constants');

/// <reference path='../../../freedom/typings/social.d.ts' />
/// <reference path='../../../third_party/typings/chrome/chrome.d.ts'/>

export import model = user_interface.model;

// --------------------- Communicating with the App ----------------------------
export var browserConnector :ChromeCoreConnector; // way for ui to speak to a uProxy.CoreApi
export var core :CoreConnector; // way for ui to speak to a uProxy.CoreApi
Expand Down Expand Up @@ -63,13 +62,25 @@ chrome.runtime.onMessageExternal.addListener((request :any, sender :chrome.runti
* updates from the Chrome App side propogate to the UI.
*/
browserApi = new ChromeBrowserApi();
browserConnector = new ChromeCoreConnector({ name: 'uproxy-extension-to-app-port' });
browserConnector.onUpdate(uproxy_core_api.Update.LAUNCH_UPROXY,
browserApi.bringUproxyToFront);

// TODO (lucyhe): Make sure that the "install" event isn't missed if we
// are adding the listener after the event is fired.
chrome.runtime.onInstalled.addListener((details :chrome.runtime.InstalledDetails) => {
if (details.reason !== 'install') {
// we only want to launch the window on the first install
return;
}
browserConnector.onceConnected.then(() => {
chrome.browserAction.setIcon({
path: {
"19" : "icons/19_" + Constants.DEFAULT_ICON,
"38" : "icons/38_" + Constants.DEFAULT_ICON,
}
});
});

chrome.tabs.query({currentWindow: true, active: true}, function(tabs){
// Do not open the extension when it's installed if the user is
Expand All @@ -85,10 +96,6 @@ chrome.browserAction.onClicked.addListener((tab) => {
browserApi.bringUproxyToFront();
});

browserConnector = new ChromeCoreConnector({ name: 'uproxy-extension-to-app-port' });
browserConnector.onUpdate(uproxy_core_api.Update.LAUNCH_UPROXY,
browserApi.bringUproxyToFront);

core = new CoreConnector(browserConnector);
var oAuth = new ChromeTabAuth();
browserConnector.onUpdate(uproxy_core_api.Update.GET_CREDENTIALS,
Expand Down
4 changes: 2 additions & 2 deletions src/chrome/extension/scripts/chrome_browser_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class ChromeBrowserApi implements BrowserAPI {

private popupState_ = PopupState.NOT_LAUNCHED;

public fulfillLaunched : () => void;
public handlePopupLaunch :() => void;
private onceLaunched_ :Promise<void>;

constructor() {
Expand Down Expand Up @@ -169,7 +169,7 @@ class ChromeBrowserApi implements BrowserAPI {
// after webstore installation), then allow the popup to open at a default
// location.
this.onceLaunched_ = new Promise<void>((F, R) => {
this.fulfillLaunched = F;
this.handlePopupLaunch = F;
});
chrome.windows.create({url: this.POPUP_URL,
type: "popup",
Expand Down
3 changes: 2 additions & 1 deletion src/chrome/extension/scripts/chrome_core_connector.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ describe('core-connector', () => {
chromeBrowserApi = jasmine.createSpyObj('ChromeBrowserApi',
['bringUproxyToFront',
'showNotification',
'on']);
'on',
'handlePopupLaunch']);



Expand Down
2 changes: 1 addition & 1 deletion src/chrome/extension/scripts/chrome_tab_auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class ChromeTabAuth {
}
};

var isActive = !user_interface.model.reconnecting;
var isActive = true; //TODO use actual value
chrome.tabs.create({url: url, active: isActive},
function(tab: chrome.tabs.Tab) {
if (isActive) {
Expand Down
2 changes: 1 addition & 1 deletion src/chrome/extension/scripts/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export var browserConnector :browser_connector.CoreBrowserConnector = ui_context

export var ui :user_interface.UserInterface = new user_interface.UserInterface(core, ui_context.browserApi);

export var model :user_interface.Model = user_interface.model;
export var model :user_interface.Model = ui.model;

ui.browser = 'chrome';
console.log('Loaded dependencies for Chrome Extension.');
3 changes: 2 additions & 1 deletion src/firefox/data/scripts/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import CoreConnector = require('../../../generic_ui/scripts/core_connector');
import FirefoxCoreConnector = require('./firefox_connector');
import FirefoxBrowserApi = require('./firefox_browser_api');

export import model = user_interface.model;
export var ui :user_interface.UserInterface;
export var core :CoreConnector;
export var browserConnector: FirefoxCoreConnector;
export var model :user_interface.Model;
function initUI() {
browserConnector = new FirefoxCoreConnector();
core = new CoreConnector(browserConnector);
Expand All @@ -17,6 +17,7 @@ function initUI() {

if (undefined === ui) {
ui = initUI();
model = ui.model;
}

ui.browser = 'firefox';
5 changes: 2 additions & 3 deletions src/firefox/data/scripts/firefox_browser_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ class FirefoxBrowserApi implements BrowserAPI {
port.on('emitRejected', this.handleEmitRejected_);
}

// Firefox doesn't ever need to wait for popup to open,
// We don't have onceLaunched promise, so fulfillLaunched is empty.
public fulfillLaunched = () => {
// Firefox has no work to do on initial launch
public handlePopupLaunch = () => {
}

public setIcon = (iconFile :string) : void => {
Expand Down
2 changes: 1 addition & 1 deletion src/firefox/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "This is the alpha version of uProxy.",
"author": "uProxy Team <info@uproxy.org>",
"license": "Apache 2.0",
"version": "0.8.13",
"version": "0.8.14",
"permissions": {
"private-browsing": true
}
Expand Down
165 changes: 67 additions & 98 deletions src/generic_core/diagnose-nat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -613,13 +613,6 @@ export function doUdpTest() {
}

socket.bind('0.0.0.0', 0)
.then((result :number) => {
if (result != 0) {
return Promise.reject(new Error('listen failed to bind :5758' +
' with result code ' + result));
}
return Promise.resolve(result);
})
.then(socket.getInfo)
.then((socketInfo: freedom_UdpSocket.SocketInfo) => {
log.debug('listening on %1:%2',
Expand Down Expand Up @@ -694,13 +687,7 @@ function pingStunServer(serverAddr: string) {

var bytes = Turn.formatStunMessage(bindRequest);
socket.bind('0.0.0.0', 0)
.then((result: number) => {
if (result != 0) {
return Promise.reject(new Error('listen failed to bind :5758' +
' with result code ' + result));
}
return Promise.resolve(result);
}).then(() => {
.then(() => {
return socket.sendTo(bytes.buffer, parts[1], parseInt(parts[2]));
}).then((written: number) => {
log.debug('%1 bytes sent correctly', [written]);
Expand Down Expand Up @@ -769,12 +756,6 @@ export function doNatProvoking() :Promise<string> {
socket.on('onData', onUdpData);

socket.bind('0.0.0.0', 0)
.then((result: number) => {
if (result != 0) {
return Promise.reject(new Error('failed to bind to a port: err=' + result));
}
return Promise.resolve(result);
})
.then(socket.getInfo)
.then((socketInfo: freedom_UdpSocket.SocketInfo) => {
log.debug('listening on %1:%2',
Expand Down Expand Up @@ -879,28 +860,24 @@ export function probePmpSupport(routerIp:string, privateIp:string) :Promise<bool
});

// Bind a UDP port and send a NAT-PMP request
socket.bind(privateIp, 0).
then((result:number) => {
if (result != 0) {
R(new Error('Failed to bind to a port: Err= ' + result));
}

// Construct the NAT-PMP map request as an ArrayBuffer
// Map internal port 55555 to external port 55555 w/ 120 sec lifetime
var pmpBuffer = new ArrayBuffer(12);
var pmpView = new DataView(pmpBuffer);
// Version and OP fields (1 byte each)
pmpView.setInt8(0, 0);
pmpView.setInt8(1, 1);
// Reserved, internal port, external port fields (2 bytes each)
pmpView.setInt16(2, 0, false);
pmpView.setInt16(4, 55555, false);
pmpView.setInt16(6, 55555, false);
// Mapping lifetime field (4 bytes)
pmpView.setInt32(8, 120, false);

socket.sendTo(pmpBuffer, routerIp, 5351);
});
socket.bind('0.0.0.0', 0).
then(() => {
// Construct the NAT-PMP map request as an ArrayBuffer
// Map internal port 55555 to external port 55555 w/ 120 sec lifetime
var pmpBuffer = new ArrayBuffer(12);
var pmpView = new DataView(pmpBuffer);
// Version and OP fields (1 byte each)
pmpView.setInt8(0, 0);
pmpView.setInt8(1, 1);
// Reserved, internal port, external port fields (2 bytes each)
pmpView.setInt16(2, 0, false);
pmpView.setInt16(4, 55555, false);
pmpView.setInt16(6, 55555, false);
// Mapping lifetime field (4 bytes)
pmpView.setInt32(8, 120, false);

socket.sendTo(pmpBuffer, routerIp, 5351);
}).catch(R);
});

// Give _probePmpSupport 2 seconds before timing out
Expand All @@ -923,55 +900,51 @@ export function probePcpSupport(routerIp:string, privateIp:string) :Promise<bool
});

// Bind a UDP port and send a PCP request
socket.bind(privateIp, 0).
then((result:number) => {
if (result != 0) {
R(new Error('Failed to bind to a port: Err= ' + result));
}

// Create the PCP MAP request as an ArrayBuffer
// Map internal port 55556 to external port 55556 w/ 120 sec lifetime
var pcpBuffer = new ArrayBuffer(60);
var pcpView = new DataView(pcpBuffer);
// Version field (1 byte)
pcpView.setInt8(0, 0b00000010);
// R and Opcode fields (1 bit + 7 bits)
pcpView.setInt8(1, 0b00000001);
// Reserved field (2 bytes)
pcpView.setInt16(2, 0, false);
// Requested lifetime (4 bytes)
pcpView.setInt32(4, 120, false);
// Client IP address (128 bytes; we use the IPv4 -> IPv6 mapping)
pcpView.setInt32(8, 0, false);
pcpView.setInt32(12, 0, false);
pcpView.setInt16(16, 0, false);
pcpView.setInt16(18, 0xffff, false);
// Start of IPv4 octets of the client's private IP
var ipOctets = ipaddr.IPv4.parse(privateIp).octets;
pcpView.setInt8(20, ipOctets[0]);
pcpView.setInt8(21, ipOctets[1]);
pcpView.setInt8(22, ipOctets[2]);
pcpView.setInt8(23, ipOctets[3]);
// Mapping Nonce (12 bytes)
pcpView.setInt32(24, randInt(0, 0xffffffff), false);
pcpView.setInt32(28, randInt(0, 0xffffffff), false);
pcpView.setInt32(32, randInt(0, 0xffffffff), false);
// Protocol (1 byte)
pcpView.setInt8(36, 17);
// Reserved (3 bytes)
pcpView.setInt16(37, 0, false);
pcpView.setInt8(39, 0);
// Internal and external ports
pcpView.setInt16(40, 55556, false);
pcpView.setInt16(42, 55556, false);
// External IP address (128 bytes; we use the all-zero IPv4 -> IPv6 mapping)
pcpView.setFloat64(44, 0, false);
pcpView.setInt16(52, 0, false);
pcpView.setInt16(54, 0xffff, false);
pcpView.setInt32(56, 0, false);

socket.sendTo(pcpBuffer, routerIp, 5351);
});
socket.bind('0.0.0.0', 0).
then(() => {
// Create the PCP MAP request as an ArrayBuffer
// Map internal port 55556 to external port 55556 w/ 120 sec lifetime
var pcpBuffer = new ArrayBuffer(60);
var pcpView = new DataView(pcpBuffer);
// Version field (1 byte)
pcpView.setInt8(0, 0b00000010);
// R and Opcode fields (1 bit + 7 bits)
pcpView.setInt8(1, 0b00000001);
// Reserved field (2 bytes)
pcpView.setInt16(2, 0, false);
// Requested lifetime (4 bytes)
pcpView.setInt32(4, 120, false);
// Client IP address (128 bytes; we use the IPv4 -> IPv6 mapping)
pcpView.setInt32(8, 0, false);
pcpView.setInt32(12, 0, false);
pcpView.setInt16(16, 0, false);
pcpView.setInt16(18, 0xffff, false);
// Start of IPv4 octets of the client's private IP
var ipOctets = ipaddr.IPv4.parse(privateIp).octets;
pcpView.setInt8(20, ipOctets[0]);
pcpView.setInt8(21, ipOctets[1]);
pcpView.setInt8(22, ipOctets[2]);
pcpView.setInt8(23, ipOctets[3]);
// Mapping Nonce (12 bytes)
pcpView.setInt32(24, randInt(0, 0xffffffff), false);
pcpView.setInt32(28, randInt(0, 0xffffffff), false);
pcpView.setInt32(32, randInt(0, 0xffffffff), false);
// Protocol (1 byte)
pcpView.setInt8(36, 17);
// Reserved (3 bytes)
pcpView.setInt16(37, 0, false);
pcpView.setInt8(39, 0);
// Internal and external ports
pcpView.setInt16(40, 55556, false);
pcpView.setInt16(42, 55556, false);
// External IP address (128 bytes; we use the all-zero IPv4 -> IPv6 mapping)
pcpView.setFloat64(44, 0, false);
pcpView.setInt16(52, 0, false);
pcpView.setInt16(54, 0xffff, false);
pcpView.setInt32(56, 0, false);

socket.sendTo(pcpBuffer, routerIp, 5351);
}).catch(R);
});

// Give _probePcpSupport 2 seconds before timing out
Expand Down Expand Up @@ -1007,12 +980,8 @@ function sendSsdpRequest(privateIp:string) :Promise<ArrayBuffer> {
});

// Bind a socket and send the SSDP request
socket.bind(privateIp, 0).
then((result:number) => {
if (result != 0) {
R(new Error('Failed to bind to a port: Err= ' + result));
}

socket.bind('0.0.0.0', 0).
then(() => {
// Construct and send a UPnP SSDP message
var ssdpStr = 'M-SEARCH * HTTP/1.1\r\n' +
'HOST: 239.255.255.250:1900\r\n' +
Expand All @@ -1021,7 +990,7 @@ function sendSsdpRequest(privateIp:string) :Promise<ArrayBuffer> {
'ST: urn:schemas-upnp-org:device:InternetGatewayDevice:1';
var ssdpBuffer = arraybuffers.stringToArrayBuffer(ssdpStr);
socket.sendTo(ssdpBuffer, '239.255.255.250', 1900);
});
}).catch(R);
});

// Give _sendSsdpRequest 1 second before timing out
Expand Down
Loading

0 comments on commit c6f6454

Please sign in to comment.