homebridge / ciao

RFC 6762 and RFC 6763 compliant mdns service discovery library written in Typescript
MIT License
79 stars 6 forks source link

Encountered invalid ipv6 with more than 8 sections! #5

Closed ellisonpatterson closed 3 years ago

ellisonpatterson commented 3 years ago

Describe The Bug: It seems CIAO is not validating the IPV6 address assigned to the OS and homebridge crashes immediately on start.

[Logs:]()

[Thu Sep 17 2020 09:29:04 GMT-0400 (EDT)] Homebridge is running on port 51826.
[Thu Sep 17 2020 09:29:04 GMT-0400 (EDT)] AssertionError [ERR_ASSERTION]: Encountered invalid ipv6 with more than 8 sections!
    at Object.enlargeIPv6 (/opt/lib/node_modules/homebridge/node_modules/@homebridge/ciao/src/util/domain-formatter.ts:140:9)
    at AAAARecord.encodeRData (/opt/lib/node_modules/homebridge/node_modules/@homebridge/ciao/src/coder/records/AAAARecord.ts:33:21)
    at AAAARecord.getRawData (/opt/lib/node_modules/homebridge/node_modules/@homebridge/ciao/src/coder/ResourceRecord.ts:101:31)
    at rrComparator (/opt/lib/node_modules/homebridge/node_modules/@homebridge/ciao/src/util/tiebreaking.ts:24:25)
    at Array.sort (<anonymous>)
    at Prober.doTiebreaking (/opt/lib/node_modules/homebridge/node_modules/@homebridge/ciao/src/responder/Prober.ts:268:62)
    at Prober.handleQuery (/opt/lib/node_modules/homebridge/node_modules/@homebridge/ciao/src/responder/Prober.ts:243:12)
    at Responder.handleQuery (/opt/lib/node_modules/homebridge/node_modules/@homebridge/ciao/src/Responder.ts:525:26)
    at MDNSServer.handleMessage (/opt/lib/node_modules/homebridge/node_modules/@homebridge/ciao/src/MDNSServer.ts:466:20)
    at Socket.emit (events.js:315:20)
[Thu Sep 17 2020 09:29:04 GMT-0400 (EDT)] AssertionError [ERR_ASSERTION]: Encountered invalid ipv6 with more than 8 sections!
    at Object.enlargeIPv6 (/opt/lib/node_modules/homebridge/node_modules/@homebridge/ciao/src/util/domain-formatter.ts:140:9)
    at AAAARecord.encodeRData (/opt/lib/node_modules/homebridge/node_modules/@homebridge/ciao/src/coder/records/AAAARecord.ts:33:21)
    at AAAARecord.getRawData (/opt/lib/node_modules/homebridge/node_modules/@homebridge/ciao/src/coder/ResourceRecord.ts:101:31)
    at rrComparator (/opt/lib/node_modules/homebridge/node_modules/@homebridge/ciao/src/util/tiebreaking.ts:24:25)
    at Array.sort (<anonymous>)
    at Prober.doTiebreaking (/opt/lib/node_modules/homebridge/node_modules/@homebridge/ciao/src/responder/Prober.ts:268:62)
    at Prober.handleQuery (/opt/lib/node_modules/homebridge/node_modules/@homebridge/ciao/src/responder/Prober.ts:243:12)
    at Responder.handleQuery (/opt/lib/node_modules/homebridge/node_modules/@homebridge/ciao/src/Responder.ts:525:26)
    at MDNSServer.handleMessage (/opt/lib/node_modules/homebridge/node_modules/@homebridge/ciao/src/MDNSServer.ts:466:20)
    at Socket.emit (events.js:315:20)
[Thu Sep 17 2020 09:29:04 GMT-0400 (EDT)] Got SIGTERM, shutting down Homebridge...
(node:2801) UnhandledPromiseRejectionWarning: cancelled
(node:2801) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:2801) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Homebridge Config:

