Giter Site home page Giter Site logo

qtzeroconf's People

Contributors

beku-epitome avatar briankendall avatar cameronklein avatar fmeinicke avatar jbagg avatar marc-cpdesign avatar mattes-bru avatar mawebmw avatar mochaap avatar morixhub avatar mzanetti avatar pgquiles avatar probonopd avatar strfry avatar viktorgino avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

qtzeroconf's Issues

Segmentation fault while reading TXT records

I recently experienced a weird crash when using QtZeroConf on Windows:
I had multiple servers running on my local machine that announced themselves using python's zeroconf implementation. In my C++ client application, I used the zeroconf browser to discover them. While the browser was discovering the servers (more specifically, during parsing of the TXT records of the entries) my application cashed.

I could trace the cause of the crash to the QZeroConfPrivate::resolverCallback function in bonjour.cpp.
While iterating over the txtRecord array it happened that the length of the next record (recLen) was bigger than the total length of the TXT records (txtLen). This resulted in an overflow in this line

txtLen-= recLen + 1;

since txtLen is an unsigned int.

I could fix the problem by simply adding a check after the recLen was read (i.e. after this):

recLen = txtRecord[0];

	if (recLen > txtLen)
	{
		break;
	}

I just wanted to get your opinion on this since I'm not really familiar with DNS records: Do you think this behaviour is just a bug in QtZeroConf or could it be that the python zeroconf implementation does something weird with the records it's publishing?
I just would've thought that it could never happen that a TXT record reports that its length (recLen) is 195 but the total length of all TXT records (txtLen) is just 41 or so.

Power-Cycling Bonjour Devices Can Cause Permanent Loss

Repro (on Mackie DL hardware):

  1. Power up a DL32S mixer and set it to use its internal router to generate a WiFi network.
  2. Connect an instance of Master Fader (5) to the mixer via the WiFi network. Forget all other networks.
  3. Power cycle the mixer. (Note that the mixer doesn't have the ability to send a power-down 'lost' message.)

The usual result is that once the WiFi network comes back up, the mixer will reconnect to it automatically. (You may need to reselect the WiFi network, as the wireless auto connect doesn't always seem to work. In this case, once the WiFi is manually reconnected, the mixer will then automatically reconnect.)

Sometimes, however, while the WiFi network is reconnected (automatically or manually), the mixer doesn't reconnect. There are at least two different issues involved:

A) Sometimes this appears to be the fault of the OS - either iOS or macOS. In this case, the mixer cannot be discovered using Flame or Discovery (iOS) or dns-sd (macOS). If the OS can't find the mixer, then Q(t)ZeroConf clearly can't be expected to, but

B) Sometimes the mixer can be discovered, but it is still not reported out of the Q(t)ZeroConf browser. In this case it seems likely that the issue is with Q(t)ZeroConf, as we've only seen this issue with iOS and macOS, not with Android or Windows, and our code is very generic in its handling of different OSs, whereas Q(t)ZeroConf has completely different sources for iOS vs. Android (?).

In both cases, though, the fix is to turn off the WiFi on the desktop or iPad and then turn it back on; this almost always restores the connection. (Note also that this result is per Mac/iPad; one can be stuck while others have successfully reconnected, so it's clearly not the mixer. We did have trouble with the mixer advertising itself at one point, but we haven't seen that in a while.)

Anyway, does this ring any bells? Is the lack of a 'lost' message on device power cycle a problem? Or maybe something with the timing of the device coming up and restarting its WiFi and its Bonjour services?

How to search for all kinds of services?

How to search for all kinds of services?

This works, but only finds one type of service:

zeroConf.startBrowser("_http._tcp");

This doesn't work:

zeroConf.startBrowser(nullptr);
zeroConf.startBrowser("");
zeroConf.startBrowser("*");
zeroConf.startBrowser("*._tcp");

So if I need to find any service on the network regardless of its type or protocol, how would I do that? And how would I find all services on TCP?

Extra files

It seems like there are full implementations of Bonjour, and Avahi in source. While it's not bothering current operations it could be a little confusing. And if someone actually tried to link to those they could break ABI compatibility.

