winter_soldier Posted January 10, 2016 Share Posted January 10, 2016 (edited) Patch unlocks additional channels depending on country code: before (mine is hardest to GB for some reason): after: diff -Npaur pineapple/modules/Configuration/api/module.php pineapple-new/modules/Configuration/api/module.php --- pineapple/modules/Configuration/api/module.php 2015-12-21 23:12:02.000000000 +0000 +++ pineapple-new/modules/Configuration/api/module.php 2016-01-10 13:06:40.000000000 +0000 @@ -44,6 +44,14 @@ class Configuration extends SystemModule case 'disableLandingPage': $this->disableLandingPage(); break; + + case 'changeRegion': + $this->changeRegion(); + break; + + case 'getCurrentRegion': + $this->getCurrentRegion(); + break; } } @@ -73,6 +81,19 @@ class Configuration extends SystemModule $this->response = array("success" => true); } + private function getCurrentRegion() + { + $currentRegion = exec('iw reg get|head -n 1|cut -b 9-10'); + $this->response = array("currentRegion" => $currentRegion); + } + + private function changeRegion() + { + $region = escapeshellarg($this->request->Region); + exec("iw reg set {$region}"); + $this->response = array("success" => true); + } + private function getLandingPageData() { $landingPage = file_get_contents('/etc/pineapple/landingpage.php'); diff -Npaur pineapple/modules/Configuration/js/module.js pineapple-new/modules/Configuration/js/module.js --- pineapple/modules/Configuration/js/module.js 2015-12-21 23:12:02.000000000 +0000 +++ pineapple-new/modules/Configuration/js/module.js 2016-01-10 13:06:40.000000000 +0000 @@ -7,6 +7,8 @@ registerController("ConfigurationGeneral $scope.newPasswordRepeat = ""; $scope.showPasswordSuccess = false; $scope.showPasswordError = false; + $scope.customRegion = ""; + $scope.currentRegion = ""; $scope.timeZones = [ { value: 'GMT+12', description: "(GMT-12:00) Eniwetok, Kwajalein" }, @@ -46,6 +48,15 @@ registerController("ConfigurationGeneral }); }); + $scope.getCurrentRegion = (function() { + $api.request({ + module: "Configuration", + action: "getCurrentRegion" + }, function(response) { + $scope.currentRegion = response.currentRegion; + }); + }); + $scope.rebootPineapple = (function() { if (confirm("Are you sure you want to reboot your WiFi Pineapple?")) { $api.request({ @@ -115,12 +126,30 @@ registerController("ConfigurationGeneral }, function(response) { if (response.success !== undefined) { - $scope.getCurrentTimeZone(); + $scope.getCurrentTimezone(); $scope.customOffset = ""; } }); }); + $scope.changeRegion = (function() { + var tmpRegion; + if ($scope.customRegion.trim() !== "") { + tmpRegion = $scope.customRegion; + } + $api.request({ + module: "Configuration", + action: "changeRegion", + Region: tmpRegion, + + }, function(response) { + if (response.success !== undefined) { + $scope.getCurrentRegion(); + $scope.customRegion="00"; + } + }); + }); + $scope.getCurrentRegion(); $scope.getCurrentTimeZone(); }]); @@ -179,4 +208,4 @@ registerController('ConfigurationLanding }); $scope.getLandingPageStatus(); -}]); \ No newline at end of file +}]); diff -Npaur pineapple/modules/Configuration/module.html pineapple-new/modules/Configuration/module.html --- pineapple/modules/Configuration/module.html 2015-12-11 01:10:48.000000000 +0000 +++ pineapple-new/modules/Configuration/module.html 2016-01-10 13:06:40.000000000 +0000 @@ -42,10 +42,27 @@ </div> </div> </form> - <br/> + <form class="form-horizontal"> + <div class="form-group"> + <label class="col-sm-2 control-label">Region: </label> + <div class="col-sm-3"> + <input type="text" class="form-control" ng-model="currentRegion" disabled> + </div> + </div> + <div class="form-group"> + <label for="Region" class="col-sm-2 control-label">Region Code</label> + <div class="col-sm-5"> + <input type="text" class="form-control" placeholder="00" ng-model="customRegion"> + </div> + </div> + <div class="form-group"> + <div class="col-sm-offset-2 col-sm-10"> + <button type="submit" class="btn btn-default" ng-click="changeRegion()">Change Region</button> + </div> + </div> + </form> <br/> - <form class="form-horizontal"> <div class="form-group"> <label for="oldPassword" class="col-sm-2 control-label">Old Password</label> @@ -100,4 +117,4 @@ </div> </div> </div> -</div> \ No newline at end of file +</div> Edited January 16, 2016 by winter_soldier 1 Quote Link to comment Share on other sites More sharing options...
winter_soldier Posted January 16, 2016 Author Share Posted January 16, 2016 (edited) Another patch for networking - not the best, but indicates channels available before (purposefully changed the Region to US for this pic): after setting the Region to JP (Japan): diff -Npaur pineapple-new/modules/Networking/api/module.php /pineapple/modules/Networking/api/module.php --- pineapple-new/modules/Networking/api/module.php 2016-01-03 17:00:01.000000000 +0000 +++ /pineapple/modules/Networking/api/module.php 2016-01-16 14:54:13.000000000 +0000 @@ -76,6 +76,10 @@ class Networking extends SystemModule case 'disconnect': $this->disconnect(); break; + + case 'getCurrentChannels': + $this->getCurrentChannels(); + break; } } @@ -262,6 +266,12 @@ class Networking extends SystemModule $this->response = $interfaceArray; } + private function getCurrentChannels() + { + exec("iw phy0 info |grep -A 14 Frequencies|grep -v disabled|awk '{gsub(/[][]/,\"\"); print $4}'|awk NF=NF RS= OFS=,",$currentChannels); + $this->response = array("currentChannels" => $currentChannels); + } + private function saveAPConfig() { $config = $this->request->apConfig; diff -Npaur pineapple-new/modules/Networking/js/module.js /pineapple/modules/Networking/js/module.js --- pineapple-new/modules/Networking/js/module.js 2015-12-31 14:08:46.000000000 +0000 +++ /pineapple/modules/Networking/js/module.js 2016-01-16 14:54:13.000000000 +0000 @@ -47,12 +46,12 @@ registerController('NetworkingRouteContr }); $scope.getRoute(); - }]); registerController('NetworkingAccessPointsController', ['$api', '$scope', '$timeout', function($api, $scope, $timeout) { $scope.apConfigurationSaved = false; $scope.apConfigurationError = ""; + $scope.currentChannels=""; $scope.apConfig = { selectedChannel: "1", openSSID: "", @@ -93,6 +92,17 @@ registerController('NetworkingAccessPoin }) }); + $scope.getCurrentChannels = (function() { + $api.request({ + module: "Networking", + action: "getCurrentChannels" + }, function(response) { + $scope.currentChannels = response.currentChannels; + + }) + }); + + $scope.getCurrentChannels(); $scope.getAPConfiguration(); }]); diff -Npaur pineapple-new/modules/Networking/module.html /pineapple/modules/Networking/module.html --- pineapple-new/modules/Networking/module.html 2015-12-31 14:08:46.000000000 +0000 +++ /pineapple/modules/Networking/module.html 2016-01-16 14:54:13.000000000 +0000 @@ -55,9 +55,16 @@ <form class="form-horizontal"> <div class="form-group"> <label class="col-sm-3 control-label">Access Point Channel</label> - <div class="col-sm-5"> + + <div class="form-group"> + <label class="col-sm-2">Available: </label> + <div class="col-sm-7"> + <input type="text" class="form-control" ng-model="currentChannels" disabled> + </div><br><br> + <label class="col-sm-2">Select: </label> + <div class="col-sm-4"> <select class="form-control" ng-model="apConfig['selectedChannel']"> - <option ng-repeat="channel in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]">{{ channel }}</option> + <option ng-repeat="channel in [1,2,3,4,5,6,7,8,9,10,11,12,13,14]">{{ channel }}</option> </select> </div> </div> @@ -265,4 +272,4 @@ </div> </div> </div> -</div> \ No newline at end of file +</div> Edited January 16, 2016 by winter_soldier 1 Quote Link to comment Share on other sites More sharing options...
dustbyter Posted January 17, 2016 Share Posted January 17, 2016 Good opportunity for me to learn how to patch a file. With the patches you have created above with the differences, can you provide an example of how to patch the respective files? Quote Link to comment Share on other sites More sharing options...
winter_soldier Posted January 17, 2016 Author Share Posted January 17, 2016 (edited) patch binary isn't on the pineapple you may have it installed on you linux host (or 'apt-get install build-essetenial' should do it). Hopefully Darren/Seb will mainstream these patches for ease of use? First download the required folder via ssh/scp (for example Configuration): local$ scp -r root@pineapple:/pineapple/modules/Configuration . assuming you copied the configuration patch to config.patch in a directory outside Configuration local$ cd Configuration local$ patch -p1 < ../config.patch (if it borks for whatever reason due to paths) just ensure its the right file e.g.. Configuration/api/module.php Then re-upload the patched binaries back to the pineapple local$ scp -r Configuration root@pineapple:/pineapple/modules/ Edited January 17, 2016 by winter_soldier Quote Link to comment Share on other sites More sharing options...
dustbyter Posted January 17, 2016 Share Posted January 17, 2016 Cool thanks will do!. I don't have my nano yet. So i'm on ubuntu anyways. I'll patch it there and move the updated files when I get it to the pineapple Quote Link to comment Share on other sites More sharing options...
flipflop Posted March 19, 2016 Share Posted March 19, 2016 (edited) Hi, I'm getting following error while patching module.html file: File to patch: module.html patching file module.html Hunk #1 succeeded at 43 (offset 1 line). patch unexpectedly ends in middle of line patch: **** malformed patch at line 142: And no Region-buttons appear under configuration Using Tetra with 1.02 firmware (I believe, the software should be the same for both Nano and Tetra?) Edited March 19, 2016 by flipflop Quote Link to comment Share on other sites More sharing options...
winter_soldier Posted June 22, 2016 Author Share Posted June 22, 2016 Im short on time at the moment, I'll need to look into the tetra to see what the difference is? think someone ordered one in the office, hopefully it will arrive in the next few weeks? else its slaving over a firmware image? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.