Skip to content

Commit

Permalink
Merge pull request #381 from prey/turn-on-wifi-windows
Browse files Browse the repository at this point in the history
Force wifi on and exceptions post fix
  • Loading branch information
javo authored Jun 28, 2018
2 parents 7cca852 + c5379db commit 2b7825a
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 10 deletions.
8 changes: 4 additions & 4 deletions lib/agent/providers/network/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,13 @@ exp.get_active_access_point = function(callback) {
if (callback) ap_callbacks.push(callback);
if (getting_ap) return;

getting_ap = true;
var done = function(err, ap) {
getting_ap = false;
if (!err & ap) active_access_point = ap;
if (ap_callbacks.length >= 1) {
fire_callbacks(err, ap);
}
getting_ap = false;
}

var fire_callbacks = function(err, ap) {
Expand All @@ -111,13 +112,12 @@ exp.get_active_access_point = function(callback) {
});
}

getting_ap = true;
os_functions.get_active_access_point_mac(function(err, ap_mac) {
if (err || !ap_mac)
return callback(err || new Error('No active access point found.'));
return done(err || new Error('No active access point found.'));

exp.get_access_points_list(function(err, aps) {
if (err) return callback(err);
if (err) return done(err);

var padded_mac = ap_mac.toString().trim().replace(/(^|:)(?=[0-9a-fA-F](?::|$))/g, "$10");

Expand Down
Binary file not shown.
Binary file added lib/agent/triggers/auto-connect/bin/wifion.exe
Binary file not shown.
6 changes: 4 additions & 2 deletions lib/agent/triggers/auto-connect/windows.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ var fs = require('fs'),
join = require('path').join,
xml2js = require('xml2js'),
exec = require('child_process').exec,
wifion = join(__dirname, 'bin', 'wifion'),
tmpdir = process.platform == 'win32' ? process.env.WINDIR + '\\Temp' : '/tmp';

var profile_json = {
Expand Down Expand Up @@ -52,8 +53,9 @@ var generate_xml = function(ssid, cb) {
}

exports.enable_wifi = function(cb) {
// To Do: Find a way to turn on wifi on windows
return cb();
exec(wifion, function(err) {
return cb();
});
}

var delete_xml = function(ssid, cb) {
Expand Down
11 changes: 9 additions & 2 deletions lib/agent/triggers/connection/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@ var emitter,
interval_checker;

var get_current_status = function(cb) {
is_online({ retries: 0 })
.then(cb('connected'))
is_online({
timeout: 1000,
retries: 0
})
.then(function() {
cb('connected');
})
.catch(function() {
network.get_connection_status(function(new_status) {
cb(new_status);
Expand All @@ -38,6 +43,7 @@ var check_status = function() {
exports.start = function(opts, cb) {
check_status();
hooks.on('network_state_changed', check_status);
hooks.on('disconnect', network.reset_active_access_point);
// Connection Heartbeat
// todo @lemavri Dinamically change interval from
// 15-60 seconds if status remains. Reset otherwise
Expand All @@ -50,6 +56,7 @@ exports.start = function(opts, cb) {

exports.stop = function(cb) {
hooks.remove('network_state_changed', check_status);
hooks.remove('disconnect');
clearInterval(interval_checker);
if (emitter) {
emitter.removeAllListeners();
Expand Down
2 changes: 1 addition & 1 deletion lib/conf/tasks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ exports.post_install = function(values, cb) {
if (err) return cb(err);

var finished = function() {
log('Sweet! Please run `prey config gui` to finish installation.');
log('Sweet! Please run `prey config panel` or `prey config gui` to link your device.');
return cb && cb();
}
// After the installation success create prey user watcher (on mac's)
Expand Down
3 changes: 2 additions & 1 deletion lib/exceptions.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
var client = require('needle'),
host = 'http://exceptions.preyproject.com';

var opts = {
var opts = {
json: true,
timeout: 4500
};

Expand Down

0 comments on commit 2b7825a

Please sign in to comment.