I think perhaps they should be removed, and rather than relying on a bundled implementation fix it via qmake.

Error while buidling on windows 7 with Qt 5.8 and MSVC2015_64bit

I would really like to build zeroconf into one of my project, but building on windows I am getting an error on line 136 from the generated moc_qzeroconf.cpp in function

const QMetaObject QZeroConf::staticMetaObject = {
    { &QObject::staticMetaObject, qt_meta_stringdata_QZeroConf.data,
      qt_meta_data_QZeroConf,  qt_static_metacall, Q_NULLPTR, Q_NULLPTR}
};

saying C2491: 'QZeroConf::staticMetaObject': definition of dllimport static data member not allowed.

problem when renewing connexion

Hi,
I use qzeroconf in my app to discover Cisco devices. when i launch my app and start browser, i can get all my devices connected to the network, but when i unplug a device:
1)removeService is emitted
2) if i plug another device, i cannot see it
3)if i replug the device i unplugged, service does not appear anymore.

to resume, when i just unplug a device, no more service is added.

i am developing on Mac OS Mojave

Do you have a solution ?

Windows 10 Loses Devices On WiFi Network Toggle

We're seeing the following issue:

Windows 10 laptop on wireless network A.

  1. Start up our app, browse for devices, devices found.
  2. Change wifi network to B. (Old devices lost, new devices found.)
  3. Switch back to wifi network A, no devices found.

The only way to find devices again seems to be to restart the laptop.

Android: Temporary resolution failures result in service removal

Using QtZeroconf on Android, I've noticed that resuming from suspend would often cause services to disappear even if they should not and it would take up to minutes for them to reappear. I've tracked it down to this code block which removes the service entry if resolving of a service fails:

https://github.com/jbagg/QtZeroConf/blob/master/avahicore.cpp#L206

The problem with this is that it seems to happen frequently when the app is in background, or the display is locked. This does not necessarily mean the other device disappeared. I understand that just removing this may cause situations where a remote service does not respond any more for real.

Not sure what the proper fix would be but I feel like the current situation might be to aggressively removing services, at least for my use case. Perhaps one option could be to pass the remove reason (eg. serviceUnregistered/resolveFailed). Or maybe not removing the service but just flagging the resolve failure in a property?

I suppose the same goes for avahiclient, but on systems with an actual avahi running presumably this happens way less often.

Unable to integrate in Qt 5.7.1.

I'd love to use this library on my current project, but have not been able to link to it, despite days of trying. I'm starting out trying to build for iOS.

I've tried several methods of linking, both the two suggested, and also pulling the project in as a submodule. None of them work, so there must be more steps needed in the instructions? Or something has broken in the past year? Specific errors below:

Submodule

Attempts to compile fail thusly:

Starting: "/usr/bin/make"
rm -f libQtZeroConf_debug.a
.../usr/bin/ar cq libQtZeroConf_debug.a
ar: no archive members specified
usage: ar -d [-TLsv] archive file ...

Building into your project

Clone or download QZeroConf. If you download, unzip.
Copy the qtzeroconf directory to be under your project's directory.
Include the qtzeroconf.pri file in your projects .pro file

include(qtzeroconf/qtzeroconf.pri)

In the case of my project, there is a main app and several other libraries, so the question is where to include the qtzeroconf.pri file? If I stick it into the main project file (at the bottom), everything compiles, but none of the objects in the qtzeroconf library can be linked to:

Undefined symbols for architecture arm64:
"QZeroConf::startBrowser(QString, QAbstractSocket::NetworkLayerProtocol)", referenced from:
QZeroConf::startBrowser(QString) in libConnectivityManager.a(connectivitymanager.o)
etc.

I've tried putting the include into the subdirs that use it, and that doesn't work either; I can provide more detail if that's the proper approach.

Compiling as a dynamic library

Clone or download QZeroConf. If you download, unzip.
Enter the qtzeroconf directory, run qmake and then make.

