Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crashing with IPv6 connections #20

Open
dkulp opened this issue Aug 13, 2024 · 0 comments
Open

Crashing with IPv6 connections #20

dkulp opened this issue Aug 13, 2024 · 0 comments

Comments

@dkulp
Copy link

dkulp commented Aug 13, 2024

I'm working on supporting some of the wled API on a more "full featured" device. One part of that is that the device supports IPv6. When WLED-native detects this service, there are a few issues:

  1. The IPv6 address is too long to display in the list of devices. The list cannot be made wide enough to display it.

  2. When clicking on the device, wled-native crashes

I actually think the best fix would be to limit the connection to ipv4. This allows

diff --git a/wled-native/Service/DiscoveryService.swift b/wled-native/Service/DiscoveryService.swift
index 904d783..dc2cf36 100644
--- a/wled-native/Service/DiscoveryService.swift
+++ b/wled-native/Service/DiscoveryService.swift
@@ -41,7 +41,10 @@ class DiscoveryService: NSObject, Identifiable {
                     print("NW Browser: Added")
                     if case .service(let name, _, _, _) = added.endpoint {
                         print("Connecting to \(name)")
-                        let connection = NWConnection(to: added.endpoint, using: .tcp)
+                        let params = NWParameters.tcp
+                        let ip = params.defaultProtocolStack.internetProtocol! as! NWProtocolIP.Options
+                        ip.version = .v4
+                        let connection = NWConnection(to: added.endpoint, using: params)
                         connection.stateUpdateHandler = { state in

Note: the _wled._tcp service is only registered with mdns on ipv4 and a " avahi-browse -a | grep wled" from a linux box confirms that. Ideally, wled-native would check the registration and force ipv4 appropriately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant