EliasKotlyar / Xiaomi-Dafang-Hacks

4.19k stars 1k forks source link

Minor source flaws found #1833

Closed centralware closed 1 year ago

centralware commented 1 year ago

I've been having an issue with Wyze v2 and PAN running with ONVIF and for unknown reasons (lack of research on my part - which is what I'm doing right now) the ONVIF service stops running, usually days of uninterrupted service, so I was going to write a watch-dog script for boot time to keep an eye on things and properly terminate and restart vital services should they crash, reboot the device if resources are unrecoverable, etc. and I came across little quirks thus far which likely should be remedied within the repo when time permits:

/system/sdcard/controlscripts/common_functions.sh

Added Suggestions:

DAFANG is an awesome CFW/FW replacement and tiny glitches like those above are well worth the tiny efforts required to put things where they belong; the only real vulnerability I've noticed over the years would be the SD CARD itself and how easily it can become glitched due to its R/W state. A possible fix for this would be to remount SD as Read Only for normal operations and if set up the way we do, the OS is dedicated with the first 256MB to 512MB of the SD card and mmcblk0p2 (vfat) is mounted at DCIM for the remainder of the card where a copy of sdcard/config is double-backed-up, where updates are performed, etc. If blk0p1 were R.O. from the start, this should reduce the risk of OS corruption (config remains vulnerable, but fix-able via backups whereas if partition 1 becomes corrupt, the card needs to be removed and re-flashed.) Even if the entire second partition was un-readable the operating system is still likely to survive and can be recovered. REMOTELY, without a ladder! :^)

Out of 283 v2/PAN cameras we installed/tested in 2022, more than half (156) had to be re-flashed already (at least once) due to power glitches/outages causing card corruption (yellow LED remains lit during boot and hangs.)

It may also be worthwhile to add kernel and tool support for EXT(2) and SYNC.

Again, many kudos and Happy Holidays!

jmtatsch commented 1 year ago

Thanks for tracking those issues down. Could you please do a pull request?

centralware commented 1 year ago

I'll be doing a bit more than a pull; likely after the holidays I should be done as I need some of these changes "live" on my end by year's end. I'll send a link (dafang repo clone) with a list of before/after changes and notes and the DAFANG members can pick and choose what should be implemented globally. (For example, we updated the web interface to include smaller video resolutions (320x180 to name one) to allow a large number of cameras to stream to a single DVR/NVR without hogging up bandwidth... something DAFANG may have no need or interest in if it doesn't affect the global scale of things.) Things we have notes on but HAVE NOT yet implemented... who knows, maybe the DAFANG team may take interest and join in; we'll see!