undwad / conf0

crossplatform (bonjour (windows/osx), avahi(linux)) zeroconf(dnssd) module for lua 5.2
MIT License
2 stars 0 forks source link

Announce services from a outside the host #2

Open nicopace opened 7 years ago

nicopace commented 7 years ago

I'm working on a service for the libremesh project, It would be great to be able to publish a list of services that are not located on the host.

Is that doable?

This is the use case: we have a mesh network of +50 nodes. The mesh protocol has a service subprotocol that allows to send administrative information much more effectively than using multicast, so as we have openwrt on each node, what we want is to snoop the mdns resolvers on each node for their mdns records and publish them through this service subprotocol in order to efficiently share mdns information.

thanks!

undwad commented 7 years ago

register function has the following paramets for both bonjour and avahi: flags: integer, optional, 0 by default `interface: integer, optional, 0 by default name: string, optional, nullptr by default type: string, required domain: string, optional, nullptr by default host: string, optional, nullptr by default port: integer, optional, 0 by default texts: table, optional, LUA_NOREF by default for avahi only: protocol`: integer, optional, AVAHI_PROTO_UNSPEC by default, look avahi's DNSServiceRegister function

so I think you can try setting anything you want instead of domain and host. but not sure if it would work.

maybe reading some docs about avahi could help.

and may be this http://stackoverflow.com/questions/20986671/could-i-use-avahi-to-publish-service-across-subnetworks is somehow ralated.

nicopace commented 7 years ago

Hi! I tried to run the test_register.lua example. These were the steps I did:

git clone https://github.com/undwad/conf0.git
cd conf0
cmake
make
ln -s libconf0.so conf0.so
lua output/test_register.lua

That sequence lead me to this error message:

lua: output/test_register.lua:1: module 'std' not found:
    no field package.preload['std']
    no file '/usr/local/share/lua/5.2/std.lua'
    no file '/usr/local/share/lua/5.2/std/init.lua'
    no file '/usr/local/lib/lua/5.2/std.lua'
    no file '/usr/local/lib/lua/5.2/std/init.lua'
    no file '/usr/share/lua/5.2/std.lua'
    no file '/usr/share/lua/5.2/std/init.lua'
    no file './std.lua'
    no file '/usr/local/lib/lua/5.2/std.so'
    no file '/usr/lib/x86_64-linux-gnu/lua/5.2/std.so'
    no file '/usr/lib/lua/5.2/std.so'
    no file '/usr/local/lib/lua/5.2/loadall.so'
    no file './std.so'
stack traceback:
    [C]: in function 'require'
    output/test_register.lua:1: in main chunk
    [C]: in ?

I understand that std is a standard lua lib that comes with the interpreter.

These are the apt packages that I have installed on my ubuntu 16.10:

liblua5.1-0
liblua5.1-0-dev
liblua5.2-0
liblua5.2-0-dbg
liblua5.2-dev
liblua5.3-0
lua-bitop
lua-expat
lua-json
lua-lpeg
lua-socket
lua5.1
lua5.2
luarocks

Any idea?

Thanks!

undwad commented 7 years ago

Hello! https://github.com/undwad/conf0/tree/master/output contains std.lua file and std directory. These are standard lua library. The example uses mainly prettytostring function and maybe something else that I don't remember. This std library is pure lua and is included via require 'std' line. So you should copy it to some location where lua could find it. These location are listed in the error message.

nicopace commented 7 years ago

Oh, thanks! So,.. it seems that avahi doesn't like to recieve hostname information... when I set host to say '192.168.1.100':

                conf0.execute{ -- begin calling conf0.register_ 
                    proc = conf0.register_, -- service function to call
                    ref = connection.ref, -- service reference
                    type = type, -- service type
                                        host = '192.168.1.100',
                    name = 'test server', -- service name
                    port = port2opaque(5500), -- service port
                    texts = {'sample text', 'key=value'}, -- service texts
                    callback = function(registered) -- begin register callback
                        pprint(registered) -- print result
                    end -- end register callback
                } -- end calling conf0.register_ 

lua tells me that "client_callback error ./browse0conf.lua:62: Invalid host name". Any idea?