Skip to content
This repository has been archived by the owner on Apr 17, 2020. It is now read-only.

Commit

Permalink
feat: Added -k switch for self signed certificates, cli parameters cl…
Browse files Browse the repository at this point in the history
…eanup (#7)


* added -k switch to use self signed certs w/tls, cleaned up cli parameters (-l logging and -h help)
* changed condition check with more compact code
  • Loading branch information
juzam authored and svrooij committed Jan 1, 2018
1 parent 1919253 commit c247fa3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ Options:
-d, --devices File location of device list (must end with .json).
-g, --password Gateway password (to enable gateway light change)
-h, --help Show help
-l, --logging possiblevalues: "error", "warn","info","debug"
[default: "info"]
-l, --logging Logging level [choices: "error", "warn", "info", "debug"] [default: "info"]
-m, --mqtt mqtt broker url. See https://github.com/svrooij/node-xiaomi2mqtt#mqtt-url
[default: "mqtt://127.0.0.1"]
-k, --insecure accept self singed-certificates when using TLS. See https://github.com/mqttjs/MQTT.js#mqttclientstreambuilder-options
[boolean] [default: false]
-n, --name instance name. used as mqtt client id and as topic prefix
[default: "xiaomi"]
--version Show version number
Expand Down
3 changes: 2 additions & 1 deletion src/bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ function start () {
message: 0,
qos: 0,
retain: true
}
},
rejectUnauthorized = !config.insecure
}

mqttClient = mqtt.connect(config.mqtt, mqttOptions)
Expand Down
8 changes: 7 additions & 1 deletion src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,30 @@ const config = require('yargs')
.describe('d', 'File location of device list (must end with .json).')
.describe('g', 'Gateway password (to enable gateway light change)')
.describe('h', 'Show this help')
.describe('l', 'possiblevalues: "error", "warn","info","debug"')
.describe('l', 'Logging level')
.describe('m', 'mqtt broker url. See https://github.com/mqttjs/MQTT.js#connect-using-a-url')
.describe('k', 'accept self singed-certificates when using TLS. See https://github.com/mqttjs/MQTT.js#mqttclientstreambuilder-options')
.describe('n', 'instance name. used as mqtt client id and as topic prefix')
.boolean('k')
.alias({
d: 'devices',
g: 'password',
h: 'help',
l: 'logging',
m: 'mqtt',
k: 'insecure',
n: 'name'
})
.choices('l', ['error', 'warn', 'info', 'debug'])
.default({
l: 'info',
m: 'mqtt://127.0.0.1',
k: false,
n: 'xiaomi'
})
.version()
.help('help')
.wrap(null)
.argv

module.exports = config

0 comments on commit c247fa3

Please sign in to comment.