Push dev work to master #2

Merged
sixteenmillimeter merged 416 commits from dev into master 2018-07-19 15:29:02 +00:00
1 changed files with 26 additions and 24 deletions
Showing only changes of commit 781f6046e5 - Show all commits

View File

@ -17,6 +17,31 @@ let _entry = null
let _ssid = null let _ssid = null
let _cb = null let _cb = null
//helper functions
function parseConfig (str) {
const networks = []
const lines = str.split('\n')
let network = {}
for (let line of lines) {
if (line.indexOf('network={') !== -1) {
network = {}
network.raw = line
} else if (line.indexOf('ssid=') !== -1) {
network.ssid = line.replace('ssid=', '').trim().replace(quoteRe, '')
if (network.raw) {
network.raw += '\n' + line
}
} else if (line.indexOf('}') !== -1) {
network.raw += '\n' + line
networks.push(network)
network = {}
} else if (network.ssid) {
network.raw += '\n' + line
}
}
return networks
}
/** Class representing the wifi features */ /** Class representing the wifi features */
class Wifi { class Wifi {
constructor () { constructor () {
@ -63,7 +88,7 @@ class Wifi {
return _cb(err) return _cb(err)
} }
parsed = this._parseConfig(data) parsed = parseConfig(data)
console.dir(parsed) console.dir(parsed)
console.log(data) console.log(data)
console.log(data.search(networkPattern)) console.log(data.search(networkPattern))
@ -122,29 +147,6 @@ class Wifi {
//this._callback(null, { ssid : ssid, pwd : pwd.length }) //this._callback(null, { ssid : ssid, pwd : pwd.length })
_cb = () => {} _cb = () => {}
} }
_parseConfig (str) {
const networks = []
const lines = str.split('\n')
let network = {}
for (let line of lines) {
if (line.indexOf('network={') !== -1) {
network = {}
network.raw = line
} else if (line.indexOf('ssid=') !== -1) {
network.ssid = line.replace('ssid=', '').trim().replace(quoteRe, '')
if (network.raw) {
network.raw += '\n' + line
}
} else if (line.indexOf('}') !== -1) {
network.raw += '\n' + line
networks.push(network)
network = {}
} else if (network.ssid) {
network.raw += '\n' + line
}
}
return networks
}
/** /**
* Create sanitized wpa_supplicant.conf stanza for * Create sanitized wpa_supplicant.conf stanza for
* configuring wifi without storing plaintext passwords * configuring wifi without storing plaintext passwords