Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Commit

Permalink
Merge pull request #340 from aleitner/master
Browse files Browse the repository at this point in the history
Port configuration more vocal. Bug in tab.js fixed
  • Loading branch information
bookchin authored Aug 10, 2016
2 parents 3d4553b + e19606e commit 4156976
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 27 deletions.
60 changes: 35 additions & 25 deletions app/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,12 @@ var appSettings = new Vue({
var min = 1000;
var max = 65535;

if (port < min || port > max) {
if ((port !== 0) && (port < min || port > max)) {
window.alert(
port + '\n' +
'Port cannot be less than ' + min + ' or greater than ' + max +
'\nSetting Port number to 0.'
);
return 0;
} else {
return port;
Expand All @@ -674,9 +679,20 @@ var appSettings = new Vue({

var potentialconnections = end - start + 1;

if (potentialconnections < 0 || numConnections < 0) {
if (start === 0 && end === 0) {
return numConnections;
} else if (potentialconnections < 0 || numConnections < 0) {
window.alert(
'Number of tunnel connections cannot be less than 0.' +
'\nSetting Connection number to 0.'
);
return 0;
} else if (numConnections > potentialconnections) {
window.alert(
'The max amount of tunnels in port range ' +
start + '-' + end + ' is ' + potentialconnections + '.' +
'\nSetting Connection number to ' + potentialconnections
);
return potentialconnections;
} else {
return numConnections;
Expand All @@ -691,38 +707,32 @@ var appSettings = new Vue({
}

if (end < start) {
window.alert('The End TCP port may not be lower than the Start port.');
window.alert(
'The End TCP port may not be lower than the Start TCP port.' +
'\nDefaulting to equal the Start TCP port.'
);
return start;
} else {
return end;
}
},
validate: function() {
var self = this;
var userdata = this.userdata;
var tab = this.userdata.tabs[this.current];

userdata.tabs.forEach(function(tab, i) {
tab.network.port = this.validatePort(tab.network.port);
tab.tunnels.tcpPort = this.validatePort(tab.tunnels.tcpPort);
tab.tunnels.startPort = this.validatePort(tab.tunnels.startPort);

userdata.tabs[i].network.port = self.validatePort(
tab.network.port
);
userdata.tabs[i].tunnels.tcpPort = self.validatePort(
tab.tunnels.tcpPort)
;
userdata.tabs[i].tunnels.startPort = self.validatePort(
tab.tunnels.startPort
);
userdata.tabs[i].tunnels.endPort = self.validateEndPort(
userdata.tabs[i].tunnels.startPort,
tab.tunnels.endPort
);
tab.tunnels.endPort = this.validateEndPort(
tab.tunnels.startPort,
tab.tunnels.endPort
);

userdata.tabs[i].tunnels.numConnections = self.validateNumConnections(
userdata.tabs[i].tunnels.startPort,
userdata.tabs[i].tunnels.endPort,
tab.tunnels.numConnections
);
});
tab.tunnels.numConnections = this.validateNumConnections(
tab.tunnels.startPort,
tab.tunnels.endPort,
tab.tunnels.numConnections
);

this.changeSettings();
},
Expand Down
7 changes: 6 additions & 1 deletion app/lib/tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,13 @@ function Tab(options) {
seed: options.network.seed || '',
nat: options.network.nat || 'true'
};

var numcx = (isNaN(Number(options.tunnels.numConnections))) ?
0 :
options.tunnels.numConnections;

this.tunnels = {
numConnections: options.tunnels.numConnections || 3,
numConnections: numcx,
tcpPort: options.tunnels.tcpPort || 0,
startPort: options.tunnels.startPort || 0,
endPort: options.tunnels.endPort || 0
Expand Down
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"productName": "Storj Share",
"identifier": "com.storj.farmer",
"description": "Earn money by sharing your extra hard drive space",
"version": "1.0.5",
"version": "1.0.6",
"author": "Storj <[email protected]>",
"main": "main.js",
"config": {
Expand Down

0 comments on commit 4156976

Please sign in to comment.