tsi index problem once process is restarted

Bug report
I run 1.3.2 with tsi engine enabled on windows and index is built as expected. but once the process is killed and restarted, it report below failure and write does not success.  the log says:
[I] 2017-08-31T05:58:56Z write failed for shard 2: [shard 2] truncate D:\Data\influxdb\data\kensho\autogen\2\index\L0-00000021.tsl: Access is denied. service=write
[I] 2017-08-31T05:58:56Z write failed for shard 2: [shard 2] truncate D:\Data\influxdb\data\kensho\autogen\2\index\L0-00000021.tsl: Access is denied. service=write
I always run the process with administrator account. and this always happen to me, not sure why.

I tried out with latest version 1.3.5, but no luck. the same failure and same logs. I tested it with a new environment, still the same.

hmm, it seems odd that you can't access the file if you're running as an administrator. What are the file permissions on the tsl files?

It is full control with all permissions on the index file. Is it possible the issue is not about permission? and what does truncate mean in this context, maybe the truncate file action has problem on windows somehow?

A truncate() shrinks or grows a file to a specified size. From this [SO thread][https://stackoverflow.com/questions/25534857/truncating-open-os-file-access-denied) it looks like files may need to be closed before truncating on Windows. However, the only place we truncate in TSI is when opening and not when writing. I can try to add that fix and see if it helps though.

Thanks! maybe you can add more detailed logs to show the error code when file error happened, thus we can track what happened if error show up again.


Add linkText to campaign creatives

Campaign creative edit/create:

Material collect list:

Material collect "preview"

Creative breakdown report:

 Add "Link Text" field to Native-X campaigns


custom path for lldb-vscode in Debug code-lens for tests

Is it possible to specify the path to the LLDB-vscode binary? I searched the docs and also this repo and the lldb-vscode repo to no avail.
Any call to the debug code-lens on tests comes back with lldb-vscode not found. Please install lldb. I installed llvm via Homebrew and the binary can be found at /usr/local/opt/llvm/bin/lldb-vscode.

It might be worth adding it to PATH, so it works everywhere.

Thanks for the quick reply. I am usually able to configure the path, but I'm also OK with extending my PATH
Would you symlink the binary itself it to somewhere like /usr/local/bin or would you add /usr/local/opt/llvm/bin/ to PATH?

It doesn't matter, try whichever you prefer so you don't get surprised next time you look for it (assuming you're relatively consistent about these things).
By the way, I don't think we invoke lldb-vscode (I don't even know what it does). Doesn't vadimcn.vscode-lldb already package it?

I am not in vscode, but in neovim so I can't install vadimcn.vscode-lldb, that's why I installed lldb-vscode via Homebrew.

How does it work? Who runs lldb-vscode?

I assume that rust-analyzer does that, I am just invoking the code-lens from the neovim built-in lsp-client

Rust-analyzer doesn't invoke a debugger. It tells an existing debugger extension to start a debugging session for the given executable. Do you have a debugger extension installed?

I'm lost. I don't know how to answer your question. I don't have any debug extension installed. Is there anything I can do? Is the debugger only supported in vscode?

The Code extension looks for a couple of known debugger extensions and nudges them when required. rust-analyzer doesn't do anything else for debugging.
If your setup is working, I guess that's fine. If not, you can look into a Vim debugging extension.

it works after adding it to my PATH

Out of curiosity, can you grep -Rn lldb-vscode ~/.config/nvim? And I suppose we can close this?

comes back empty :(

thanks ya'll for your help 😊


doc: expand system call documentation

This gives more detail on how system calls with large argument
lists, or large return value types should be handled.
Signed-off-by: Andrew Boie<EMAIL_ADDRESS>

Note to reviewers: is the technique of using 'volatile' the best way to ensure that argument values are really copied out of the struct?

addressed @dbkinder comments, thanks for reviewing


Can InfluxDB IOx publish its line_protocol parser using the influxdb_line_protocol name?

@Hakuyume 👋  -- Thank you
Hi, I work for InfluxData and I am trying to publish the (rust) implementation of the line protocol parser we built for InfluxDB IOx (see https://github.com/influxdata/influxdb_iox/issues/7051)
However, you appear to own the crate named https://crates.io/crates/influxdb_line_protocol and this project hasn't progressed
Would it be possible to let me publish the InfluxDB IOx line_protocol parser using the influxdb_line_protocol name? What do you think?
Thank you for your consideration

I am positive about releasing the crates.io's entry. I don't use the crate now and plan any updates.
Could you tell me the username on crates.io? I will add you as a new owner.

@alamb I've sent an invitation on crates.io. After you accept the invitation, I'll remove myself.

@alamb I've sent an invitation on crates.io. After you accept the invitation, I'll remove myself.

Thank you @Hakuyume  -- I have done so

Thank you. I removed myself.


Material UI v5 TextField component causes Jest test to fail

Duplicates

[X] I have searched the existing issues

Latest version

[X] I have tested the latest version

Current behavior 😯
I recently upgraded from Material UI v4 to v5. It seems there is some kind of incompatibility with my Jest tests since now I get the following error when attempting to render a TextField. The test runs fine if I use the component from MUI v4. The component renders fine when viewing the page in the browser.
Error: Uncaught [TypeError: Cannot read properties of undefined (reading ‘setAttribute’)]
at reportException (/home/node_modules/jest-config/node_modules/jsdom/lib/jsdom/living/helpers/runtime-script-errors.js:66:24)
at innerInvokeEventListeners (/home/node_modules/jest-config/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:341:9)
at invokeEventListeners (/home/node_modules/jest-config/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:274:3)
at HTMLUnknownElementImpl._dispatch (/home/node_modules/jest-config/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:221:9)
at HTMLUnknownElementImpl.dispatchEvent (/home/node_modules/jest-config/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:94:17)
at HTMLUnknownElement.dispatchEvent (/home/node_modules/jest-config/node_modules/jsdom/lib/jsdom/living/generated/EventTarget.js:231:34)
at Object.invokeGuardedCallbackDev (/home/node_modules/react-dom/cjs/react-dom.development.js:4210:16)
at invokeGuardedCallback (/home/node_modules/react-dom/cjs/react-dom.development.js:4274:31)
at reportUncaughtErrorInDEV (/home/node_modules/react-dom/cjs/react-dom.development.js:22737:5)
at captureCommitPhaseError (/home/node_modules/react-dom/cjs/react-dom.development.js:27078:5) TypeError: Cannot read properties of undefined (reading ‘setAttribute’)
at /home/node_modules/@emotion/react/dist/emotion-react.cjs.dev.js:206:12
console.error
The above error occurred in the  component:
at /home/node_modules/@emotion/react/dist/emotion-element-e89f38a3.cjs.dev.js:64:23
at GlobalStyles (/home/node_modules/@mui/styled-engine/node/GlobalStyles/GlobalStyles.js:28:5)
at GlobalStyles
at InputBase (/home/node_modules/@mui/material/node/InputBase/InputBase.js:251:44)
at OutlinedInput (/home/node_modules/@mui/material/node/OutlinedInput/OutlinedInput.js:135:44)
at div
at /home/node_modules/@emotion/react/dist/emotion-element-e89f38a3.cjs.dev.js:64:23
at FormControl (/home/node_modules/@mui/material/node/FormControl/FormControl.js:111:44)
at /home/node_modules/@emotion/react/dist/emotion-element-e89f38a3.cjs.dev.js:64:23
at TextField (/home/node_modules/@mui/material/node/TextField/TextField.js:107:44)
at div
at /home/node_modules/@emotion/react/dist/emotion-element-e89f38a3.cjs.dev.js:64:23
at Box (/home/node_modules/@mui/system/createBox.js:41:41)
at div
at /home/node_modules/@emotion/react/dist/emotion-element-e89f38a3.cjs.dev.js:64:23
at Box (/home/node_modules/@mui/system/createBox.js:41:41)
at form
at CreateNewCVForm (/home/src/project/sciencv/static/sciencv/js/index/CreateNewCVForm.js:16:41)
at div
at /home/node_modules/@emotion/react/dist/emotion-element-e89f38a3.cjs.dev.js:64:23
at Box (/home/node_modules/@mui/system/createBox.js:41:41)
at div
at /home/node_modules/@emotion/react/dist/emotion-element-e89f38a3.cjs.dev.js:64:23
at CVListPage (/home/src/project/sciencv/static/sciencv/js/CVListPage.js:77:

Expected behavior 🤔
Jest tests are able to render a TextField component.
Steps to reproduce 🕹
Steps:

Context 🔦
Here is what I have in package.json
"devDependencies": {
"@babel/core": "^7.16.0",
"@babel/plugin-proposal-class-properties": "^7.16.0",
"@babel/plugin-proposal-optional-chaining": "^7.16.0",
"@babel/plugin-proposal-private-methods": "^7.16.0",
"@babel/plugin-transform-react-jsx": "^7.16.0",
"@babel/plugin-transform-react-jsx-self": "^7.16.0",
"@babel/preset-env": "^7.16.4",
"@babel/preset-react": "^7.16.0",
"@emotion/react": "^11.9.0",
"@emotion/styled": "^11.8.1",
"@mui/icons-material": "^5.8.3",
"@mui/lab": "^5.0.0-alpha.83",
"@mui/material": "^5.8.1",
"@mui/styles": "^5.8.0",
"@testing-library/jest-dom": "^5.16.4",
"@testing-library/react": "^13.3.0",
"axios": "^0.21.4",
"babel-eslint": "^10.1.0",
"babel-loader": "^8.2.3",
"clean-webpack-plugin": "^2.0.1",
"clone": "^2.1",
"css-loader": "^2.1.1",
"cssnano": "^4.1.10",
"date-fns": "^2.28.0",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.15.0",
"eslint-config-standard": "^14.1.1",
"eslint-loader": "^3.0.4",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.3.1",
"eslint-plugin-standard": "^4.1.0",
"file-loader": "^4.2.0",
"jest": "^27.3.1",
"jest-teamcity-reporter": "^0.9.0",
"loglevel": "^1.7.1",
"marked": "^1.2.9",
"mini-css-extract-plugin": "^0.5.0",
"optimize-css-assets-webpack-plugin": "^5.0.1",
"prettier": "^2.4.1",
"react": "^18.1.0",
"react-dom": "^18.1.0",
"react-test-renderer": "^18.1.0",
"reactstrap": "^8.10.1",
"regenerator-runtime": "^0.13.9",
"resolve-url-loader": "^3.1.2",
"sass": "^1.43.4",
"terser-webpack-plugin": "^1.4.3",
"url-loader": "^3.0.0",
"webpack": "^4.46.0",
"webpack-bundle-tracker": "^0.4.3",
"webpack-cli": "^3.3.11",
"webpack-merge": "^4.2.1"
}
Your environment 🌎

npx @mui/envinfo
  System:
    OS: Linux 3.10 CentOS Linux 7 (Core)
  Binaries:
    Node: 16.13.2 - /opt/nodejs/16/bin/node
    Yarn: Not Found
    npm: 8.1.2 - /opt/nodejs/16/bin/npm
  Browsers:
    Chrome: Not Found
    Firefox: 98.0
  npmPackages:
    @emotion/react: ^11.9.0 => 11.9.0
    @emotion/styled: ^11.8.1 => 11.8.1
    @mui/base:  5.0.0-alpha.82
    @mui/icons-material: ^5.8.3 => 5.8.3
    @mui/lab: ^5.0.0-alpha.83 => 5.0.0-alpha.85
    @mui/material: ^5.8.1 => 5.8.1
    @mui/private-theming:  5.8.0
    @mui/styled-engine:  5.8.0
    @mui/styles: ^5.8.0 => 5.8.0
    @mui/system:  5.8.3
    @mui/types:  7.1.3
    @mui/utils:  5.8.0
    @mui/x-date-pickers:  5.0.0-alpha.1
    @types/react:  17.0.6
    react: ^18.1.0 => 18.1.0
    react-dom: ^18.1.0 => 18.1.0

Can you please set up an example repro with the failing tests. It is not clear what could cause the issue with the test just from seeing the description of the issue.

Ok I think I have a better idea about what is causing this issue now, which is related to some custom code I have.  I have this spy that overrides the implementation for retrieving the value of a CRSF token, and seems like that is conflicting another part of the code from one of the libraries.
jest.spyOn(document, 'querySelector')...
Sorry to waste your time but appreciate your response!


optimize in-memory transaction store

What
Increasing the transaction retention window would increase the memory utilization.
This optimization helps to reduce that.
Why
Storing the expanded go-XDR in memory could be a memory hog compared to encoded XDR.
Known limitations
The additional encoding during ingestion would slow down the ingestion ( a bit ).
This is a tradeoff in CPU & ingestion time vs memory utilization.
Memory Consumption

Branch
Transaction Count
Memory

main
10,000,000
22.7 GB

current
10,000,000
8.8 GB

The transaction count of 10M was selected since it aligns with the expected daily transaction volume of 500 transactions per ledger /w roughly 20,000 transactions per day ( 4.32 seconds / ledger )

Two minor things, otherwise LGTM


Support for iMou devices (DAHUA based)

Is there chance of this working with imou Ranger 2 cameras, which are based on DAHUA  IPC-A22EP?

My guess is I need to implement this https://github.com/rroller/dahua/issues/4 and it'll work.
I don't have the hardware to test with so it makes implementing it a little difficult. I'll try to buy one of these cameras soon to test with.

Greatly appreciate it!

Hi,
I have cameras model IPC-A22E (Imou Ranger2) and another IPC-C22EP-IMOU (Imou Cue2). I have tried adding them and neither of the two models works but I want to try to do more tests and activate the debug mode that you mention in the readme.md. If you need me to try something to test the cameras, do not hesitate to let me know.

@gelokatil that would be the same issue as https://github.com/rroller/dahua/issues/4
I'm buying one of those cameras this week so I can build in support for it. Not sure how long shipping will take, but hopefully not to long.

I'm buying one of those cameras this week so I can build in support for it. Not sure how long shipping will take, but hopefully not to long.

I also have two iMou Ranger 2 IPC-A22E cameras. With the windows app Smart PSS can be controlled locally, even the PTZ. When configuring, the program uses port 37777.
If you need us to do any testing, here we are.
Thanks for everything!

I just ordered this. It’ll arrive Monday and I’ll try to get it working ASAP.
https://www.amazon.com/dp/B08RD2C67R

I'am not able to connect to a IPC-HFW2100P. Is it the same issue?
br,
PJ

@paalj69 I'm not sure.

The hardware arrived today. I hope to test it out soon. Will report back as soon as I know more.

I have an Imou Ranger 2 (IPC-A22E) too!
Let me know if there a fix/hack/trick to let it work, specially if I can use PTZ controls (so I can control the camera from Home Assistant)

Just have a imou Ranger Pro which new version  having 2K,  is it similar with the imou ranger 2?

@inevity probably the same API.
Just a heads up, I finally got this device hooked up so now I can start hacking away :)
I'll continue to keep you posted. Sorry for the delays!

OK this is going to take some work. This camera uses the RPC2 API (which is better because it's json based). The other cameras support the same RPC2 API but the way I coded this integration up was with the REST API. I'll have to either build a translation layer or switch to the RPC2 API (it'll just take some time). I'll see what I can do.

OK this is going to take some work. This camera uses the RPC2 API (which is better because it's json based). The other cameras support the same RPC2 API but the way I coded this integration up was with the REST API. I'll have to either build a translation layer or switch to the RPC2 API (it'll just take some time). I'll see what I can do.

Ok rroller, thanks in advance for all your work

OK this is going to take some work. This camera uses the RPC2 API (which is better because it's json based). The other cameras support the same RPC2 API but the way I coded this integration up was with the REST API. I'll have to either build a translation layer or switch to the RPC2 API (it'll just take some time). I'll see what I can do.

Thank you for the work you are doing.
I don't think it's very useful, but with the ConfigTool app, which is inside the ToolBox app, you can change the image settings, like switching the compression of the main video to H264, making it compatible with HA, the bitrate, resolution etc ...
https://www.imoulife.com/support/downloadCenter/tools

Just to keep everyone posted, I've started to write the first bit of code for this. Nowhere near done, but at least it's a start 😆

I have the basic commands working with the RPC2 API (login, logout, get device details). This works great for all my Dahua cameras but it still doesn't work for the iMou camera. It will require more digging to understand what's going on.

As far as I can tell, these cameras do not have an HTTP API. Unfortunately you have to connect over a socket and send the commands according to their protocol as seen here https://github.com/mcw0/PoC/blob/master/Dahua-3DES-IMOU-PoC.py
That's going to be very painful to implement and to get right.

I doubt this will help at all... but I just released 0.8.13 which uses the rpc2 API during the config flow. Can some of you try with the latest 0.8.13 release to see if you get further along when trying to add an iMou camera? I really doubt it will help, but I'd like to rule it out.

Hi, I've tested with IPC-A22E and IPC-C22EP-IMOU and gives on both this error message.
Could not connect to Dahua device
Traceback (most recent call last):
File "/config/custom_components/dahua/config_flow.py", line 194, in _test_credentials
data = await client2.get_machine_name()
File "/config/custom_components/dahua/client.py", line 93, in get_machine_name
return await self.get(url)
File "/config/custom_components/dahua/client.py", line 528, in get
raise exception
File "/config/custom_components/dahua/client.py", line 516, in get
response = await auth.request("GET", url)
File "/config/custom_components/dahua/digest.py", line 46, in request
response = await self.session.request(method, url, headers=headers, **kwargs)
File "/usr/local/lib/python3.8/site-packages/aiohttp/client.py", line 544, in _request
await resp.start(conn)
File "/usr/local/lib/python3.8/site-packages/aiohttp/client_reqrep.py", line 890, in start
message, payload = await self._protocol.read()  # type: ignore
File "/usr/local/lib/python3.8/site-packages/aiohttp/streams.py", line 604, in read
await self._waiter
aiohttp.client_exceptions.ServerDisconnectedError: Server disconnected

Imou Ranger 2
(IPC-A22E)
Logger: custom_components.dahua
Source: custom_components/dahua/client.py:524
Integration: Dahua (documentation, issues)
First occurred: 10:46:42 (1 occurrences)
Last logged: 10:46:42
TimeoutError fetching information from http://<IP_ADDRESS>:80/cgi-bin/magicBox.cgi?action=getMachineName -
:(
I already use this camera in HA with a standard onvif config, but I have a lot of lag and no PTZ (so I can't control the camera), just image.
Should I log out from the ONVIF config before I try this Dahua integration? Not sure

Nevermind, i've got the same result with or without the ONVIF integration

As far as I can tell, these cameras do not have an HTTP API. Unfortunately you have to connect over a socket and send the commands according to their protocol as seen here https://github.com/mcw0/PoC/blob/master/Dahua-3DES-IMOU-PoC.py
That's going to be very painful to implement and to get right.

Hello rroller,
Maybe this is wasting time but I have been playing with the code you have named and I have successfully managed to connect to my camera through the IMOU cloud, passing it as the camera serial parameter. I'm not a programmer at all, but maybe the part of the code that authenticates to the cloud could be redirected to the local IP of the camera instead of going through their cloud.
I have achieved it with this command passing the camera serial as a parameter.
python3 dahua_3des.py --dhp2p XXXXXXXXXXXX -dd

@gelokatil thanks. We don't want to use the cloud here and would like to stay completely local. I should have mentioned this before... the local username is admin and the local password is the "safety code" on the bottom on the camera. You'll also need to figure out the local IP address.
With the mcw0 tools I was able to restart the device which means everything we want to do is doable, but it's doing all of this over socket communication. Writing a client for that is very tedious

@mabusdogma that's the same that I'm getting. It's because the Dahua integration is trying to speak HTTP to an API that doesn't understand HTTP so the iMou device just hangs waiting for the right header bytes. If I send the right bytes over a socket I can make progress but it's going to take me awhile to really write something that works and to fully understand the protocol based on @mcw0's work (and hope that the API isn't different from Dahua's HTTP api). Right now this is going to be low on my list of things to do as I want to build in more support for native Dahua cams.

Guys, thanks for "alerting" in the post, please let me know how I could help you out.
FYI, I mostly use Dahua undocumented API, not the same as their official CGI API.

Guys, thanks for "alerting" in the post, please let me know how I could help you out.
FYI, I mostly use Dahua undocumented API, not the same as their official CGI API.

By the way, the undocumented API I am mostly using working 99.9% with both HTTP/HTTPS and DHIP (DHIP, what I guess you refer as socket), and 2nd, I do have few IMOU devices that I testing/playing with )

Whoaaa the legend respond :-) amazing work you’ve done with figuring out these APIs.
Can you point me to an example you might have where you use http? I couldn’t get it to work.

Whoaaa the legend responded :-) amazing work you’ve done with figuring out these APIs.
Can you point me to an example you might have where you use http? I couldn’t get it to work.

Well, firstly, thanks and I don't think I am legend, just doing research for fun and NO profit.
Basically, the undocumented JSON API I am using with the DHIP protocol do just work fine fine with normal HTTP/HTTPS as well. I have HTTP/HTTPS  implemented in my next version of the script.
Although, there is few tricks to get it working with the "Console", and to give some working examples would make to much work, so I would suggest to wait until i release next version of the script.
However, one thing that's very important to get the "Console" and other "events" to work, is the subscribe to "stream" for events and other stuff.
def open_stream(self, session_id):
    """Open stream session for events and other 'client.Notify'"""
    self.stream = self.remote.get(
        '{}/SubscribeNotify.cgi?sessionId={}'.format(self.uri, session_id),
        verify=False, allow_redirects=False, stream=True
    )

def recv_stream(self):
    """Return events and other 'client.Notify'"""
    return fix_json(self.stream.raw.readline().decode('utf-8'))

Wish I could release the script now, but I have still too much work with other parts of script...

Sounds great! Now we have two legends! (and a lot of beta testers) working on it :)
Let us now if we can help some way, and thanks a lot!

2021-07-06 14:52:36 WARNING (MainThread) [custom_components.dahua] Could not connect to Dahua device via the RPC2 API, falling back to cgi
2021-07-06 14:52:41 ERROR (MainThread) [custom_components.dahua] TimeoutError fetching information from http://<IP_ADDRESS>:80/cgi-bin/magicBox.cgi?action=getMachineName
So now must dive into @mcw0 's DHIP api or https API.

I have 5 of these and would absolutely buy you guys a lot of beers/coffees if you can make Imou Ranger 2 work with HA.
You have one more beta tester.
P.S: Do you guys have a buymeacoffee.com link or is there a way to contribute finally?

Whoaaa the legend responded :-) amazing work you’ve done with figuring out these APIs.
Can you point me to an example you might have where you use http? I couldn’t get it to work.

I know it's kinda unfair to ask an ETA for an open source software like this, but could you still give us a ball park estimate? Days, Weeks, Months?

P.S: Do you guys have a buymeacoffee.com link or is there a way to contribute finally?

@sagarspatil personally I'm not in this for money and don't want anything at all. I just want to help others and help the home automation world :D
I think we just need to wait for @mcw0 script to be released and then take it from there.

P.S: Do you guys have a buymeacoffee.com link or is there a way to contribute finally?

@sagarspatil personally I'm not in this for money and don't want anything at all. I just want to help others and help the home automation world :D
I think we just need to wait for @mcw0 script to be released and then take it from there.

You are so kind. Thank you for all your efforts. Please let us know if we can help in anyway.

P.S: Do you guys have a buymeacoffee.com link or is there a way to contribute finally?

@sagarspatil personally I'm not in this for money and don't want anything at all. I just want to help others and help the home automation world :D
I think we just need to wait for @mcw0 script to be released and then take it from there.

Do my script work in any way with your devices?
DHIP/JSON for instance? (you should be able to use other port than TCP/5000, normally TCP/80 works too)
DVRIP/JSON? (mostly only work on TCP/37777, but few do actually work on TCP/80 && 5000 too)
If JSON works, I could share my HTTP/HTTPS code that do work with JSON with you.
Best, bashis

P.S: Do you guys have a buymeacoffee.com link or is there a way to contribute finally?

@sagarspatil personally I'm not in this for money and don't want anything at all. I just want to help others and help the home automation world :D
I think we just need to wait for @mcw0 script to be released and then take it from there.

Do my script work in any way with your devices?
DHIP/JSON for instance? (you should be able to use other port than TCP/5000, normally TCP/80 works too)
DVRIP/JSON? (mostly only work on TCP/37777, but few do actually work on TCP/80 && 5000 too)
If JSON works, I could share my HTTP/HTTPS code that do work with JSON with you.
Best, bashis

Btw, do you have any local access to those devices? What ports is open? You have web GUI?
Maybe my IMOU are more flexible in that sense as i have full HTTP access and DHIP/DVRIP to them.
I know some other "Dahua" devices are based on huawei and has not full "set of features".

@mcw0 I do have local access to the device. In Imou life app, there's a tool called Lan Live. It lists all the cameras with local IP, example <IP_ADDRESS>. When i click on a particular camera, it shows the port as 37777 and asks for username and password.
Picture
http://imgur.com/gallery/5sfNab4
https://imgur.com/gallery/0eVPkLd

@mcw0 I do have local access to the device. In Imou life app, there's a tool called Lan Live. It lists all the cameras with local IP, example <IP_ADDRESS>. When i click on a particular camera, it shows the port as 37777 and asks for username and password.
Picture
http://imgur.com/gallery/5sfNab4
https://imgur.com/gallery/0eVPkLd

Cool, that's Dahua old protocol DVRIP, may (or should) use some JSON after the legacy DVRIP login.
What ports do you have open on the device? (could you make a NMAP scan of 1-65535?)
Can you do HTTP/HTTPS Web to the device?

Sure. On it. Give me a couple of minutes.

@mcw0
`Scanning <IP_ADDRESS> [65535 ports]
Discovered open port 80/tcp on <IP_ADDRESS>
Discovered open port 554/tcp on <IP_ADDRESS>
Discovered open port 37777/tcp on <IP_ADDRESS>
Discovered open port 8086/tcp on <IP_ADDRESS>
Completed SYN Stealth Scan at 21:15, 12.06s elapsed (65535 total ports)`

Port 80: 404 - Not Found
Port 554: ERR_UNSAFE_PORT
Port 37777: Keeps loading, no response
Port 8086: Keeps loading, no response

@mcw0
Scanning <IP_ADDRESS> [65535 ports]

Discovered open port 80/tcp on <IP_ADDRESS>

Discovered open port 554/tcp on <IP_ADDRESS>

Discovered open port 37777/tcp on <IP_ADDRESS>

Discovered open port 8086/tcp on <IP_ADDRESS>

Completed SYN Stealth Scan at 21:15, 12.06s elapsed (65535 total ports)

Cool, HTTP, RTSP and DVRIP (TCP/8086 is interesting, seen that on mine too, but not figured yet)
Wow, 404 on port 80 :o - That is weird, you should have WEB GUI on that one.
Does my script work on port 80 with 'dhip'?
(DVRIP TCP/37777 with the script should work, maybe not get the fully Console, but at least login.. etc.)

Does my script work on port 80 with 'dhip'?
(DVRIP TCP/37777 with the script should work, maybe not get the fully Console, but at least login.. etc.)
@mcw0 Could you tell me the exact steps I need to take?
I tried to run the python script directly without any modification but it gave me this error
Traceback (most recent call last):
  File "C:\Users\sagar\Downloads\dahua.py", line 101, in <module>
    import resource
ModuleNotFoundError: No module named 'resource'

@sagarspatil
$ pip install resource
(do that on all missing modules)

This is strange...
C:\Users\sagar\Downloads>pip install resource
Requirement already satisfied: resource in c:\users\sagar\appdata\local\programs\python\python39\lib\site-packages (0.2.1)
Requirement already satisfied: python-easyconfig>=0.1.0 in c:\users\sagar\appdata\local\programs\python\python39\lib\site-packages (from resource) (0.1.7)
Requirement already satisfied: JsonSir>=0.0.2 in c:\users\sagar\appdata\local\programs\python\python39\lib\site-packages (from resource) (0.0.2)
Requirement already satisfied: JsonForm>=0.0.2 in c:\users\sagar\appdata\local\programs\python\python39\lib\site-packages (from resource) (0.0.2)
Requirement already satisfied: jsonschema in c:\users\sagar\appdata\local\programs\python\python39\lib\site-packages (from JsonForm>=0.0.2->resource) (2.6.0)
Requirement already satisfied: PyYAML in c:\users\sagar\appdata\local\programs\python\python39\lib\site-packages (from python-easyconfig>=0.1.0->resource) (5.4.1)
Requirement already satisfied: six in c:\users\sagar\appdata\local\programs\python\python39\lib\site-packages (from python-easyconfig>=0.1.0->resource) (1.16.0)

C:\Users\sagar\Downloads>python dahua.py
Traceback (most recent call last):
  File "C:\Users\sagar\Downloads\dahua.py", line 101, in <module>
    import resource
ModuleNotFoundError: No module named 'resource'

ok, comment out: import resource (# import resource) - you will not be able to use "memory" in "Console#"
But that doesn't matter, just debug stuff for me anyhow

https://stackoverflow.com/questions/37710848/importerror-no-module-named-resource
I'm trying to run it on Ubuntu. Give me 2 mins.

P.S: Do you guys have a buymeacoffee.com link or is there a way to contribute finally?

@sagarspatil personally I'm not in this for money and don't want anything at all. I just want to help others and help the home automation world :D
I think we just need to wait for @mcw0 script to be released and then take it from there.

Do my script work in any way with your devices?
DHIP/JSON for instance? (you should be able to use other port than TCP/5000, normally TCP/80 works too)
DVRIP/JSON? (mostly only work on TCP/37777, but few do actually work on TCP/80 && 5000 too)
If JSON works, I could share my HTTP/HTTPS code that do work with JSON with you.
Best, bashis

Hi Bashis,
Like @sagarspatil , I have two IPC-C22E model cameras and two more IPC-A22E models. In both, I can successfully connect with your Dahua-JSON-Debug-Console-v2.py script, although some bugs appear when executing some commands, but data is obtained in some of them.
[] [Dahua JSON Debug Console 2019-2021 bashis ]
[+] Opening connection to <IP_ADDRESS> on port 37777: Done
[-] Dahua JSON Console: Attach Console failed, using local only
[+] Login: Success
[+] keepAlive thread: Started
[] Remote Model: IPC-A22E, Class: IPC, Time: 2021-07-08 17:28:20
[Console] # help
[*] Local cmd:
[+] certificate: Dump some information of remote certificate
[+] config: remote config (-h for params)
[+] console: console instance handling (-h for params)
[+] debug: debug instance (-h for params)
[+] device: Dump some information of remote device
[+] dhp2p: Dump some information of dhp2p
[+] diag: Interim Remote Diagnose (-h for params)
[+] door: open door (-h for params)
[+] events: Subscribe on events from eventManager (-h for params)
[+] fuzz: fuzz service methods (-h for params)
[+] ldiscover: Device Discovery from this script (-h for params)
[+] log: Log stuff (-h for params)
[+] network: Network stuff (-h for params)
[+] memory: Used memeory of this script (-h for params)
[+] pcap: pcap in remote device (-h for params)
[+] rdiscover: Device Discovery from remote device (-h for params)
[+] service: List remote services and "methods" (-h for params)
[+] sshd: Start / Stop (-h for params)
[+] setDebug: Should start produce output from Console in VTO / VTH
[+] telnet: Start / Stop (-h for params)
[+] test-config: New config test (-h for params)
[+] uboot: U-Boot Environment Variables (-h for params)
[+] "quit": "quit" active instance "quit all" to quit from all
[+] "reboot": "reboot" active instance "reboot all" to reboot all
[+] REBOOT: Try force reboot of remote
[+] TEST: TEST function (-h for params)
[Console] # device
[+] [System]
Vendor: Lechange, Build: 2020-07-30 19:17:25, Version: 2.680.0000000.9.R
Device: IPC-A22P-S2, Web: <IP_ADDRESS>284, OEM: 0000000
Package: LC_IPC-Consumer-Hai-Edison_Eng_P
Traceback (most recent call last):
File "Dahua-JSON-Debug-Console-v2.py", line 6720, in
status = DebugConsole ()
File "Dahua-JSON-Debug-Console-v2.py", line 740, in init
self.MainConsole ()
File "Dahua-JSON-Debug-Console-v2.py", line 1334, in MainConsole
exec (tmp)
File "", line 1, in
File "Dahua-JSON-Debug-Console-v2.py", line 4162, in GetRemoteInfo
self.devStorage ()
File "Dahua-JSON-Debug-Console-v2.py", line 4022, in devStorage
self.InstanceService (methodName, params = {"name": Device}, start = True)
File "Dahua-JSON-Debug-Console-v2.py", line 3110, in InstanceService
if not self.CheckForService (methodName):
File "Dahua-JSON-Debug-Console-v2.py", line 2875, in CheckForService
if not len (self.RemoteServicesCache):
TypeError: object of type 'bool' has no len ()
Regards

@mcw0
[*] [Dahua JSON Debug Console 2019-2021 bashis ]
[+] Opening connection to <IP_ADDRESS> on port 37777: Done
[+] Login: Success
[BEGIN SEND (<IP_ADDRESS>)] <------------------2259------------------>
a0010000|00000000|00000000|00000000|00000000|00000000|05020101|0000a1aa
[ END  SEND (<IP_ADDRESS>)] <------------------2259------------------>
[BEGIN RECV (<IP_ADDRESS>)] <------------------2379------------------>
b0000068|36000000|010e0100|00000000|00000000|01000000|0600f900|00000002
[ END  RECV (<IP_ADDRESS>)] <------------------2379------------------>
[BEGIN SEND (<IP_ADDRESS>)] <------------------2259------------------>
a0050000|47000000|00000000|00000000|00000000|00000000|05020008|0000a1aa
admin&&C59D83158CB3AA27657D19D075A3E9A5BB264C1BAFA037D65AE9D45E3B2A83FE
[ END  SEND (<IP_ADDRESS>)] <------------------2259------------------>
[BEGIN RECV (<IP_ADDRESS>)] <------------------2365------------------>
b0000068|00000000|00080100|33000000|33040000|01000000|0600f900|00000002
[ END  RECV (<IP_ADDRESS>)] <------------------2365------------------>
[BEGIN SEND (<IP_ADDRESS>)] <------------------2259------------------>
f6000000|34010000|05000000|00000000|34010000|00000000|33040000|00000000
{"id": 5, "method": "system.multicall", "params": [{"method": "magicBox.getDeviceType", "params": null, "session": 1075, "id": 2}, {"method": "magicBox.getDeviceClass", "params": null, "session": 1075, "id": 3}, {"method": "global.getCurrentTime", "params": null, "session": 1075, "id": 4}], "session": 1075}
[ END  SEND (<IP_ADDRESS>)] <------------------2259------------------>
[BEGIN RECV (<IP_ADDRESS>)] <------------------2379------------------>
f6000068|d2000000|05000000|00000000|d2000000|00000000|33040000|00000000
{"result":true,"params":[{"result":true,"id":2,"params":{"type":"IPC-A22E"}},{"result":true,"id":3,"params":{"type":"IPC"}},{"result":true,"id":4,"params":{"time":"2021-07-08 22:11:38"}}],"id":5,"session":1075}
[ END  RECV (<IP_ADDRESS>)] <------------------2379------------------>
[] Remote Model: IPC-A22E, Class: IPC, Time: 2021-07-08 22:11:38
[BEGIN SEND (<IP_ADDRESS>)] <------------------2259------------------>
f6000000|4a000000|06000000|00000000|4a000000|00000000|33040000|00000000
{"method": "system.listService", "session": 1075, "params": null, "id": 6}
[ END  SEND (<IP_ADDRESS>)] <------------------2259------------------>
[BEGIN RECV (<IP_ADDRESS>)] <------------------2379------------------>
f6000068|5f000000|06000000|00000000|5f000000|00000000|33040000|00000000
{"result":false,"error":{"code":268632064,"message":"InterfaceNotFound"},"id":6,"session":1075}
[ END  RECV (<IP_ADDRESS>)] <------------------2379------------------>
[BEGIN SEND (<IP_ADDRESS>)] <------------------2259------------------>
f6000000|45000000|07000000|00000000|45000000|00000000|33040000|00000000
{"method": "global.logout", "params": null, "session": 1075, "id": 7}
[ END  SEND (<IP_ADDRESS>)] <------------------2259------------------>
[BEGIN RECV (<IP_ADDRESS>)] <------------------2379------------------>
f6000068|33000000|07000000|00000000|33000000|00000000|33040000|00000000
{"result":true,"params":null,"id":7,"session":1075}
[ END  RECV (<IP_ADDRESS>)] <------------------2379------------------>
[+] Logout
[] Closed connection to <IP_ADDRESS> port 37777
[*] All done
[+] Successful instance termination of IPC-A22E (<IP_ADDRESS>)
Does this help?

Port 80. DHIP.
[*] [Dahua JSON Debug Console 2019-2021 bashis <mcw noemail eu>]
[+] Opening connection to <IP_ADDRESS> on port 80: Done
[+] Login: Success
[BEGIN SEND (<IP_ADDRESS>)] <------------------2259------------------>
20000000|44484950|00000000|00000000|b8000000|00000000|b8000000|00000000
{"id": 0, "method": "global.login", "params": {"clientType": "", "ipAddr": "<IP_ADDRESS>", "loginType": "Direct", "password": "", "userName": "admin", "Encryption": "None"}, "session": 0}
[ END  SEND (<IP_ADDRESS>)] <------------------2259------------------>
[BEGIN RECV (<IP_ADDRESS>)] <------------------2379------------------>
20000000|44484950|8d6d04ab|00000000|eb000000|00000000|eb000000|00000000
{"result":false,"params":{"realm":"Login to 907F3C6C73FEDA77","random":"1f1e4fbc-858a-47c8-8a50-cb9310ad48cb","encryption":"Default"},"error":{"code":268632079,"message":"Component error: login challenge!"},"id":0,"session":2869194125}
[ END  RECV (<IP_ADDRESS>)] <------------------2379------------------>
[BEGIN SEND (<IP_ADDRESS>)] <------------------2259------------------>
20000000|44484950|8d6d04ab|01000000|17010000|00000000|17010000|00000000
{"id": 1, "method": "global.login", "params": {"userName": "admin", "password": "9E44A9BF0C9D7F1AD639190D1CBD7B4A", "clientType": "", "ipAddr": "<IP_ADDRESS>", "loginType": "Direct", "authorityInfo": "", "authorityType": "Default", "passwordType": "Default"}, "session":<PHONE_NUMBER>}
[ END  SEND (<IP_ADDRESS>)] <------------------2259------------------>
[BEGIN RECV (<IP_ADDRESS>)] <------------------2379------------------>
20000000|44484950|8d6d04ab|01000000|4d000000|00000000|4d000000|00000000
{"result":true,"params":{"keepAliveInterval":30},"id":1,"session":2869194125}
[ END  RECV (<IP_ADDRESS>)] <------------------2379------------------>
[BEGIN SEND (<IP_ADDRESS>)] <------------------2259------------------>
20000000|44484950|8d6d04ab|05000000|4c010000|00000000|4c010000|00000000
{"id": 5, "method": "system.multicall", "params": [{"method": "magicBox.getDeviceType", "params": null, "session":<PHONE_NUMBER>, "id": 2}, {"method": "magicBox.getDeviceClass", "params": null, "session":<PHONE_NUMBER>, "id": 3}, {"method": "global.getCurrentTime", "params": null, "session":<PHONE_NUMBER>, "id": 4}], "session":<PHONE_NUMBER>}
[ END  SEND (<IP_ADDRESS>)] <------------------2259------------------>
[BEGIN RECV (<IP_ADDRESS>)] <------------------2379------------------>
20000000|44484950|8d6d04ab|05000000|d8000000|00000000|d8000000|00000000
{"result":true,"params":[{"result":true,"id":2,"params":{"type":"IPC-A22E"}},{"result":true,"id":3,"params":{"type":"IPC"}},{"result":true,"id":4,"params":{"time":"2021-07-08 22:13:15"}}],"id":5,"session":2869194125}
[ END  RECV (<IP_ADDRESS>)] <------------------2379------------------>
[*] Remote Model: IPC-A22E, Class: IPC, Time: 2021-07-08 22:13:15
[BEGIN SEND (<IP_ADDRESS>)] <------------------2259------------------>
20000000|44484950|8d6d04ab|06000000|50000000|00000000|50000000|00000000
{"method": "system.listService", "session":<PHONE_NUMBER>, "params": null, "id": 6}
[ END  SEND (<IP_ADDRESS>)] <------------------2259------------------>
[BEGIN RECV (<IP_ADDRESS>)] <------------------2379------------------>
20000000|44484950|8d6d04ab|06000000|65000000|00000000|65000000|00000000
{"result":false,"error":{"code":268632064,"message":"InterfaceNotFound"},"id":6,"session":2869194125}
[ END  RECV (<IP_ADDRESS>)] <------------------2379------------------>
[BEGIN SEND (<IP_ADDRESS>)] <------------------2259------------------>
20000000|44484950|8d6d04ab|07000000|4b000000|00000000|4b000000|00000000
{"method": "global.logout", "params": null, "session":<PHONE_NUMBER>, "id": 7}
[ END  SEND (<IP_ADDRESS>)] <------------------2259------------------>
[BEGIN RECV (<IP_ADDRESS>)] <------------------2379------------------>
20000000|44484950|8d6d04ab|07000000|39000000|00000000|39000000|00000000
{"result":true,"params":null,"id":7,"session":2869194125}
[ END  RECV (<IP_ADDRESS>)] <------------------2379------------------>
[+] Logout
[*] Closed connection to <IP_ADDRESS> port 80
[*] All done
[+] Successful instance termination of IPC-A22E (<IP_ADDRESS>)

@gelokatil

Remote Model: IPC-A22E, Class: IPC, Time: 2021-07-08 17:28:20
This tells me JSON do work

same with this:
[Console] # device
[+] [System]
Vendor: Lechange, Build: 2020-07-30 19:17:25, Version: 2.680.0000000.9.R
Device: IPC-A22P-S2, Web: <IP_ADDRESS>284, OEM: 0000000
Package: LC_IPC-Consumer-Hai-Edison_Eng_P
However, your crash are most probably something made by me while trying to parse incoming JSON.
I can also see you are able to attach to the "Console", however you do not get any output from the "builtin Coonsole", only my stuff.
You could try with the command:  setDebug:
(This is needed for VTH and VTO before giving some output)

Port 80. DHIP.

Cool!
DHIP working, so HTTP/HTTPS with JSON should work just fine as well.
Below you find the raw HTTP/HTTPS part of my next script. Trying/working on to split up stuff to get better overview and functionality.
Beware, will not just work out of the box, just to give some ideas before I am done with other parts of my script.
@rroller @sagarspatil @gelokatil (et all)
Hope it will help you out in someway...

from requests import packages
from requests.packages import urllib3
from requests.packages.urllib3 import exceptions
class DahuaHttp(object):
def del(self):
log.info('DahuaHttp DELETE')
""" Dahua http """
def __init__(self, rhost, rport, proto, timeout=60):
    super(DahuaHttp, self).__init__()

    self.rhost = rhost
    self.rport = rport
    self.proto = proto
    self.timeout = timeout

    self.remote = None
    self.uri = None
    self.stream = None

    """ Most devices will use self-signed certificates, suppress any warnings """
    requests.packages.urllib3.disable_warnings(requests.packages.urllib3.exceptions.InsecureRequestWarning)

    self.remote = requests.Session()

    """Used with _debug"""
    self.headers = self.remote.headers
    self.cookies = self.remote.cookies

    self._init_uri()

    import random as random_agent
    random_agent.seed(1)
    self.remote.headers.update({
        'User-Agent': useragents.random(),
        'X-Requested-With': 'XMLHttpRequest',
        'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
        'Accept': 'application/json, text/javascript, */*; q=0.01',
        'Accept-Language': 'en-US,en;q=0.9',
        'Host': '{}:{}'.format(self.rhost, self.rport),
    })
    """
    self.remote.proxies.update({
        # 'http': 'http://<IP_ADDRESS>:8080',
    })
    """

def send(self, url=None, query_args=None, login=False, timeout=5):

    """JSON API communication"""
    if query_args:
        if query_args.get('params') is not None and not len(query_args.get('params')):
            query_args.update({'params': None})

    """This weird code will try automatically switch between http/https
    and update Host
    """
    try:
        if url and not query_args:
            return self.get(url, timeout)
        else:
            dh_data = self.post(self._get_url(login, url), query_args, timeout)
    except requests.exceptions.ConnectionError:
        self.proto = 'https' if self.proto == 'http' else 'https'
        self._init_uri()
        try:
            if url and not query_args:
                return self.get(url, timeout)
            else:
                dh_data = self.post(self._get_url(login, url), query_args, timeout)
        except requests.exceptions.ConnectionError as e:
            if login:
                return self._error(dh_error=e)
            return None
    except requests.exceptions.RequestException as e:
        if login:
            return self._error(dh_error=e)
        return None
    except KeyboardInterrupt:
        return None

    """302 when requesting http on https enabled device"""
    if dh_data.status_code == 302:
        redirect = dh_data.headers.get('Location')
        self.uri = redirect[:redirect.rfind('/')]
        self._update_host()
        if url and not query_args:
            return self.get(url, timeout)
        else:
            dh_data = self.post(self._get_url(login, url), query_args, timeout)

    """Catch non dahua hosts"""
    if not dh_data.status_code == 200:
        return self._error(dh_error=dh_data.text, code=dh_data.status_code)

    """JSON API communication"""
    dh_json = dh_data.json()

    """Set SessionID Cookie during login"""
    if login and self.remote.cookies.get('DWebClientSessionID') is None:
        self.remote.cookies.set('username', query_args.get('params').get('userName'))
        self.remote.cookies.set('DWebClientSessionID', dh_json.get('session'))

    return dh_data

@staticmethod
def _get_url(login, url):
    if login:
        return '/RPC2_Login'
    elif url:
        """GET or other POST JSON API communication"""
        return url
    """Default JSON API communication"""
    return '/RPC2'

def _update_host(self):
    if not self.remote.headers.get('Host') == self.uri[self.uri.rfind('://') + 3:]:
        self.remote.headers.update({
            'Host': self.uri[self.uri.rfind('://') + 3:],
        })

def _init_uri(self):
    self.uri = '{proto}://{rhost}:{rport}'.format(proto=self.proto, rhost=self.rhost, rport=str(self.rport))

@staticmethod
def _error(dh_error=None, code=500):
    """Keep 'login' happy and give some info back in case of failure"""
    return json.dumps({'result': False, 'error': {'code': code, 'message': str(dh_error)}})

def options(self):
    timeout = 10
    req = requests.Request('OPTIONS', 'rtsp://{host}:{port}?proto=Onvif RTSP/1.1\r\nCSeq: 1\r\n\r\n'.format(
        host='<IP_ADDRESS>', port=80))
    print(req.prepare())
    print(req.url)
    dh_data = self.remote.send(req.url, verify=False, allow_redirects=False, timeout=timeout)
    print(dh_data)

def post(self, url, query_args, timeout):
    """JSON API Communication"""
    return self.remote.post(self.uri + url, json=query_args, verify=False, allow_redirects=False, timeout=timeout)

def get(self, url, timeout):
    """Non JSON Communication"""
    return self.remote.get(self.uri + url, verify=False, allow_redirects=False, timeout=timeout)

def open_stream(self, session_id):
    """Open stream session for events and other 'client.Notify'"""
    self.stream = self.remote.get(
        '{}/SubscribeNotify.cgi?sessionId={}'.format(self.uri, session_id),
        verify=False, allow_redirects=False, stream=True
    )

def recv_stream(self):
    """Return events and other 'client.Notify'"""
    return fix_json(self.stream.raw.readline().decode('utf-8'))

@staticmethod
def can_recv():
    """We do not expect unexpected data
    the 'stream' above will handle that"""
    return False

@staticmethod
def connected():
    # TODO: Assume connected, should find a way to check
    return True

def close(self):
    # TODO: Not really sure if this way
    self.remote.close()
    return True

@mcw0 You are a rockstar.  We in this thread, owe you our firstborn.
 I already have two (what I know of) =]

Share is care, enjoy! )

Now we wait for @rroller to work his magic :D

I can also see you are able to attach to the "Console", however you do not get any output from the "builtin Coonsole", only my stuff.

Sorry dude, I just now saw you are not able to attach to the "Console" ([-] Dahua JSON Console: Attach Console failed, using local only)

TypeError: object of type 'bool' has no len()

Interesting,  FYI, you need to have valid username/password to get my script to work, what I could see from your dumps, you don't except this, and there is a crash in the script as I am parsing things wrongly, do not belong to @rroller work. Please report to my stuff here

you need to have valid username/password to get my script to work,

Now once fix the no len() error, can enter into the local console. so what is next job to do to hack?

Now once fix the no len() error, can enter into the local console. so what is next job to do to hack?

With the message in your first attempt: "Dahua JSON Console: Attach Console failed, using local only"
Same issue as with NVR's, the "console" are not available... unfortunately.

Same issue as with NVR's, the "console" are not available... unfortunately.

So next should we focus the socket layer to reverse?

@rroller Any update on this? Is there any way we can help?

Port 80. DHIP.

Cool!
DHIP working, so HTTP/HTTPS with JSON should work just fine as well.
Below you find the raw HTTP/HTTPS part of my next script. Trying/working on to split up stuff to get better overview and functionality.
Beware, will not just work out of the box, just to give some ideas before I am done with other parts of my script.
@rroller @sagarspatil @gelokatil (et all)
Hope it will help you out in someway...
from requests import packages
from requests.packages import urllib3
from requests.packages.urllib3 import exceptions
class DahuaHttp(object):
def del(self):
log.info('DahuaHttp DELETE')
""" Dahua http """
def __init__(self, rhost, rport, proto, timeout=60):
    super(DahuaHttp, self).__init__()

    self.rhost = rhost
    self.rport = rport
    self.proto = proto
    self.timeout = timeout

    self.remote = None
    self.uri = None
    self.stream = None

    """ Most devices will use self-signed certificates, suppress any warnings """
    requests.packages.urllib3.disable_warnings(requests.packages.urllib3.exceptions.InsecureRequestWarning)

    self.remote = requests.Session()

    """Used with _debug"""
    self.headers = self.remote.headers
    self.cookies = self.remote.cookies

    self._init_uri()

    import random as random_agent
    random_agent.seed(1)
    self.remote.headers.update({
        'User-Agent': useragents.random(),
        'X-Requested-With': 'XMLHttpRequest',
        'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
        'Accept': 'application/json, text/javascript, */*; q=0.01',
        'Accept-Language': 'en-US,en;q=0.9',
        'Host': '{}:{}'.format(self.rhost, self.rport),
    })
    """
    self.remote.proxies.update({
        # 'http': 'http://<IP_ADDRESS>:8080',
    })
    """

def send(self, url=None, query_args=None, login=False, timeout=5):

    """JSON API communication"""
    if query_args:
        if query_args.get('params') is not None and not len(query_args.get('params')):
            query_args.update({'params': None})

    """This weird code will try automatically switch between http/https
    and update Host
    """
    try:
        if url and not query_args:
            return self.get(url, timeout)
        else:
            dh_data = self.post(self._get_url(login, url), query_args, timeout)
    except requests.exceptions.ConnectionError:
        self.proto = 'https' if self.proto == 'http' else 'https'
        self._init_uri()
        try:
            if url and not query_args:
                return self.get(url, timeout)
            else:
                dh_data = self.post(self._get_url(login, url), query_args, timeout)
        except requests.exceptions.ConnectionError as e:
            if login:
                return self._error(dh_error=e)
            return None
    except requests.exceptions.RequestException as e:
        if login:
            return self._error(dh_error=e)
        return None
    except KeyboardInterrupt:
        return None

    """302 when requesting http on https enabled device"""
    if dh_data.status_code == 302:
        redirect = dh_data.headers.get('Location')
        self.uri = redirect[:redirect.rfind('/')]
        self._update_host()
        if url and not query_args:
            return self.get(url, timeout)
        else:
            dh_data = self.post(self._get_url(login, url), query_args, timeout)

    """Catch non dahua hosts"""
    if not dh_data.status_code == 200:
        return self._error(dh_error=dh_data.text, code=dh_data.status_code)

    """JSON API communication"""
    dh_json = dh_data.json()

    """Set SessionID Cookie during login"""
    if login and self.remote.cookies.get('DWebClientSessionID') is None:
        self.remote.cookies.set('username', query_args.get('params').get('userName'))
        self.remote.cookies.set('DWebClientSessionID', dh_json.get('session'))

    return dh_data

@staticmethod
def _get_url(login, url):
    if login:
        return '/RPC2_Login'
    elif url:
        """GET or other POST JSON API communication"""
        return url
    """Default JSON API communication"""
    return '/RPC2'

def _update_host(self):
    if not self.remote.headers.get('Host') == self.uri[self.uri.rfind('://') + 3:]:
        self.remote.headers.update({
            'Host': self.uri[self.uri.rfind('://') + 3:],
        })

def _init_uri(self):
    self.uri = '{proto}://{rhost}:{rport}'.format(proto=self.proto, rhost=self.rhost, rport=str(self.rport))

@staticmethod
def _error(dh_error=None, code=500):
    """Keep 'login' happy and give some info back in case of failure"""
    return json.dumps({'result': False, 'error': {'code': code, 'message': str(dh_error)}})

def options(self):
    timeout = 10
    req = requests.Request('OPTIONS', 'rtsp://{host}:{port}?proto=Onvif RTSP/1.1\r\nCSeq: 1\r\n\r\n'.format(
        host='<IP_ADDRESS>', port=80))
    print(req.prepare())
    print(req.url)
    dh_data = self.remote.send(req.url, verify=False, allow_redirects=False, timeout=timeout)
    print(dh_data)

def post(self, url, query_args, timeout):
    """JSON API Communication"""
    return self.remote.post(self.uri + url, json=query_args, verify=False, allow_redirects=False, timeout=timeout)

def get(self, url, timeout):
    """Non JSON Communication"""
    return self.remote.get(self.uri + url, verify=False, allow_redirects=False, timeout=timeout)

def open_stream(self, session_id):
    """Open stream session for events and other 'client.Notify'"""
    self.stream = self.remote.get(
        '{}/SubscribeNotify.cgi?sessionId={}'.format(self.uri, session_id),
        verify=False, allow_redirects=False, stream=True
    )

def recv_stream(self):
    """Return events and other 'client.Notify'"""
    return fix_json(self.stream.raw.readline().decode('utf-8'))

@staticmethod
def can_recv():
    """We do not expect unexpected data
    the 'stream' above will handle that"""
    return False

@staticmethod
def connected():
    # TODO: Assume connected, should find a way to check
    return True

def close(self):
    # TODO: Not really sure if this way
    self.remote.close()
    return True

Have you by any chance published an updated script that will help @rroller build support for Imou Ranger 2 cameras?

@sagarspatil no I haven't had any time to work on this lately.  Once I get free time I will

@sagarspatil no I haven't had any time to work on this lately. Once I get free time I will

No worries. Thank you for taking the time to respond.

@mcw0
Have you by any chance published an updated script that will help @rroller build support for Imou Ranger 2 cameras?

No, sorry, currently on holiday, I'm not happy yet with my new rewrite yet and I also expect to release two 0day in September/October that should be included in the next version of the script.

Hi guys, I have a Imou ranger 2 4MP (Other name of device: Imou A1 4MP). Can i help and check things out?

I presume the code that is in the works will also apply for the Imou Bullet 2E (IPC-F42FP)?
This crappy software is a real bummer, after my great experiences with the VTO 2202 doorbell from Dahua it feels like this software and code is in every way inferior.

@rroller Any update on this kind sir

No I'm very sorry. It's not an easy problem to solve and I don't have much time right now.

No I'm very sorry. It's not an easy problem to solve and I don't have much time right now.

No worries. Thanks for responding. I appreciate it.

I am also looking forward to this implementation. Happy to be beta tester as well. Thanks everyone for working on this.

@rroller Do you have any plans to support this camera in future? If not, could you let us know, I think, in that case, I’ll just upgrade my cameras.

I’m also waiting for this integration but I understand that having free time is not easy, and I don’t have the knowledge to do it, So I think I’ll  ended up buying one of cameras that are already integrated

I too would love integration for the ranger 2

Same with IMOU F22FP. Any new temporary solution?

Thank you for the hard work on this guys, I see the same issue on an imou IPC- F22AP. Hoping to see through this one !👍🏽
https://www.imoulife.com/public/asset/files/QSG-IPC-F22A_(PoE).pdf

After all, i dont know how to use wrapper... Need a guide on read me ._.

If it can help:
IMOU CUE 2C
$ nmap <IP_ADDRESS>
Starting Nmap 7.80 ( https://nmap.org ) at 2022-01-18 23:41 CET
Nmap scan report for NOMI-IPC-C22C.station (<IP_ADDRESS>)
Host is up (0.0052s latency).
Not shown: 997 closed ports
PORT     STATE SERVICE
80/tcp   open  http
554/tcp  open  rtsp
8086/tcp open  d-s-n
./Console.py --auth admin:xxxxx --rhost <IP_ADDRESS> --proto dvrip --rport 80
[!] Pwntools does not support 32-bit Python.  Use a 64-bit release.
[] [Dahua Debug Console 2019-2021 bashis ]
[] logon type "default" with proto "dvrip" at <IP_ADDRESS>:80
[+] Opening connection to <IP_ADDRESS> on port 80: Done
[-] Dahua Debug Console: Attach Console failed, using local only
[+] Login: Success
[+] keepAlive thread: Started
[] [Active Users]
<EMAIL_ADDRESS>since 2022-01-18 23:29:45 with "DVRIP" (Id: 1)
<EMAIL_ADDRESS>since 2022-01-18 22:28:02 with "DVRIP" (Id: 2)
[] Remote Model: IPC-C22C, Class: IPC, Time: 2022-01-18 23:29:45
[Console]# device
[+] [System]
Vendor: Lechange, Build: 2021-12-18 16:35:21, Version: 2.680.0000000.22.R
Device: IPC-C22C, Web: 2.4, OEM: 0000000
Package: (null)
[+] [Encrypt Info]
Asymmetric: RSA, Cipher: AES; RPAC, Padding: (null), RSA Exp.: 010001
RSA Modulus:
[ ... ]
-----BEGIN PUBLIC KEY-----
[ ... ]
-----END PUBLIC KEY-----
[Console]# console
[*] Console: dh0, Device: IPC-C22C (<IP_ADDRESS>) Active
[Console]# ldiscover dhip <IP_ADDRESS>
[+] dh_discover response from: <IP_ADDRESS>:37810
{
"mac": "b4:4c:3b:90:f7:f4",
"method": "client.notifyDevInfo",
"params": {
"deviceInfo": {
"AlarmInputChannels": 0,
"AlarmOutputChannels": 0,
"DeviceClass": "IPC",
"DeviceType": "IPC-C22C",
"HttpPort": 80,
"Port3": 80,
"Port": 37777,
"UnLoginFuncMask": 1,
"IPv4Address": {
"DefaultGateway": "<IP_ADDRESS>",
"DhcpEnable": true,
"IPAddress": "<IP_ADDRESS>",
"SubnetMask": "<IP_ADDRESS>"
},
"MachineName": "7J052D0PAZEAB79",
"Manufacturer": "Private",
"RemoteVideoInputChannels": 0,
"SerialNo": "7J052D0PAZEAB33",
"DeviceID": "",
"Vendor": "Lechange",
"Version": "2.680.0000000.22.R",
"VideoInputChannels": 1,
"VideoOutputChannels": 0,
"Init": 1158,
"Find": "BC",
"FindVersion": 1,
"CountryCode": "DE"
}
}
}
It works also with DHIP protocol, no access to 37777 port.
Same parameters (ip, login, pw, 80, 544) to DAHUA integration: Username, Password, or Address is wrong.
Error in HA log:
2022-01-18 23:28:59 ERROR (MainThread) [custom_components.dahua] TimeoutError fetching information from http://<IP_ADDRESS>:80/cgi-bin/magicBox.cgi?action=getMachineName -
2022-01-18 23:29:09 ERROR (MainThread) [custom_components.dahua] TimeoutError fetching information from http://<IP_ADDRESS>:80/cgi-bin/magicBox.cgi?action=getSystemInfo -
2022-01-18 23:44:16 ERROR (MainThread) [custom_components.dahua] Could not connect to Dahua device. For iMou devices see https://github.com/rroller/dahua/issues/6
Traceback (most recent call last):
File "/home/homeassistant/.homeassistant/custom_components/dahua/config_flow.py", line 179, in _test_credentials
data.update(serial)
AttributeError: 'NoneType' object has no attribute 'update'

Please, add support for IMOU IPC-F22 Bullet 2C (router see it like NOMI-IPC-F22; ONVIF integration also writes it like IPC-F22
Lechange, it works but there are no alerts).
DAHUA integration via HACS responds with "Username, Password, or Address is wrong"

There are news, on implementation of Imou Ranger 2 IPC-A22E?

My attempt connection IMOU Cruiser 4MP:
$ python3 Console.py --auth admin:XXXXXXXX --rhost 192.168.179.ZZZ --proto dvrip --rport 80
/usr/local/lib/python3.5/dist-packages/OpenSSL/crypto.py:14: CryptographyDeprecationWarning: Python 3.5 support will be dropped in the next release of cryptography. Please upgrade your Python.
from cryptography import utils, x509
[] [Dahua Debug Console 2019-2021 bashis ]
[] logon type "default" with proto "dvrip" at 192.168.179.ZZZ:80
[+] Opening connection to 192.168.179.ZZZ on port 80: Done
[-] Dahua Debug Console: Failed
[-] Login: Realm
[p2p] while len(dh_data) TypeError("the JSON object must be str, not 'bytes'",)
b'Realm:Login to YYYYYYYYYYYYYYYY\r\nRandom:1386202155d\r\n\r\n'
[] All done
[] Closed connection to 192.168.179.ZZZ port 80
$ nmap 192.168.179.ZZZ
Starting Nmap 7.40 ( https://nmap.org ) at 2022-02-17 20:46 CET
Nmap scan report for 192.168.179.ZZZ
Host is up (0.0039s latency).
Not shown: 996 closed ports
PORT     STATE    SERVICE
53/tcp   filtered domain
80/tcp   open     http
554/tcp  open     rtsp
8086/tcp open     d-s-n
Nmap done: 1 IP address (1 host up) scanned in 22.73 seconds
On ports 8086 I also get no response.

I've installed ispyagentdvr as docker container:
https://hub.docker.com/r/doitandbedone/ispyagentdvr
The IMOU Cruiser isn't listed, but works as 'Cue 2' without any problem.
What I need is a simple short code to move the cameras from one preset position to another. The recording will be done by motion.

Hello
Do you have any new news about the imou Cruiser 4MP and the ranger 2 4Mp
thank you all very much for helping!!!

I have sent back the camera to the seller, because the Cruiser doesn't support the Move- and Goto-commands.
Now I use a D-Link DCS-8635LH which supports the commands. I move the camera from position to position by using onvif_cli (https://github.com/quatanium/python-onvif). The problem with many cameras seems to be, that most of them doesn't support the Move- and Goto-commands - even if they are ONVIF Profile "S" or "T"-Type cameras, because these commands are not mandantory.

I have an IMOU camera Model: IPC-F42	 (4mega pixel). it has the same problem. The user name, password, or Ip address is wrong. Here is the log:
On the other hand Imou camera model: IPC-C26E-V2 is working fine..
2022-04-23 12:24:54 ERROR (MainThread) [custom_components.dahua] Could not connect to Dahua device. For iMou devices see https://github.com/rroller/dahua/issues/6
Traceback (most recent call last):
File "/config/custom_components/dahua/config_flow.py", line 177, in _test_credentials
data = await client.get_machine_name()
File "/config/custom_components/dahua/client.py", line 101, in get_machine_name
return await self.get("/cgi-bin/magicBox.cgi?action=getMachineName")
File "/config/custom_components/dahua/client.py", line 687, in get
raise exception
File "/config/custom_components/dahua/client.py", line 669, in get
response = await auth.request("GET", url)
File "/config/custom_components/dahua/digest.py", line 46, in request
response = await self.session.request(method, url, headers=headers, **kwargs)
File "/usr/local/lib/python3.9/site-packages/aiohttp/client.py", line 559, in _request
await resp.start(conn)
File "/usr/local/lib/python3.9/site-packages/aiohttp/client_reqrep.py", line 898, in start
message, payload = await protocol.read() # type: ignore[union-attr]
File "/usr/local/lib/python3.9/site-packages/aiohttp/streams.py", line 616, in read
await self._waiter
aiohttp.client_exceptions.ServerDisconnectedError: Server disconnected

Hi,
Any update about Imou Ranger 2 IPC-A22E integration ?

Hi @rroller. I fixed RPC2 class for authentification and updating session. I needed to use coaxial control that wasn't working through cgi on my iMou IPC-T26EP. Maybe you want to change cgi client to RPC2 in the future.
https://github.com/VaLeXaR/dahua/tree/imou_coaxial_control

Imou db60 doorbell?

Hi,
anyone knows how to grab a jpg from Imou Cue 2C (IPC-C22CP)
Camera has open port 554 for rtsp stream and also port 80 open ... but for what?!
I tried all jpeg path from https://www.ispyconnect.com/camera/imou but none works
THX

So do I understand correctly now that this feature will never come? I just bought two imou Rex devices (IPC-A46LP-D) but it has become clear that without this feature I'll have to return them, sadly they are not as 'onvif-ready' as implied...

@sophof I'm very sorry that I'm short on time and can't dedicate time to get this working. Right now I won't have the time, maybe someone else will jump in and help out but not sure, it's not an easy problem to solve. But I think @VaLeXaR already did the actual hard work, so we need to integrate that.

@rroller Sorry, I see now that my comment was a bit harsh, it wasn't intended that way. It simply was unclear to me what the status was in general. Since I just bought them I still have a window where I can return them, so I really wanted it to be clear, that was all :)
I only know too well what it is like to want to work on these things but lack the time to put in the effort.
I have some experience working on home assistant integrations, but none on camera's and their API's but maybe I can help @VaLeXaR (under similar time constraints :P)? I had a look at your code a few days ago, but I discounted it because it was about coaxial control, so I assumed it wasn't relevant?

After reading some more I think I understand, let me try to summarise. These cameras exclusively use the RPC2 API, where the current integration uses a REST api, which works for most older cameras. For coaxial control @VaLeXaR needed to use the RPC2 api, so he further adjusted that for his usecase. However, all currently supported camera's, including those via the 'current' rpc2 api communicate through HTTP/HTTPS, where the imou camera's for some reason only use something called DHIP. It stands to reason that they haven't written an entirely new API, so probably what is needed is some way to 'translate' (my knowledge isn't deep enough to understand what is needed for that).
I see @mcw0 is working on a dahua console that supports DHIP and is in pre-alpha status though. Presumably this is the same work in essence?

@sophof DHIP is the way to go, working both on HTTP/HTTPS and binary mode. CGI stuff totally sux, just lacking lots of stuff. I did some attempts for making it as python library, but I'm far from done, as I have other things to do. However, if @rroller , @sophof  or anyone else are interested to work with that as well, I can setup a repo for that.

@mcw0 Yeah, I saw that your code was currently at the 'pre-alpha' stage. Sadly, my level of knowledge about these communication protocols is literally zero, so it would require a lot of effort for likely little result from my part.
I have bought a camera from TP-link that looks similar to test as an alternative. That has working local control in home assistant as far as I can tell, so once it arrives and I'm happy I'll likely take the easy road and just return the imou cameras.

Hi @rroller. I fixed RPC2 class for authentification and updating session. I needed to use coaxial control that wasn't working through cgi on my iMou IPC-T26EP. Maybe you want to change cgi client to RPC2 in the future. https://github.com/VaLeXaR/dahua/tree/coaxial_control

With this 'coaxial control' variant, I can enter the Imou IPC-A22E. Also the camera view works, the other entities don't seem to work.
Thanks for the work!

Hi @rroller. I fixed RPC2 class for authentification and updating session. I needed to use coaxial control that wasn't working through cgi on my iMou IPC-T26EP. Maybe you want to change cgi client to RPC2 in the future. https://github.com/VaLeXaR/dahua/tree/coaxial_control

With this 'coaxial control' variant, I can enter the Imou IPC-A22E. Also the camera view works, the other entities don't seem to work. Thanks for the work!

Hey, I have the same Imou camera, how did you make it work? I Installed the coaxial_control, set the username/password and so on, but I just get this message: Dahua device at 192.168.1.xxx isn't fully initialized yet
Reload the integration or even restart HA don't help.
Did you select some specific features? (at the beginning, there was a lot of checkboxes and I set them all on 'check', did you?) something else I'm missing, maybe?

this is the error log:
Logger: custom_components.dahua
Source: custom_components/dahua/__init__.py:291
Integration: Dahua (documentation, issues)
First occurred: 3:18:19 p. m. (4 occurrences)
Last logged: 3:18:57 p. m.

Unexpected error fetching dahua data: Dahua device at <IP_ADDRESS> isn't fully initialized yet
Traceback (most recent call last):
  File "/config/custom_components/dahua/__init__.py", line 201, in _async_update_data
    self._max_streams = await self.client.get_max_extra_streams() + 1
  File "/config/custom_components/dahua/client.py", line 141, in get_max_extra_streams
    result = await self.get("/cgi-bin/magicBox.cgi?action=getProductDefinition&name=MaxExtraStream")
  File "/config/custom_components/dahua/client.py", line 755, in get
    raise exception
  File "/config/custom_components/dahua/client.py", line 737, in get
    response = await auth.request("GET", url)
  File "/config/custom_components/dahua/digest.py", line 46, in request
    response = await self.session.request(method, url, headers=headers, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/client.py", line 559, in _request
    await resp.start(conn)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/client_reqrep.py", line 898, in start
    message, payload = await protocol.read()  # type: ignore[union-attr]
  File "/usr/local/lib/python3.10/site-packages/aiohttp/streams.py", line 616, in read
    await self._waiter
aiohttp.client_exceptions.ServerDisconnectedError: Server disconnected

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 205, in _async_refresh
    self.data = await self._async_update_data()
  File "/config/custom_components/dahua/__init__.py", line 291, in _async_update_data
    raise PlatformNotReady("Dahua device at " + self._address + " isn't fully initialized yet")
homeassistant.exceptions.PlatformNotReady: Dahua device at 192.168.1.xxx isn't fully initialized yet

Hi @rroller. I fixed RPC2 class for authentification and updating session. I needed to use coaxial control that wasn't working through cgi on my iMou IPC-T26EP. Maybe you want to change cgi client to RPC2 in the future. https://github.com/VaLeXaR/dahua/tree/coaxial_control

With this 'coaxial control' variant, I can enter the Imou IPC-A22E. Also the camera view works, the other entities don't seem to work. Thanks for the work!

Hey, I have the same Imou camera, how did you make it work? I Installed the coaxial_control, set the username/password and so on, but I just get this message: Dahua device at 192.168.1.xxx isn't fully initialized yet Reload the integration or even restart HA don't help.
Did you select some specific features? (at the beginning, there was a lot of checkboxes and I set them all on 'check', did you?) something else I'm missing, maybe?

Well, installing the coaxial control version, restart HA, and log in.
If I reload the integration, it gives me the same error as you, but if I disable it and reactivate it, it logs in without problems.
But little else can be done, since no sensor gives correct information, no switch works because from what I understand the cgi commands don't work.

Now it works! but... is there a chance to use PTZ to control from HA? To be honest I started to follow this thread more than a year ago because I want to control on HA what the camera sees, and to open/close the camera, so I could inactivate video when I'm home for privacy.

Now it works! but... is there a chance to use PTZ to control from HA? To be honest I started to follow this thread more than a year ago because I want to control on HA what the camera sees, and to open/close the camera, so I could inactivate video when I'm home for privacy.

In fact, I'm the same as you, right now they are in a drawer precisely because there is no option to move or disable the video.
I was trying Onvif and Amcrest (which are similar) and nothing, neither worked the PTZ.
I commented to report that the coaxial control version was logging into the Imou Ranger 2 IPC-A22E, the current main version never gets around to logging in.

I've installed ispyagentdvr as docker container:
hub.docker.com/r/doitandbedone/ispyagentdvr
The IMOU Cruiser isn't listed, but works as 'Cue 2' without any problem.

I can confirm this is working with the Cruiser SE+ (IPC-S21FE), including pan+tilt controls, but no mic support.

Sadly that is a non-local solution, which is a deal-breaker for me.

Hello, I bought the Ranger 2C... this is the fourth camera I bought, as you I am upset by manufacturers applications and clouds, I was thinking after few reading that this one was able to work locally without any requirment of creating an account or using a mobile app... I am also trying to hack this thing but dont want to loose a huge amount of time, I wonder if I am not going to re-sent this device... I got a ten years old camera from TPLink in my garage that I was able to make running in a cupple of minutes using its web gui... nowadays all mannufacturers try to force theirs applications this is really discouraging

For now I have just connected to it using its Wifi AP and password written on the camera, doing a port scan give me 80 & 554 TCP open but no HTTP layer, any HTTP request fall in timeout, no response, at TCP layer just an ACK no payload.
I'll try to use my computer as a wifi AP and make the first official steps, see what I can grab but I have few hopes to get anything usable.

I knew, it was not going to be that simple...
After a bit more than one hour here is what I was able to make :
1 - make my computer appear as to be the camera for the mobile application.
The QRCode just contain serial number, wifi AP password and model of the camera as a json string, those data are also written on the camera underneath of the QRCode.
It use those datas to connect to the wifi AP of the camera.
I have created with my computer an access point with the same SSID & Password as the camera and was able to get to step 2 of configuration on the mobile application. it is not great but a starting point...
2 - make my computer appear as to be the mobile application for the camera
For this I just connect to its Wifi and set my  IP to <IP_ADDRESS> (based on prévious packets I captured)
So finally, the start of the scenario is :
1 - Mobile App use Serial Number+Wifi password to determine SSID and connect to the Webcam AP
2 - Once mobile app connect to the AP, it then send an UDP broadcast packet with a cupple of bytes "a301000100000000000000000000000002000000000000000000000000000000"
3 - WebCam ask by ARP who is <IP_ADDRESS>
4 - once the WebCam get an asnwer for it ARP request, it try to request at different Google DNS with hardcoded IPs (it try <IP_ADDRESS>,  <IP_ADDRESS>,...)  to resolve devaccess.easy4ipcloud.com
So next step, is to respond to the webcam for its DNS request for devaccess.easy4ipcloud.com an try to proxy all requests.
Not sure I will do this.

In short when I spoof the mobile APP I got this :

And as it got no response from <IP_ADDRESS> it ask to another <IP_ADDRESS> and so on :

Once <IP_ADDRESS> is translated :

This is incredible that this thing rely on a hard coded domain name, a harcoded DNS, a mobile application, and an internet connexion to be configured !

Imou DB60 RTSP ?

This is incredible that this thing rely on a hard coded domain name, a harcoded DNS, a mobile application, and an internet connexion to be configured !

Use the SmartPSS application to change the DNS and hostname. You need to connect over TCP port 37777. The username is "admin" and the password is your safety code printed on the camera label or found in the Imou app.

Imou DB60 RTSP ?

The correct RTSP format looks like this
stream_source: rtsp://<username>:<password>@<IP>:554/cam/realmonitor?channel=1&subtype=0

Use the SmartPSS application to change the DNS and hostname. You need to connect over TCP port 37777. The username is "admin" and the password is your safety code printed on the camera label or found in the Imou app.

Yes in the mean time I bought an Amcrest camera (because it works with it own integrated web interface) and was nicely surprise to see that the mobile Amcrest application detect it aswell as other camera configuration application like Dahua conifg tool.
Anyway, thanks for your tips.

like

Does your RTSP stream still work? Bought a brandnew IPC A22EP-0 (Ranger 2C), updated to firmware version 2.800.0000000.13.R.230708 and did not manage to make RTSP work

HI eadmaster
how did you configure your cam?


Can not install my flutter app on Android12

My app's targetSdkVersion is 31
I can not install it on Pixel6.
I added android:exported to the AndroidManifest.xml file
Also I checked the merged AndroidManifest.xml file.
all activities, services, receivers have android:exported.
but i can not install the app on Android12 phones.
What should i do more?

Hi @liqiang1995, Thanks for filing the issue. Your issue looks similar to https://github.com/flutter/flutter/issues/98256 which was fixed on the master channel. Please share the output of flutter doctor -v and the error logs that you see when the install fails.


Changing to a new world

Hi,
is there a way to change the container world to a new fresh world? What folders / config do I need to wipe?

You need to clear the /config/worlds folder

@ChristianStrube-dev Since I've done that, I am unable to bring up the server anymore, not even by fully removing /data and /config. What could be the issue?
Logs tail, it stops always here
valheim_1  | Jan 27 17:45:08 /supervisord: valheim-updater /dev/sda2 /config ext4 rw,noatime,errors=remount-ro 0 0
valheim_1  | Jan 27 17:45:08 /supervisord: valheim-updater /dev/sda2 /opt/valheim ext4 rw,noatime,errors=remount-ro 0 0
valheim_1  | Jan 27 17:45:11 /supervisord: valheim-updater DEBUG - [38] - No players connected to Valheim server
valheim_1  | Jan 27 17:45:11 /supervisord: valheim-updater INFO - Downloading/updating/validating Valheim server from Steam
valheim_1  | Jan 27 17:45:11 /supervisord: valheim-updater max open descriptors set to 2048
valheim_1  | Jan 27 17:45:13 /supervisord: valheim-updater Redirecting stderr to '/home/valheim/Steam/logs/stderr.txt'
valheim_1  | Jan 27 17:45:13 /supervisord: valheim-updater [  0%] Checking for available updates...
valheim_1  | Jan 27 17:45:13 /supervisord: valheim-updater [----] Verifying installation...
valheim_1  | Jan 27 17:45:13 /supervisord: valheim-updater Steam Console Client (c) Valve Corporation - version<PHONE_NUMBER>
valheim_1  | Jan 27 17:45:13 /supervisord: valheim-updater -- type 'quit' to exit --
valheim_1  | Jan 27 17:45:13 /supervisord: valheim-updater Loading Steam API...OK
valheim_1  | Jan 27 17:45:13 /supervisord: valheim-updater
valheim_1  | Jan 27 17:45:13 /supervisord: valheim-updater Connecting anonymously to Steam Public...
valheim_1  | Jan 27 17:45:15 /supervisord: valheim-updater OK
valheim_1  | Jan 27 17:45:15 /supervisord: valheim-updater Waiting for client config...OK
valheim_1  | Jan 27 17:45:15 /supervisord: valheim-updater Waiting for user info...
valheim_1  | Jan 27 17:45:15 /supervisord: valheim-updater OK
valheim_1  | Jan 27 17:45:15 /supervisord: valheim-updater ^[[33;1mPlease use force_install_dir before logon!
valheim_1  | Jan 27 17:45:15 /supervisord: valheim-updater ^[[0m
valheim_1  | Jan 27 17:45:25 /supervisord: valheim-updater  Update state (0x5) verifying install, progress: 0.10 (1048576 /<PHONE_NUMBER>)
valheim_1  | Jan 27 17:45:25 /supervisord: valheim-updater  Update state (0x5) verifying install, progress: 21.59 (234534470 /<PHONE_NUMBER>)
valheim_1  | Jan 27 17:45:25 /supervisord: valheim-updater  Update state (0x5) verifying install, progress: 43.96 (477556615 /<PHONE_NUMBER>)
valheim_1  | Jan 27 17:45:25 /supervisord: valheim-updater  Update state (0x5) verifying install, progress: 67.86 (737193818 /<PHONE_NUMBER>)
valheim_1  | Jan 27 17:45:25 /supervisord: valheim-updater  Update state (0x5) verifying install, progress: 91.61 (995223354 /<PHONE_NUMBER>)
valheim_1  | Jan 27 17:45:25 /supervisord: valheim-updater Success! App '896660' fully installed.
valheim_1  | Jan 27 17:45:25 /supervisord: valheim-updater .d..t...... ./
valheim_1  | Jan 27 17:45:25 /supervisord: valheim-updater INFO - Valheim Server is already the latest version
valheim_1  | Jan 27 17:45:25 /supervisord: valheim-updater DEBUG - [38] - ValheimPlus is enabled - running updater
valheim_1  | Jan 27 17:45:25 /supervisord: valheim-updater DEBUG - [774] - Local ValheimPlus archive is identical to remote archive and was successfully installed - no update required

I just tested with an old installation as well as a completely empty /data and /config, with and without V+ and in all cases the server came up successfully. Not really sure what might be going wrong on your system. That said, the log above is not from a clean install.

It actually worked after redownloading the docker image, not sure what was going on.


Initial implementation

Initial implementation of the node compactor, which removes underutilized nodes more aggressively than how GKE (and possibly other cloud implementations) would do out of the box.
This controller depends on the Cluster autoscaler running, otherwise it wouldn't work.
The algorithm is the following:

We check all the nodes for which estafette.io/node-compactor-enabled is enabled, and check if their CPU utilization is under the limit specified in estafette.io/node-compactor-scale-down-cpu-request-ratio-limit.
If we have at least as many underutilized nodes as estafette.io/node-compactor-scale-down-required-underutilized-node-count, then we start a scaledown.
When scaling down, we pick the node with the lowest utilization.
Removing a node consists of two steps:

Cordoning it
Deleting all of its pods
And then the Cluster autoscaler will notice that the node is not utilized, and it'll remove it automatically, so we don't actually delete nodes nor VMs ourselves.

In this first implementation we don't take pod disruption budget into account at all, but with an anti affinity rule at least we can ensure that we never delete all of the pods of a certain deployment in one go.

HELLO!! LOOKING FOR A GREAT BLOWJOB?? CALL CAROLINE +33661818188 OR VERO +33667301419!!  JEAN BAUDIN KNOWS THAT FOR SURE!  DON’T BELIVE? CALL HIM AND ASK +31657697635 XOXO

HELLO!! LOOKING FOR A GREAT BLOWJOB?? CALL CAROLINE +33661818188 OR VERO +33667301419!!  JEAN BAUDIN KNOWS THAT FOR SURE!  DON’T BELIVE? CALL HIM AND ASK +31657697635 XOXO

I believe this is a great project that we need. Thank you for the work.

yeah JEAN is also happy ;)
HELLO!! LOOKING FOR A GREAT BLOWJOB?? CALL CAROLINE +33661818188 OR VERO +33667301419!!  JEAN BAUDIN KNOWS THAT FOR SURE!  DON’T BELIVE? CALL HIM AND ASK +31657697635 or +31655935354 XOXO

I think I've addressed all comments, and I've tested quite a lot on development and fixed a number of edge-case issues, and now it seems to be working properly.

Hey all,
I've been testing this and it's working fine on production.
I'd like to implement some improvements to the algorithm, but first I'll merge this PR and open a new one with the improvements so it's easier to review.


Windows T265 Detection Issues

I have a T265. I am running v2.34.0 on Windows 10 (PC). I cannot run any of the samples, as it says it cannot detect the device, even though it is plugged into a USB 3.0 Port. When I open device manager, it shows it as "Intel(R) RealSense(TM) Tracking Camera T265", but under USB Devices,  and not imaging devices. I have tried reinstalling everything, but I cannot get it to work. What do I do?

@sidxrs Does the T265 show up in the Realsense Viewer app?

It does show up in the app.

The first time you connect the T265 to your system, Device Manager will recognize it as a Movidius MA2X5X on a universal serial bus device.
Then launch RealSense Viewer and it will be recognized again as T265 by Universal Serial Bus device in Device Manager.
When another camera is connected, it may not appear in the RealSense Viewer.
You can add T265 by clicking "Add Source" on the top left.


Skip querying preference if OS is empty (backport)

We may have VM without OS set. In such case we get an empty string from the map. This patch will prevent querying and erroring when we hit this case.

backport of #862


Publishing new version to npmjs

Could you please publish the latest version to npm?

Just published 0.3.0 to npm 🚀