Running Qt5.7/5.7/clang_64/bin/qmake (the only one that works on my Mac, duh, creates a .dylib, and I suspect it might work with MacOS, but it's not going to work with iOS is it? (Trying the ios qmake yields the same 'ar' errors as listed above for the submodule - probably not a coincidence?)

I've also tried endless permutations of trying to import the sources and add (another) library to my project; these all fail to link. Qt Creator is extremely short on help, though, so I could easily be doing something wrong.

Any ideas?

Thanks,
Alex

the host is empty

I test the browser,I found that the host string is empty(""),but my service truly published with the host string,I can get it by my python code.I need this string ,is there a way to solve this?Thanks!

SIGABRT if Avahi is not running on Linux

If Avahi isn't running, pri->client ends up null, and there is no way to check for this condition. Attempting to start a service publish or a browser results in Avahi throwing up a SIGABRT

It would be great if there was a way to check if required services are available and running before running any of the functions that require a valid client.

Use bonjour-sdk on other platforms, too?

Is there a way to use bonjour-sdk not only for WIN32, but also for e.g., Linux or FreeBSD? If so, how?

Ideally there would be a configure-time switch to use either Avahi or bonjour-sdk.

The use case would be embedded systems where no full Avahi stack is running and no dependencies on Avahi are desirable.

Library does not broadcast on Android devices

Hello,
I've tried to use this library on both Android and Apple devices. iOS and Mac is working fine, however on Android devices nothing happened - I've tried following "fixes":

Do you have any idea what might be wrong? Example does not work on Android as well (it runs but does not broadcast itself).

serviceAdded() Callback for Powered Off Device?

Howdy,

I'm seeing behavior from the browser that I can't account for, so I wonder if I'm misunderstanding how things are supposed to work, or if there's a bug.

Repro:

  1. Power up a device that publishes it service name via Bonjour - in my case, a speaker.
  2. Create a QZeroConf browser, connect up serviceAdded(), etc., and call startBrowser().
  3. See that the device is added by the browser (callback via serviceAdded()).
  4. Power down the device. (Note that the device doesn't send a 'lost' or 'removed' or whatever message on power down - it doesn't have the ability to send a last message during power off.)
  5. Call stopBrowser() followed by startBrowser().
  6. See that the device is added by the browser!

The weirdness is not that the device is rediscovered - I'm sure it's persisting in various Bonjour caches on the network. The weirdness is that I thought that QtZeroConf had a resolution step before it added a device, and I don't think it's possible to resolve a device that isn't physically present on the network? Or is that also handled indirectly via cached records?

Does QtZeroConf 'remember' that it resolved the device previously and just use the old information (since it hasn't gotten any Bonjour notification about the device going away)? This assumes that a 'real' resolution pass happened initially.

Also, what is the resolution timeout?

Thoughts?

Thanks,
Alex

issue reading txtrecord of addService()

I want to fetch text record of added service aka.
zcs.txt["Qt"]; --> should give me QT is best according to your info file.

but in my case, its showing failed. the hint can be mismatch data type in QMap & QByteArray;
bcz
qDebug () << zcs.txt(); gives me complete QMap but cant fetch the single one.. a simple example like your readme will be enough.

error: invalid types ' [const char [5]]' for array subscript.

Update of TXT records

Hello everybody. I am using QtZeroConf for an embedded device and I am in need to update the content of TXT records while the device is running (basically a TXT record represents the "status" of the device" and so I have to update it accordingly)...

There is a way of doing this with QtZeroConf?

Thanks.

Android API Level 30 issues

With Android API level 30, registering the zoerconf browser fails with

W qtMainLoopThrea: type=1400 audit(0.0:8386): avc: denied { ioctl } for path="socket:[6380337]" dev="sockfs" ino=6380337 ioctlcmd=0x8927 scontext=u:r:untrusted_app:s0:c154,c256,c512,c768 tcontext=u:r:untrusted_app:s0:c154,c256,c512,c768 tclass=tcp_socket permissive=0 app=io.guh.nymeaapp

The failing call is in netlink.c, in avahi_netlink_new

    if (bind(fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {

fails with "Permission denied".

Now that new apps can't be uploaded any more with an API level less than 30 (and existing apps only until end of November) this becomes a real problem. I'm still debugging how to get it to work again but so far couldn't find anything.

compiling on Windows 10 with Qt 5.8

I'm having an impossible time compiling. The issue seems to the with the keyword "interface" in your QZeroConfService structure. So I changed the word "interface" to "intrfc" throughout the code, and now I can get it to compile.

struct QZeroConfService {
QString name;
QString type;
QString domain;
QString host;
QHostAddress ip;
QHostAddress ipv6;
quint32 interface;
quint16 port;
};

Using thread safe signals for the api

Signal / slots can be considered thread safe in Qt but the API of QtZeroConf breaks this by using the QZeroconf data type. What about using the SharedData concept of Qt?

No Services on iOS using test app

I am using QT 5.15.2, Xcode 12.5.1 and iOS 14.7.1 and I get no services in the test_app. addService or removeService never fires.

Add Contact Info to Readme

The Readme lists the clause below to contact jbagg for a copy of QZeroConf with a BSD licence, but no contact information is given, nor is any present in the jbagg Github profile. Please add this.

Apple App Store deployment
Publishing GPL software in the App Store is a violation of the GPL. If you need to publish an app in the Apple App Store that uses QZeroConf, please contact me for a copy of QZeroConf with a BSD licence.

qzeroconfigservice ipv4 property assigned ipv6 address

I set the browser to ipv4 only. When a new service is added, sometimes the ipv4 property "ip" in the qzeroconfservice-object is assigned an ipv6 address.

I tested this by adding a qDebug() output to the setIp function:

void QZeroConfService::setIp(QHostAddress &ip) { data->ip = ip; qDebug() << "set ip" << ip; }

The output:

/qtzeroconf/qzeroconfservice.cpp:89 (void QZeroConfService::setIp(QHostAddress&)): set ip QHostAddress("fe80::f55c:ea97:334e:b8c8")

System hosting the service is a Windows machine. The browser is running on Android.

Cannot build example on FreeBSD

Cannot build example on FreeBSD with -DBUILD_EXAMPLE=1:

mkdir build
cd build
cmake .. -DBUILD_EXAMPLE=1
make
(...)
[ 11%] Automatic MOC for target QtZeroConf
[ 11%] Built target QtZeroConf_autogen
[ 22%] Building CXX object CMakeFiles/QtZeroConf.dir/QtZeroConf_autogen/mocs_compilation.cpp.o
[ 33%] Building CXX object CMakeFiles/QtZeroConf.dir/qzeroconfservice.cpp.o
[ 44%] Linking CXX static library libQtZeroConf.a
[ 44%] Built target QtZeroConf
[ 55%] Automatic MOC and UIC for target QtZeroConfExample
[ 55%] Built target QtZeroConfExample_autogen
[ 66%] Building CXX object example/CMakeFiles/QtZeroConfExample.dir/QtZeroConfExample_autogen/mocs_compilation.cpp.o                                                                              
[ 77%] Building CXX object example/CMakeFiles/QtZeroConfExample.dir/window.cpp.o
[ 88%] Building CXX object example/CMakeFiles/QtZeroConfExample.dir/main.cpp.o
[100%] Linking CXX executable QtZeroConfExample
/usr/local/bin/x86_64-unknown-freebsd13.1-ld: CMakeFiles/QtZeroConfExample.dir/QtZeroConfExample_autogen/mocs_compilation.cpp.o: in function `mainWindow::~mainWindow()':
mocs_compilation.cpp:(.text._ZN10mainWindowD2Ev[_ZN10mainWindowD2Ev]+0x38): undefined reference to `QZeroConf::~QZeroConf()'
/usr/local/bin/x86_64-unknown-freebsd13.1-ld: CMakeFiles/QtZeroConfExample.dir/window.cpp.o: in function `mainWindow::mainWindow()':
window.cpp:(.text+0x92): undefined reference to `QZeroConf::QZeroConf(QObject*)'
/usr/local/bin/x86_64-unknown-freebsd13.1-ld: window.cpp:(.text+0x27c): undefined reference to `QZeroConf::~QZeroConf()'
/usr/local/bin/x86_64-unknown-freebsd13.1-ld: CMakeFiles/QtZeroConfExample.dir/window.cpp.o: in function `mainWindow::stopPublishClicked()':
window.cpp:(.text+0x1016): undefined reference to `QZeroConf::stopServicePublish()'
/usr/local/bin/x86_64-unknown-freebsd13.1-ld: CMakeFiles/QtZeroConfExample.dir/window.cpp.o: in function `mainWindow::appStateChanged(Qt::ApplicationState)':
window.cpp:(.text+0x11ba): undefined reference to `QZeroConf::stopServicePublish()'
/usr/local/bin/x86_64-unknown-freebsd13.1-ld: window.cpp:(.text+0x11c7): undefined reference to `QZeroConf::stopBrowser()'
/usr/local/bin/x86_64-unknown-freebsd13.1-ld: window.cpp:(.text+0x11f4): undefined reference to `QZeroConf::publishExists()'
/usr/local/bin/x86_64-unknown-freebsd13.1-ld: window.cpp:(.text+0x1212): undefined reference to `QZeroConf::browserExists()'
/usr/local/bin/x86_64-unknown-freebsd13.1-ld: CMakeFiles/QtZeroConfExample.dir/window.cpp.o: in function `mainWindow::startPublish()':
window.cpp:(.text+0x12c0): undefined reference to `QZeroConf::clearServiceTxtRecords()'
/usr/local/bin/x86_64-unknown-freebsd13.1-ld: window.cpp:(.text+0x12f6): undefined reference to `QZeroConf::addServiceTxtRecord(QString, QString)'
/usr/local/bin/x86_64-unknown-freebsd13.1-ld: window.cpp:(.text+0x133a): undefined reference to `QZeroConf::addServiceTxtRecord(QString)'
/usr/local/bin/x86_64-unknown-freebsd13.1-ld: window.cpp:(.text+0x13a9): undefined reference to `QZeroConf::startServicePublish(char const*, char const*, char const*, unsigned short)'
/usr/local/bin/x86_64-unknown-freebsd13.1-ld: CMakeFiles/QtZeroConfExample.dir/window.cpp.o: in function `QZeroConf::startBrowser(QString)':
window.cpp:(.text._ZN9QZeroConf12startBrowserE7QString[_ZN9QZeroConf12startBrowserE7QString]+0x2c): undefined reference to `QZeroConf::startBrowser(QString, QAbstractSocket::NetworkLayerProtocol)'
/usr/local/bin/x86_64-unknown-freebsd13.1-ld: ../libQtZeroConf.a(mocs_compilation.cpp.o):(.data.rel.ro+0x88): undefined reference to `QZeroConf::~QZeroConf()'
/usr/local/bin/x86_64-unknown-freebsd13.1-ld: ../libQtZeroConf.a(mocs_compilation.cpp.o):(.data.rel.ro+0x90): undefined reference to `QZeroConf::~QZeroConf()'
c++: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [example/CMakeFiles/QtZeroConfExample.dir/build.make:134: example/QtZeroConfExample] Fehler 1
make[1]: *** [CMakeFiles/Makefile2:155: example/CMakeFiles/QtZeroConfExample.dir/all] Fehler 2
make: *** [Makefile:136: all] Fehler 2

Services disappear on macOS Catalina

I'm able to consistently reproduce a problem with services disappearing when the broadcasting application is terminated and not re-appearing when the broadcast is restarted.

I get the serviceAdded signal when the broadcaster is initially launched. If I terminate the broadcaster I get the serviceRemoved signal. However when I restart the broadcaster I get neither serviceAdded nor serviceUpdated.

This happens 100% of the time on macOS Catalina. The broadcast is done using native libraries and I can see the service appear an disappear in Discovery so I'm fairly certain the broadcast is done properly.

Stopped working for ios 17

I have had this working fine until ios 17 update. I can't get it to find any mdns services from different iphones all running ios 17. Anyone have this working on ios17?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.