toxuin / mdns-tunneller

Tunnels two (or more) mDNS domains together
Other
117 stars 9 forks source link

TypeError: data.copy is not a function #2

Closed agisofttm closed 3 years ago

agisofttm commented 3 years ago

Hi @toxuin

Thanks for amazing tool. I have some problems with client side. Th problem is that client is working for some time and suddely quit with an error:

vladimirtodorov@hassio-ribarica:~/mdns-tunneller$ npm run start

mdns-tunneller@0.0.1 start /home/vladimirtodorov/mdns-tunneller node index.js

Connecting to http://192.168.2.167:42069... Connected to the remote: http://192.168.2.167:42069 /home/vladimirtodorov/mdns-tunneller/node_modules/dns-packet/index.js:173 data.copy(buf, offset + 2) ^

TypeError: data.copy is not a function at Object.runknown.encode (/home/vladimirtodorov/mdns-tunneller/node_modules/dns-packet/index.js:173:8) at Object.answer.encode (/home/vladimirtodorov/mdns-tunneller/node_modules/dns-packet/index.js:799:9) at encodeList (/home/vladimirtodorov/mdns-tunneller/node_modules/dns-packet/index.js:992:9) at Object.exports.encode (/home/vladimirtodorov/mdns-tunneller/node_modules/dns-packet/index.js:924:12) at onbind (/home/vladimirtodorov/mdns-tunneller/node_modules/multicast-dns/index.js:87:28) at apply (/home/vladimirtodorov/mdns-tunneller/node_modules/thunky/index.js:44:12) at process._tickCallback (internal/process/next_tick.js:63:19) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! mdns-tunneller@0.0.1 start: node index.js npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the mdns-tunneller@0.0.1 start script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! /home/vladimirtodorov/.npm/_logs/2020-12-08T13_51_29_515Z-debug.log

Client side is Virtual Ubuntu 18.04 with NodeJS 10.23.

If I start client again the error appear almost immediately.

Can you help me with this error?

Thank you in advance

toxuin commented 3 years ago

Hello. Sorry for the late reply. Were you able to resolve this? Seems like some packet is getting mangled in transit and cannot be re-created on the client side.

Are there any errors in console on server side?

Could you enable debug mode on both client and server (DEBUG=* npm run start) and see if there are some weird malformed packets? Warning: this will generate a lot of logs. Also, those logs might contain some private data.

agisofttm commented 3 years ago

Hello. Sorry for the late reply. Were you able to resolve this? Seems like some packet is getting mangled in transit and cannot be re-created on the client side.

Are there any errors in console on server side?

Could you enable debug mode on both client and server (DEBUG=* npm run start) and see if there are some weird malformed packets? Warning: this will generate a lot of logs. Also, those logs might contain some private data.

Hi @toxuin

Unfortunately I'm unable to resolve this and moved to docker installation were seems to work properly, but this was only for few days, and after I'm getting same error even in docker. Today I'll enable DEBUG and will post you the results. Thank you for help.

Kind Regards

agisofttm commented 3 years ago

@toxuin I think, I found the problem The main problem is that I have a VPN connection and tunneller is trying to resend packets from main network to it self. So for example I'm connecting to network 192.168.2.0/24 from 192.1683.0/24. Everything from 192.168.3.0/0 is send to mdns server, but in one moment mdns Client get packets from 192.168.2.0/24 network and try to send them to server, and everything is go down. I tried to blacklist certain IP from 192.168.2.0/24 but it's not working. So now I put both Clients and server to docker with auto restart feature, and for now everything Is Ok. But can you please check Blacklisting is it working. It's amazing software, and I want to use it.

toxuin commented 3 years ago

Thank you for your kind words. If at least one person in the world (other than my mom) likes my software - it makes me happy.

I'll verify the blacklist works as intended and get back to you. There's very basic network storm protection built-in, but seems it's insufficient.

toxuin commented 3 years ago

@agisofttm I've just pushed a major update out. I believe it should fix this issue now.

It is almost a complete re-write. I've decided to write everything in typescript, incorporated better library for parsing raw DNS packets (ciao) and now produce multi-arch docker images (= works on raspberry pi too).

I've managed to reproduce the error you were having and found the root cause too: it was happening when it tried to parse DNS packets of certain types the underlying library was unaware of. I've also noticed one rather major bug that was fixed in this new version: no A records would be able to be sent through the tunnel unless they're also paired with a record from a whitelist. This made my Apple TV not work with Home Assistant at all. With this new version it's actually auto-discovered 😄

Please let me know what you think.

agisofttm commented 3 years ago

@agisofttm I've just pushed a major update out. I believe it should fix this issue now.

It is almost a complete re-write. I've decided to write everything in typescript, incorporated better library for parsing raw DNS packets (ciao) and now produce multi-arch docker images (= works on raspberry pi too).

I've managed to reproduce the error you were having and found the root cause too: it was happening when it tried to parse DNS packets of certain types the underlying library was unaware of. I've also noticed one rather major bug that was fixed in this new version: no A records would be able to be sent through the tunnel unless they're also paired with a record from a whitelist. This made my Apple TV not work with Home Assistant at all. With this new version it's actually auto-discovered 😄

Please let me know what you think.

You are awesome. I can't wait to get and test the new version and give you feedback. And I'll push this to Home Assistant community, so someone can make an Add-on from this, because it's not only useable - it is money saving piece from a lot Apple TV's that someone should buy for controlling a lot of HomeAssistant instances from Apple's Home app thru Hobebridge 😁

toxuin commented 3 years ago

Hey @agisofttm can you verify that this issue is resolved? I did some testing myself and I can’t trigger this error anymore, but would like to hear what you’d find before I close the issue :)

agisofttm commented 3 years ago

Hey @agisofttm can you verify that this issue is resolved? I did some testing myself and I can’t trigger this error anymore, but would like to hear what you’d find before I close the issue :)

Hi @toxuin I can verify that issue is completely gone after 7 day of testing. 1 Server and 5 clients are no issues in logs, and everything run smoothly and actually run more quickly ;-) thanks again 👍

toxuin commented 3 years ago

Perfect! Happy to hear.