SimulPiscator / AirSane

Publish SANE scanners to MacOS, Android, and Windows via Apple AirScan.
GNU General Public License v3.0
258 stars 26 forks source link

umdns instead of avahi on OpenWRT #126

Open cmangla opened 2 months ago

cmangla commented 2 months ago

Avahi is available as a package on OpenWRT, and our current package uses it as a dependency. However, OpenWRT has its own mDNS alternative called umdns, which is light-weight and typically pre-installed. On OpenWRT, umdns does not require any native code integration. It can just be called upon from the init scripts that launch airsaned. Some routers may not have enough space to install avahi.

If airsaned can, after launch, generate output of the form <service> <proto> <port> [<textkey=textvalue> ... ], then this can just be passed on to umdns on OpenWRT. I believe this is all that's required. Example output is "webdav" "tcp" "80" "path=/nextcloud/remote.php/dav/files/YOUR_USER/" "u=YOUR_USER"

Is avahi currently a hard dependency?

Can we add an option to airsaned to just output the text needed by umdns as shown above?

SimulPiscator commented 2 months ago

On macOS, airsaned is using dnssd instead of avahi, so there is some modularization in place already. Certainly, it would not be difficult to write the required output, but note that airsaned will dynamically add or remove entries if scanners are plugged in or removed. It should thus have means to restart/reload the umdns process. Is this possible?

cmangla commented 2 months ago

On macOS, airsaned is using dnssd instead of avahi, so there is some modularization in place already.

Ah, that's good to know.

Certainly, it would not be difficult to write the required output, but note that airsaned will dynamically add or remove entries if scanners are plugged in or removed. It should thus have means to restart/reload the umdns process. Is this possible?

The clean way to do this on OpenWRT (I'm guessing) would be to tell umdns to change the AirSane entries using ubus. The ubus subsystem (with u meaning µ meaning 'micro') is their alternative for the desktop linux daemon dbus. And again, the least hacky way to use ubus would be to use its c-api by linking against libubus.

I am tempted to work around linking against the libubus because our needs are simple. It is also possible to send ubus messages using the ubus binary with the right arguments, and that is how it is used on the commandline. We can just invoke it with system().

I will look into these options when I find some free time.

cmangla commented 2 months ago

Closes cmangla/AirSane-openwrt#32