Push dev work to master #2
|
@ -125,13 +125,17 @@ class Wifi {
|
|||
*/
|
||||
_createPSK (ssid, pwd, callback) {
|
||||
const cmd = `wpa_passphrase "${ssid}" "${pwd}" | grep "psk="`
|
||||
let output
|
||||
let lines
|
||||
let hash
|
||||
let plaintext
|
||||
exec(cmd, (err, stdout, stderr) => {
|
||||
if (err) {
|
||||
return callback(err)
|
||||
}
|
||||
output = stdout.replace('#psk=', '').split('psk=')[1]
|
||||
callback(null, output.trim())
|
||||
lines = stdout.replace('#psk=', '').split('psk=')
|
||||
hash = lines[1]
|
||||
plaintext = lines[0]
|
||||
callback(null, hash.trim(), plaintext.trim())
|
||||
})
|
||||
}
|
||||
/**
|
||||
|
@ -139,10 +143,13 @@ class Wifi {
|
|||
*
|
||||
* @param {string} ssid SSID of network to configure
|
||||
* @param {string} pwd Password of access point, plaintext
|
||||
* @param {string} hash Password/SSID of access point, securely hashed
|
||||
* @param {function} callback Function invoked after process is complete, or fails
|
||||
*/
|
||||
setNetwork (ssid, pwd, callback) {
|
||||
_entry = `network={\n\tssid="${ssid}"\n\tpsk="${pwd}"\n}\n`
|
||||
setNetwork (ssid, pwd, hash, callback) {
|
||||
let masked = pwd.split('').map(char => { return '*' }).join('')
|
||||
console.log(pwd + ' vs. ' + masked)
|
||||
_entry = `network={\n\tssid="${ssid}"\n\t#psk=${masked}\n\tpsk=${hash}\n}\n`
|
||||
_cb = callback
|
||||
_ssid = ssid
|
||||
fs.readFile(filePath, 'utf8', this._readConfigCb)
|
||||
|
|
Loading…
Reference in New Issue