Browse files

DHCP works now

  • Loading branch information...
1 parent 9930865 commit 1d5df7ac6a29b4fa3d7f6f01f38fe395e7ab96fe @tlhunter committed Jun 24, 2012
Showing with 49 additions and 29 deletions.
  1. +37 −15 README.md
  2. +1 −1 app.js
  3. +11 −13 node_modules/wireless/index.js
View
52 README.md
@@ -38,28 +38,50 @@ Current Status
=
Currently, enabling/disabling adapter works, finding new networks will trigger events,
-able to read encryption method and other data, and disappearing networks trigger events.
+able to read encryption method and other data, and disappearing networks trigger events,
+able to enable and disable dhcp.
$ node app.js
[PROGRESS] Enabling wireless card...
[PROGRESS] Wireless card enabled.
[PROGRESS] Starting wireless scan...
[PROGRESS] Wireless scanning has commenced.
- [ APPEAR] nucleocide [00:18:F8:75:60:80] 81% -53 dBm NONE
- [ APPEAR] dOpsInternal [00:0C:41:36:A3:F6] 100% -34 dBm WPA
- [ APPEAR] ArborMesh [62:3D:28:71:4F:79] 81% -53 dBm NONE
- [ APPEAR] Zen Buddhist Temple Public [F8:D1:11:47:EE:4A] 77% -56 dBm NONE
- [ APPEAR] Zen Buddhist Temple Private [FA:D1:11:47:EE:4B] 67% -63 dBm WPA2
- [ APPEAR] AHOPS [00:23:A2:DE:4A:B0] 57% -70 dBm WPA&WPA2
- [ APPEAR] ArborMesh [0A:B3:85:5F:45:99] 100% -5 dBm NONE
- [ APPEAR] Zen Buddhist Temple Public [00:27:22:14:DB:84] 82% -52 dBm NONE
- [ APPEAR] Zen Buddhist Temple Private [02:27:22:14:DB:85] 100% -5 dBm WPA2
- [ APPEAR] 2WIRE163 [00:1F:B3:6B:97:D9] 78% -55 dBm WEP
- Yay, we connected! I will try to disconnect in 20 seconds.
- [ JOIN] nucleocide [00:18:F8:75:60:80]
- 20 seconds are up, gonna try to disconnect now.
- [ LEAVE] Left the network
+ [ APPEAR] Zen Buddhist Temple Public [00:27:22:14:DB:84] 64% -65 dBm NONE
+ [ APPEAR] ArborMesh-ch1 [0A:B3:85:5F:45:99] 62% -66 dBm NONE
+ [ APPEAR] AHOPS [00:23:A2:DE:4A:B0] 100% -14 dBm WPA&WPA2
+ [ APPEAR] ArborMesh [62:3D:28:71:4F:79] 100% -28 dBm NONE
+ [ APPEAR] dOpsInternal [00:0C:41:36:A3:F6] 100% -25 dBm WPA
+ [ APPEAR] Zen Buddhist Temple Public [F8:D1:11:47:EE:4A] 100% -17 dBm NONE
+ [ APPEAR] Zen Buddhist Temple Private [FA:D1:11:47:EE:4B] 100% -28 dBm WPA2
+ [ APPEAR] Zen Buddhist Temple Public [F8:D1:11:54:A9:DE] 100% -23 dBm NONE
+ [ APPEAR] Zen Buddhist Temple Private [FA:D1:11:54:A9:DF] 91% -46 dBm WPA2
[ APPEAR] ATT200 [CC:7D:37:81:0F:20] 68% -62 dBm WPA&WPA2
+ Yay, we connected! I will try to get an IP.
+ [ JOIN] Zen Buddhist Temple Public [00:27:22:14:DB:84]
+ [ DHCP] Leased IP 10.88.0.58
+ Yay, I got an IP address (10.88.0.58)! I'm going to disconnect in 20 seconds.
+ [ LEVELS] Zen Buddhist Temple Public
+ [ LEVELS] ArborMesh-ch1
+ [ LEVELS] AHOPS
+ [ LEVELS] ArborMesh
+ [ LEVELS] dOpsInternal
+ [ LEVELS] Zen Buddhist Temple Public
+ [ LEVELS] Zen Buddhist Temple Private
+ [ LEVELS] Zen Buddhist Temple Public
+ [ LEVELS] ATT200
+ 20 seconds are up! Attempting to turn off DHCP...
+ DHCP has been turned off. Leaving the network...
+ [ LEAVE] Left the network
+ [ LEVELS] Zen Buddhist Temple Public
+ [ LEVELS] ArborMesh-ch1
+ [ LEVELS] AHOPS
+ [ LEVELS] ArborMesh
+ [ LEVELS] dOpsInternal
+ [ LEVELS] Zen Buddhist Temple Public
+ [ LEVELS] Zen Buddhist Temple Public
+ [ APPEAR] Zen Buddhist Temple Private [02:27:22:14:DB:85] 100% -20 dBm WPA2
+ [ LEVELS] Zen Buddhist Temple Private
+ [ APPEAR] 2WIRE163 [00:1F:B3:6B:97:D9] 75% -57 dBm WEP
^C[PROGRESS] Gracefully shutting down from SIGINT (Ctrl+C)
[PROGRESS] Disabling Adapter...
[PROGRESS] Stopping Wireless App...
View
2 app.js
@@ -47,7 +47,7 @@ wireless.on('appear', function(error, network) {
if (!connectedToMyHome && network.ssid == 'Zen Buddhist Temple Public') {
connectedToMyHome = true;
- wireless.join(network, 'pineapple', function() {
+ wireless.join(network, '', function() {
console.log("Yay, we connected! I will try to get an IP.");
wireless.dhcp(network, function(ip_address) {
console.log("Yay, I got an IP address (" + ip_address + ")! I'm going to disconnect in 20 seconds.");
View
24 node_modules/wireless/index.js
@@ -50,8 +50,8 @@ var Wireless = function() {
metric: 'sudo ifconfig :INTERFACE metric :METRIC',
connect_wep: 'sudo iwconfig :INTERFACE essid ":ESSID" key :PASSWORD',
- connect_wpa: 'sudo wpa_passphrase :ESSID :PASSWORD > wpa-temp.conf && sudo wpa_supplicant -D wext -i :INTERFACE -c wpa-temp.conf && rm wpa-temp.conf',
- connect_open: 'sudo iwconfig :INTERFACE essid :ESSID',
+ connect_wpa: 'sudo wpa_passphrase ":ESSID" :PASSWORD > wpa-temp.conf && sudo wpa_supplicant -D wext -i :INTERFACE -c wpa-temp.conf && rm wpa-temp.conf',
+ connect_open: 'sudo iwconfig :INTERFACE essid ":ESSID"',
},
translated: {}
};
@@ -141,15 +141,16 @@ var Wireless = function() {
throw err;
}
- if (stderr) {
- self.emit('error', false, "There was an error enabling dhcp" + stdout + stderr);
- }
-
- var lines = scanResults.split(/\r\n|\r|\n/);
+ // Command output is over stderr :'(
+ var lines = stderr.split(/\r\n|\r|\n/);
var ip_address = null;
+ var temp = null;
_.each(lines, function(line) {
- ip_address = line.match(/leased (\b(?:\d{1,3}\.){3}\d{1,3}\b) for [0-9]+ seconds/)[0];
+ temp = line.match(/leased (\b(?:\d{1,3}\.){3}\d{1,3}\b) for [0-9]+ seconds/);
+ if (temp) {
+ ip_address = temp[1];
+ }
});
if (ip_address) {
@@ -171,10 +172,6 @@ var Wireless = function() {
throw err;
}
- if (stderr) {
- self.emit('error', false, "There was an error disabling dhcp" + stdout + stderr);
- }
-
if (callback) {
callback();
}
@@ -432,7 +429,8 @@ var Wireless = function() {
self.emit('debug', false, command);
exec(command, function(err, stdout, stderr) {
if (err || stderr) {
- self.emit('error', false, "Shit is broken TODO");
+ self.emit('error', false, "There was an error joining an open network");
+ console.log(err, stderr);
if (callback_failure) {
callback_failure();
}

0 comments on commit 1d5df7a

Please sign in to comment.