kushagharahi / homebridge-dahua-alerts

Routes motion alerts for Dahua and Lorex camera streams to homebridge-camera-ffmpeg
27 stars 13 forks source link

Feature Request: HTTP setting #13

Closed IGx89 closed 3 years ago

IGx89 commented 3 years ago

Hello! First off, thanks a lot for writing this plugin! Just entering the world of surveillance cameras (for my residence) and the existence of this plugin is what convinced me to go with Dahua for my first camera (an N43AJ52-B).

Basic motion alerts work great, however your HTTPS requirement, while understandable, is an unnecessary inconvenience for me. Enabling HTTPS support on my camera turns off HTTP support, and using a self-signed cert makes other web browsers/tools loudly complain and sometimes even not work. Would you be open to adding a setting to your plugin to allow users to switch between HTTP and HTTPS? I've manually done so by editing the raw JS on my Homebridge device (basically changing all "https" text to "http" in dahua.js) so it seems like it would be easy to do.

Not a high priority from my perspective since I have a workaround, but still would be helpful.

kushagharahi commented 3 years ago

Hi, thanks for this report. Flattered that you based your camera purchase on my simple plugin. (Dahua holla at me for the sale kickback plz)

Your usecase makes a lot of sense. I've added optional http support in 1.1.3. Could you please install it and verify it works for you?

IGx89 commented 3 years ago

Haha! :)

Thanks a lot for making this change! I'm running a customized version of your plugin so it's not quite as easy to update and test currently, but I'll do that within the next few days and let you know. I looked over your commit and it looks like it should do the trick. Only change I'd possibly suggest is having it stop disabling TLS validation (NODE_TLS_REJECT_UNAUTHORIZED=0) if useHttp is true -- that appears to disable SSL certificate validation for the entire Homebridge instance.

kushagharahi commented 3 years ago

disabling TLS validation (NODE_TLS_REJECT_UNAUTHORIZED=0) if useHttp is true -- that appears to disable SSL certificate validation for the entire Homebridge instance.

Good catch. I will check to see if you can disable cert validation per request rather than doing it globally again. Otherwise I will make this addition.

Big-IoT-Man commented 3 years ago

have you had any success in terms of enabling cert validation per request as of yet?

ronsidi commented 3 years ago

First of all, thank you for the plugin.

I tried to set useHttp for the same reason described above, yet the plugin still attempts to use https. looking at the code I noticed that in https://github.com/kushagharahi/homebridge-dahua-alerts/blob/master/src/index.ts#L33 the useHttp parameter is not passed: uniqueHosts.set(config.host, {host: config.host, user: config.user, pass: config.pass} as CameraCredentials) Similarly it is not passed when handling per-camera host. Could this be the reason for it not working?

kushagharahi commented 3 years ago

@ronsidi good catch, you're absolutely right! I just pushed up 1.1.5 that fixes that fixes bug where useHttp flag is not set when there are multiple hosts

@Big-IoT-Man 1.1.5 will address disabling cert validation per request so it's no longer globally affecting homebridge

Good catch. I will check to see if you can disable cert validation per request rather than doing it globally again. Otherwise I will make this addition.

@IGx89 The above is done :)

Check it out for me please and let me know if there's any feedback. Thanks!

kushagharahi commented 3 years ago

Closing this issue as it has been fully addressed in 1.1.5. If there are any new bugs, please open a new issue!