dougbw / coredns_omada

CoreDNS plugin for TP-Link Omada SDN
Apache License 2.0
84 stars 9 forks source link

Initial Setup results in " invalid memory address or nil pointer dereference" #35

Closed kantmn closed 7 months ago

kantmn commented 7 months ago

Hi there,

it sounds like a great solution you build. but i am currently not able to use it.

using the latest docker container with an omada software controller 5.13.23 added the corresponding variables to the docker run command, created the user in omada and i can confirm that the docker is connecting and logging into the omada controller. after that i crashes immediately with this result in the logs.

searching the existing issues, this seems to relate to ipv6, but we only use ipv4, i was not able to find any ipv6 configuration in the omada controller.

Do you have any idea what is going wrong?

Thank you a lot Regards

`panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x5707e0]

goroutine 1 [running]: net.networkNumberAndMask(0x0?) /usr/local/go/src/net/ip.go:425 net.(IPNet).Contains(0x0?, {0xc00091eb60, 0x10, 0x14?}) /usr/local/go/src/net/ip.go:449 +0x25 github.com/dougbw/coredns_omada.(Omada).updateZones(0xc00099f560, {0x1?, 0x22ef893?}) /coredns_omada/update.go:144 +0x18bc github.com/dougbw/coredns_omada.setup(0xc0009b0240) /coredns_omada/setup.go:50 +0x7d9 github.com/coredns/caddy.executeDirectives(0xc000616100, {0x22d7859, 0x8}, {0x3a685c0, 0x35, 0x0?}, {0xc000560460, 0x1, 0x14ae9ce2f338?}, 0x0) /go/pkg/mod/github.com/coredns/caddy@v1.1.1/caddy.go:661 +0x61d github.com/coredns/caddy.ValidateAndExecuteDirectives({0x287a680?, 0xc0009ba3c0}, 0x416b3c?, 0x0) /go/pkg/mod/github.com/coredns/caddy@v1.1.1/caddy.go:612 +0x3c5 github.com/coredns/caddy.startWithListenerFds({0x287a680, 0xc0009ba3c0}, 0xc000616100, 0x0) /go/pkg/mod/github.com/coredns/caddy@v1.1.1/caddy.go:515 +0x265 github.com/coredns/caddy.Start({0x287a680, 0xc0009ba3c0}) /go/pkg/mod/github.com/coredns/caddy@v1.1.1/caddy.go:472 +0xd4 github.com/coredns/coredns/coremain.Run() /coredns/coremain/run.go:66 +0x1c6 main.main() /coredns/coredns.go:12 +0xf [INFO] plugin/omada: logging in...`

dougbw commented 7 months ago

Hi, this looks like a bug and I think I can see the cause. On your controller in the "Wired Networks" -> "LAN" page do you have any networks configured as "VLAN" rather than "Interface" ? If you aren't actually using the VLANs then removing them temporarily might get this working in the mean time.

Assuming this is the case It should be an easy enough fix.

kantmn commented 7 months ago

Hi thanks for the reply, i have created a Backup File for my omada config, and proceeded with the given Changes.  The docker Container Afterwards started sucessfully i was Not able to check the logs so far, but dns resolving worls now. Will Check logs later

Just a Note, the vlans we're from default config for guest network. I would Like to use vlans im Future, any way to fix this with an easy fix or is this a big Change?

Thanks a Lot  Regards

dougbw commented 7 months ago

There are 2 types of LAN "networks" on the Omada controller: Interface and VLAN. The interface networks are routable networks with an address space (e.g on the gateway) while the VLAN networks are simply to assign VLANs to switch ports but without any of the associated IP range/routing capabilities.

The interface networks always worked with coredns_omada (and this would have been how the majority of users would have been using VLANs), however the VLAN only "networks" seem to be the cause of this bug.

dougbw commented 7 months ago

I have just pushed a new release which should fix this:

https://github.com/dougbw/coredns_omada/releases/tag/v1.6.3