{
    "bridge": {
        "name": "Home",
        "username": "CC:22:3D:E3:AA:31",
        "port": 51826,
        "pin": "999-01-999"
    },
    "ports": {
        "start": 52100,
        "end": 52150,
        "comment": "This section is used to control the range of ports that separate accessory (like camera or television) should be bind to."
    },
    "accessories": [
        {
            "accessory": "DummySwitch",
            "name": "Home Status",
            "stateful": true
        }
    ],
    "platforms": [
        {
            "name": "Config",
            "port": 9000,
            "auth": "form",
            "theme": "auto",
            "restart": "exec '/opt/etc/init.d/S60homebridge restart'",
            "tempUnits": "f",
            "lang": "auto",
            "sudo": false,
            "log": {
                "method": "custom",
                "command": "/opt/data/homebridge/watch-logs.sh"
            },
            "platform": "config"
        }
    ]
}

Environment:

Supereg commented 3 years ago

Could you please elaborate which operating system you are using. Also can you provide the IPv6 address which ciao fails to parse? Can be censored in anyway when at least the structure is kept in the same way. Can't guide you to any steps as I don't know your OS.

ellisonpatterson commented 3 years ago

Could you please elaborate which operating system you are using. Also can you provide the IPv6 address which ciao fails to parse? Can be censored in anyway when at least the structure is kept in the same way. Can't guide you to any steps as I don't know your OS.

It is dd-wrt and the IPv6 address is fe80::c314:60ff:ff37:2370/64

ellisonpatterson commented 3 years ago

@Supereg Just updated and here is the new log output:

Sep 21 11:08:32 III-1 user.notice homebridge: Error occurred handling incoming (on lo) dns query packet: AssertionError [ERR_ASSERTION]: Encountered invalid ipv6 with more than 8 sections (2604:6000:xxxx:73c8:200:ff:fe00::)!
Sep 21 11:08:32 III-1 user.notice homebridge:     at Object.enlargeIPv6 (/opt/lib/node_modules/homebridge/node_modules/@homebridge/ciao/src/util/domain-formatter.ts:140:9)
Sep 21 11:08:32 III-1 user.notice homebridge:     at AAAARecord.encodeRData (/opt/lib/node_modules/homebridge/node_modules/@homebridge/ciao/src/coder/records/AAAARecord.ts:33:21)
Sep 21 11:08:32 III-1 user.notice homebridge:     at AAAARecord.getRawData (/opt/lib/node_modules/homebridge/node_modules/@homebridge/ciao/src/coder/ResourceRecord.ts:101:31)
Sep 21 11:08:32 III-1 user.notice homebridge:     at rrComparator (/opt/lib/node_modules/homebridge/node_modules/@homebridge/ciao/src/util/tiebreaking.ts:24:25)
Sep 21 11:08:32 III-1 user.notice homebridge:     at Array.sort (<anonymous>)
Sep 21 11:08:32 III-1 user.notice homebridge:     at Prober.doTiebreaking (/opt/lib/node_modules/homebridge/node_modules/@homebridge/ciao/src/responder/Prober.ts:268:62)
Sep 21 11:08:32 III-1 user.notice homebridge:     at Prober.handleQuery (/opt/lib/node_modules/homebridge/node_modules/@homebridge/ciao/src/responder/Prober.ts:243:12)
Sep 21 11:08:32 III-1 user.notice homebridge:     at Responder.handleQuery (/opt/lib/node_modules/homebridge/node_modules/@homebridge/ciao/src/Responder.ts:539:26)
Sep 21 11:08:32 III-1 user.notice homebridge:     at MDNSServer.handleMessage (/opt/lib/node_modules/homebridge/node_modules/@homebridge/ciao/src/MDNSServer.ts:467:22)
Sep 21 11:08:32 III-1 user.notice homebridge:     at Socket.emit (events.js:315:20)
Supereg commented 3 years ago

I assume the xxxx is just you censoring your ipv6 address?

Supereg commented 3 years ago

@ellisonpatterson thanks, the log output helped to identify and reproduce the issue. Will be fixed with the next version.

Supereg commented 3 years ago

ciao was updated to v.1.0.11 including a fix for this problem. It will take some time until we release a new homebridge version. If you want to force update ciao, just reinstall homebridge npm package and it should pull in the update automatically.

Edit: depending on npm caches, you may need to wait a few minutes.

ellisonpatterson commented 3 years ago

ciao was updated to v.1.0.11 including a fix for this problem. It will take some time until we release a new homebridge version. If you want to force update ciao, just reinstall homebridge npm package and it should pull in the update automatically.

Edit: depending on npm caches, you may need to wait a few minutes.

Sorry about my tardiness. Thank you so much for the prompt update!