Fixed wps function

This commit is contained in:
Martin Schröder 2015-05-20 17:21:59 +02:00 committed by Martin Schröder
parent 456b5c03e4
commit 9e53cac16f
14 changed files with 175 additions and 78 deletions

View file

@ -174,6 +174,104 @@
"fw_down_path": { dvalue: "", type: String, required: false}
}
},
"broadcom": {
"broadcom": {
"init": { dvalue: '1', type: String },
"debug": { dvalue: '0', type: String },
"wl0_cfgno": { dvalue: '', type: String },
"wl0_reg_mode": { dvalue: 'h', type: String },
"wl_5g_radio": { dvalue: 'wl0', type: String },
"wl0_acs_chan_dwell_time": { dvalue: '70', type: String },
"wl0_acs_chan_flop_period": { dvalue: '70', type: String },
"wl0_acs_ci_scan_timeout": { dvalue: '300', type: String },
"wl0_acs_ci_scan_timer": { dvalue: '4', type: String },
"wl0_acs_cs_scan_timer": { dvalue: '7200', type: String },
"wl0_acs_scan_entry_expire": { dvalue: '3600', type: String },
"wl0_acs_tx_idle_cnt": { dvalue: '5', type: String },
"wl0_acs_lowband_least_rssi": { dvalue: '-75', type: String },
"wl0_acs_fcs_mode": { dvalue: '0', type: String },
"wl0_acs_dfs": { dvalue: '1', type: String },
"wl0_acs_dfsr_activity": { dvalue: '30 10240', type: String },
"wl0_acs_dfsr_deferred": { dvalue: '604800 5', type: String },
"wl0_acs_dfsr_immediate": { dvalue: '300 3', type: String },
"wl0_apsta": { dvalue: '0', type: String },
"wl0_mode": { dvalue: 'ap', type: String },
"wl0_ifname": { dvalue: 'wl0', type: String },
"wl0_ssid": { dvalue: '', type: String },
"wl0_radio": { dvalue: '1', type: String },
"wl0_infra": { dvalue: '1', type: String },
"wl0_auth": { dvalue: '0', type: String },
"wl0_preauth": { dvalue: '0', type: String },
"wl0_net_auth_type": { dvalue: '1', type: String },
"wl0_wep": { dvalue: 'disabled', type: String },
"wl0_wpa_gtk_rekey": { dvalue: '0', type: String },
"wl0_akm": { dvalue: 'psk psk2', type: String },
"wl0_crypto": { dvalue: 'tkip+aes', type: String },
"wl0_wpa_psk": { dvalue: '', type: String },
"wl0_auth_mode": { dvalue: 'psk', type: String },
"wl0_wps_mode": { dvalue: 'enabled', type: String },
"router_disable": { dvalue: '0', type: String },
"wps_modelnum": { dvalue: '', type: String },
"boardnum": { dvalue: '', type: String },
"wps_modelname": { dvalue: 'Broadcom', type: String },
"wps_mfstring": { dvalue: 'Broadcom', type: String },
"wps_device_name": { dvalue: 'Inteno', type: String },
"wps_version2": { dvalue: 'enabled', type: String },
"lan_wps_reg": { dvalue: 'enabled', type: String },
"lan_wps_oob": { dvalue: 'disabled', type: String },
"wps_button_gpio": { dvalue: '22', type: String },
"wps_oob_configured": { dvalue: '1', type: String },
"wps_config": { dvalue: 'DONE', type: String },
"wl0_vifs": { dvalue: 'wl0', type: String },
"wl0_network": { dvalue: 'lan', type: String },
"wl0_bss_enabled": { dvalue: '1', type: String },
"wl0_hwaddr": { dvalue: '', type: String },
"wl_main_ifnames": { dvalue: 'wl0 wl1', type: String },
"wl1_cfgno": { dvalue: '', type: String },
"wl_2g_radio": { dvalue: 'wl1', type: String },
"acs_ifnames": { dvalue: 'wl0 wl1', type: String },
"wl1_acs_chan_dwell_time": { dvalue: '70', type: String },
"wl1_acs_chan_flop_period": { dvalue: '70', type: String },
"wl1_acs_ci_scan_timeout": { dvalue: '300', type: String },
"wl1_acs_ci_scan_timer": { dvalue: '4', type: String },
"wl1_acs_cs_scan_timer": { dvalue: '7200', type: String },
"wl1_acs_scan_entry_expire": { dvalue: '3600', type: String },
"wl1_acs_tx_idle_cnt": { dvalue: '5', type: String },
"wl1_acs_lowband_least_rssi": { dvalue: '-75', type: String },
"wl1_acs_fcs_mode": { dvalue: '1', type: String },
"wl1_acs_dfs": { dvalue: '0', type: String },
"wl1_apsta": { dvalue: '0', type: String },
"wl1_mode": { dvalue: 'ap', type: String },
"wl1_ifname": { dvalue: 'wl1', type: String },
"wl1_ssid": { dvalue: '', type: String },
"wl1_radio": { dvalue: '1', type: String },
"wl1_infra": { dvalue: '1', type: String },
"wl1_auth": { dvalue: '0', type: String },
"wl1_preauth": { dvalue: '0', type: String },
"wl1_net_auth_type": { dvalue: '1', type: String },
"wl1_wep": { dvalue: 'disabled', type: String },
"wl1_wpa_gtk_rekey": { dvalue: '0', type: String },
"wl1_akm": { dvalue: 'psk psk2', type: String },
"wl1_crypto": { dvalue: 'tkip+aes', type: String },
"wl1_wpa_psk": { dvalue: '', type: String },
"wl1_auth_mode": { dvalue: 'psk', type: String },
"wl1_wps_mode": { dvalue: 'enabled', type: String },
"wl1_vifs": { dvalue: 'wl1', type: String },
"wl1_network": { dvalue: 'lan', type: String },
"wl1_bss_enabled": { dvalue: '1', type: String },
"wl1_hwaddr": { dvalue: '', type: String },
"wlmngr": { dvalue: 'done', type: String },
"lan_ifname": { dvalue: 'br-lan', type: String },
"lan_ifnames": { dvalue: '', type: String },
"wps_device_pin": { dvalue: '', type: String },
"wps_config_method": { dvalue: '0x2688', type: String },
"wps_aplockdown": { dvalue: '0', type: String },
"wps_button": { dvalue: '0', type: String },
"wps_sta_pin": { dvalue: '00000000', type: String },
"wl_unit": { dvalue: '0', type: String },
"wps_proc_status": { dvalue: 0, type: Number }
}
},
"network": {
"interface": {
"is_lan": { dvalue: 1, type: Number },
@ -419,7 +517,7 @@
$rpc.uci.revert({
config: self[".name"]//,
//ubus_rpc_session: $rpc.$sid()
}).done(function(){
}).always(function(){ // we have to use always because we always want to sync regardless if reverts work or not ( they will not if the config is readonly! )
$rpc.uci.state({
config: self[".name"]
}).done(function(data){
@ -444,8 +542,6 @@
}).fail(function(){
deferred.reject();
});
}).fail(function(){
deferred.reject("Could not revert config before sync!");
});
return deferred.promise();
}

View file

@ -34,7 +34,7 @@ $juci.module("core")
.directive("luciConfigLines", function(){
var plugin_root = $juci.module("core").plugin_root;
return {
template: '<div class="table" ><div ng-transclude></div></div>',
template: '<div class="table" ><div ng-transclude></div><hr style="width: 100%; border-bottom: 1px solid #ccc; clear: both;"/></div>',
replace: true,
transclude: true
};
@ -42,16 +42,18 @@ $juci.module("core")
.directive("luciConfigLine", function(){
var plugin_root = $juci.module("core").plugin_root;
return {
template: '<div class="row" style="margin-top: 20px; ">'+
'<div class="col-md-6">'+
template: '<div><div class="row" style="margin-top: 20px; ">'+
'<div class="col-xs-6">'+
'<label style="font-size: 1.2em">{{title}}</label>'+
'<p style="font-size: 12px">{{help}}</p>'+
'</div>'+
'<div class="col-md-6">'+
'<div class="col-xs-6">'+
'<div class="{{pullClass}}" ng-transclude></div>'+
'</div></div>',
'</div></div></div>',
replace: true,
scope: {
title: "@"
title: "@",
help: "@"
},
transclude: true,
link: function (scope, element, attrs) {

View file

@ -9,7 +9,7 @@
<juci-theme-picker></juci-theme-picker>
</div>
<div id="info">
WAN IP Address: {{wanip}} | Firmware version: {{firmware}}
WAN IP Address: {{wanip||'Not connected'}} | Firmware version: {{firmware}}
</div>
</div>

View file

@ -39,6 +39,7 @@ $juci.module("core")
$languages.setLanguage(lang.short_code);
};
$scope.config = $config;
$scope.wanip = $tr(gettext("Not connected"));
$rpc.network.interface.dump().done(function(result){
if(result && result.interface) {
result.interface.map(function(i){
@ -47,6 +48,7 @@ $juci.module("core")
}
});
}
$scope.$apply();
});
$rpc.router.info().done(function(result){
if(result.system) $scope.firmware = result.system.firmware;

View file

@ -2,7 +2,14 @@ JUCI.app
.controller("StatusNATPageCtrl", function($scope, $rpc){
$rpc.luci2.network.conntrack_table().done(function(table){
if(table && table.entries){
$scope.connections = table.entries.sort(function(a, b){ return (a.src+a.dest) < (b.src+b.dest); });
$scope.connections = table.entries.sort(function(a, b){ return (a.src+a.dest) < (b.src+b.dest); }).map(function(x){
switch(x.protocol){
case 6: x.protocol = "TCP"; break;
case 2: x.protocol = "UNIX"; break;
case 17: x.protocol = "UDP"; break;
}
return x;
});
$scope.$apply();
}
});

View file

@ -34,6 +34,6 @@ describe("UCI.firewall", function(){
});
it("should have network config and settings", function(done){
expect($uci.network).to.be.ok();
expect($uci.network["@all"].to.not.be.empty());
expect($uci.network["@all"]).to.not.be.empty();
});
});

View file

@ -3,43 +3,43 @@
<luci-config-section>
<luci-config-heading>{{ 'Dropbear' | translate }}</luci-config-heading>
<luci-config-info>{{ 'settings.dropbear.info' | translate }}</luci-config-info>
<luci-config-line title="{{'Enabled'|translate}}">
<luci-config-line title="{{'Enabled'|translate}}" help="Set to 0 to disable starting dropbear at system boot.">
<switch ng-model="dropbear.enable.value" class="green" ng-change="onApply()"></switch>
</luci-config-line>
<luci-config-line title="{{'Verbose logging'|translate}}">
<luci-config-line title="{{'Verbose logging'|translate}}" help="Set to 1 to enable verbose output by the start script.">
<switch ng-model="dropbear.verbose.value" class="green" ng-change="onApply()"></switch>
</luci-config-line>
<luci-config-line title="{{'Banner File'|translate}}">
<luci-config-line title="{{'Banner File'|translate}}" help="Name of a file to be printed before the user has authenticated successfully.">
<input class="form-control" ng-model="dropbear.BannerFile.value" ng-blur="onApply()"></input>
</luci-config-line>
<luci-config-line title="{{'Password Authentication'|translate}}">
<luci-config-line title="{{'Password Authentication'|translate}}" help="Set to 0 to disable authenticating with passwords.">
<switch ng-model="dropbear.PasswordAuth.value" ng-change="onApply()"></switch>
</luci-config-line>
<luci-config-line title="{{'Port'|translate}}">
<luci-config-line title="{{'Port'|translate}}" help="Port number to listen on.">
<input class="form-control" ng-model="dropbear.Port.value" ng-blur="onApply()"></switch>
</luci-config-line>
<luci-config-line title="{{'Root Password Auth'|translate}}">
<luci-config-line title="{{'Root Password Auth'|translate}}" help="Set to 0 to disable authenticating as root with passwords.">
<switch ng-model="dropbear.RootPasswordAuth.value" ng-change="onApply()"></switch>
</luci-config-line>
<luci-config-line title="{{'Root Login'|translate}}">
<luci-config-line title="{{'Root Login'|translate}}" help="Set to 0 to disable SSH logins as root.">
<switch ng-model="dropbear.RootLogin.value" ng-change="onApply()"></switch>
</luci-config-line>
<luci-config-line title="{{'Gateway Ports'|translate}}">
<luci-config-line title="{{'Gateway Ports'|translate}}" help="Set to 1 to allow remote hosts to connect to forwarded ports.">
<switch ng-model="dropbear.GatewayPorts.value" ng-change="onApply()"></switch>
</luci-config-line>
<luci-config-line title="{{'Interface'|translate}}">
<luci-config-line title="{{'Interface'|translate}}" help="Tells dropbear to listen only on the specified interface.">
<input class="form-control" ng-model="dropbear.Interface.value" ng-blur="onApply()"></switch>
</luci-config-line>
<luci-config-line title="{{'RSA Key File'|translate}}">
<luci-config-line title="{{'RSA Key File'|translate}}" help="Path to RSA file">
<input class="form-control" ng-model="dropbear.rsakeyfile.value" ng-blur="onApply()"></switch>
</luci-config-line>
<luci-config-line title="{{'DSS Key File'|translate}}">
<luci-config-line title="{{'DSS Key File'|translate}}" help="Path to DSS/DSA file">
<input class="form-control" ng-model="dropbear.dsskeyfile.value" ng-blur="onApply()"></switch>
</luci-config-line>
<luci-config-line title="{{'Connection Keep Alive'|translate}}">
<luci-config-line title="{{'Connection Keep Alive'|translate}}" help="Keep Alive timout">
<input class="form-control" ng-model="dropbear.SSHKeepAlive.value" ng-blur="onApply()"></switch>
</luci-config-line>
<luci-config-line title="{{'Idle Timeout'|translate}}">
<luci-config-line title="{{'Idle Timeout'|translate}}" help="Idle timeout">
<input class="form-control" ng-model="dropbear.IdleTimeout.value" ng-blur="onApply()"></switch>
</luci-config-line>
</luci-config-section>

View file

@ -3,9 +3,8 @@
<luci-config-section>
<luci-config-heading>{{ 'Gateway Password' | translate }}</luci-config-heading>
<luci-config-info>{{ 'settings.password.info' | translate }}</luci-config-info>
<h3>{{'Login Account'|translate}}</h3>
<luci-config-lines>
<luci-config-line title="{{'Your account password'|translate}}">
<luci-config-line title="{{'Your account'|translate}} ({{username}})">
<button class="btn btn-default btn-lg" ng-click="onChangePasswordClick()">{{'Change Password'|translate}}</button>
</luci-config-line>
</luci-config-lines>

View file

@ -2,6 +2,7 @@ $juci.module("settings")
.controller("SettingsPasswordCtrl", function($scope, $rpc, $tr, $session, gettext){
$scope.showPassword = 0;
$scope.showModal = 0;
$scope.username = $rpc.$session.data.username;
$scope.modal = {
old_password: "",
password: "",

View file

@ -39,11 +39,13 @@ $juci.module("status")
if(!rpc){
rpc = true;
$rpc.session.access().done(function(){
$scope.showConfirmation = 0;
$scope.$apply();
window.location.reload();
}).fail(function(){
$scope.$apply();
// it will not succeed anymore because box is rebooting
}).fail(function(result){
if(result.code && result.code == -32002) { // access denied error. We will get it when it boots up again.
$scope.showConfirmation = 0;
$scope.$apply();
window.location.reload();
}
}).always(function(){
rpc = false;
});

View file

@ -10,7 +10,10 @@
</luci-config-line>
</luci-config-lines>
</luci-config-section>
<luci-config-section ng-show="wireless.status.wps.value">
<luci-config-section ng-show="progress != 0">
<p translate>wifi.wps.paired.info</p>
</luci-config-section>
<luci-config-section ng-show="wireless.status.wps.value && progress == 0">
<luci-config-lines ng-repeat="interface in wireless['@wifi-iface']">
<luci-config-line title="{{'Enable WPS on '|translate}} {{interface.ssid.value}}">
<switch id="enabled" name="enabled" ng-model="interface.wps_pbc.value" class="green" ng-change="save()" ></switch>
@ -49,19 +52,19 @@
<input type="text" class="form-control input-lg" ng-model="data.userPIN" />
</luci-config-line>
<luci-config-line title="{{'Pair (within 2 minutes)'|translate}}">
<button class="btn btn-lg btn-default" ng-click="onPairUserPIN()" translate>Pair</button>
<button ng-show="progress == 0" class="btn btn-lg btn-default" ng-click="onPairUserPIN()" translate>Pair</button>
</luci-config-line>
</luci-config-lines>
</luci-config-section>
</luci-config>
<modal title="{{'Attempting to Pair'|translate}}" ng-show="showProgress">
<div ng-show="pairState == 'progress'" >
<modal title="{{'Attempting to Pair'|translate}}" ng-show="progress != 0 && progress != 2">
<div ng-show="progress != 0" >
<i class="fa fa-spinner fa-spin fa-3x"/>
<p translate>wifi.wpspairmodal.progressinfo</p>
<p>{{timeRemaining}} <span translate>seconds remaining</span></p>
</div>
<p ng-show="pairState == 'success'" translate>wifi.wpspairmodal.successinfo</p>
<p ng-show="pairState == 'fail'" translate>wifi.wpspairmodal.failinfo</p>
<p ng-show="progress == 0" translate>wifi.wpspairmodal.progressinfo.0</p>
<p ng-show="progress == 1" translate>wifi.wpspairmodal.progressinfo.1</p>
<p ng-show="progress == 2" translate>wifi.wpspairmodal.progressinfo.2</p>
</modal>
</div>
</luci-layout-with-sidebar>

View file

@ -4,6 +4,8 @@ $juci.module("wifi")
$scope.data = {
userPIN: ""
}
$scope.progress = 0;
$uci.sync(["wireless", "boardpanel"]).done(function(){
if($uci.boardpanel == undefined) $scope.$emit("error", "Boardpanel config is not present on this system!");
else $scope.boardpanel = $uci.boardpanel;
@ -19,48 +21,29 @@ $juci.module("wifi")
}).fail(function(err){
console.log("failed to sync config: "+err);
});
function retry(){
setTimeout(function(){
$uci.sync("broadcom").done(function(){
$scope.progress = $uci.broadcom.nvram.wps_proc_status.value;
$scope.$apply();
retry();
});
}, 1000);
} retry();
$rpc.wps.showpin().done(function(data){
$scope.generatedPIN = data.pin;
});
function wpsSuccess(){
$scope.pairState = 'success';
$scope.$apply();
setTimeout(function(){
$scope.showProgress = 0;
$scope.$apply();
}, 2000);
}
function wpsFail(){
$scope.pairState = 'fail';
$scope.$apply();
setTimeout(function(){
$scope.showProgress = 0;
$scope.$apply();
}, 2000);
}
$scope.save = function(){
$uci.save();
}
$scope.onPairPBC = function(){
$scope.showProgress = 1;
$scope.pairState = 'progress';
$rpc.wps.pbc().done(function(){
wpsSuccess();
}).fail(function(){
wpsFail();
});
$rpc.wps.pbc();
}
$scope.onPairUserPIN = function(){
$scope.showProgress = 1;
$scope.pairState = 'progress';
$rpc.wps.stapin({ pin: $scope.data.userPIN }).done(function(data){
wpsSuccess();
}).fail(function(){
wpsFail();
}).always(function(){
$scope.data.userPIN = "";
$scope.$apply();
});
$rpc.wps.stapin({ pin: $scope.data.userPIN });
}
$scope.onGeneratePIN = function(){
$rpc.wps.genpin().done(function(data){

View file

@ -14,11 +14,12 @@ describe("Wireless", function(){
it("should be completed", function(){
expect(Object.keys(completed).filter(function(x){ return completed[x] == 0; })).to.be.empty();
});
it("should have wireless config", function(done){
$uci.sync("wireless").done(function(){
expect($uci.wireless).to.be.an(Object);
done();
});
it("should have wireless config", function(){
expect($uci.wireless).to.be.an(Object);
});
it("should have broadcom config", function(){
expect($uci.broadcom).to.be.an(Object);
expect($uci.broadcom["@all"]).not.to.be.empty();
});
it("should have hosts config", function(){
expect($uci.hosts).to.be.ok();

View file

@ -386,7 +386,8 @@
},
"uci": [
"network",
"wireless"
"wireless",
"broadcom"
]
},
"write": {