This service browses the published zeroconf services in the local network of the server where the service is running and returns the results of the browse through the specified API GET endpoint. A service can be also registered by the API user through the POST method in /services endpoint.
Compatible with:
- Avahi
- Bonjour
- Clone the repository & navigate to directory and run:
git clone [email protected]:Frantisekf/zeroconf-service-discovery-API.git
sudo pip3 install -r requirements.txt
python3 run.py
- You're done!
To deploy the Zeroconf service/API on a device such as Rpi. make sure you have avahi installed on the device
- Make sure you have git version control installed. if not run
sudo apt-get install git
- navigate to your directory which would contain the service on raspberry pi (e.g.
/home/pi/
) - Type in
sudo crontab -e
to open a the crontab config file - Run the
install.sh
as a root to install the/etc
folder of your machine - Restart the Rpi using the command
sudo reboot
- After the restart type the command
cat /service-discovery-API/logs/cronlog
to see if the log is populated with logging output from API - You can configure the port to be used by the API in
/zeroconf.api.service/.env
file
Note: you can configure the port
, hostname
and setDEBUG
level in the .env
file
- Install Docker.
curl -sSL https://get.docker.com | sh
- Add permission to user.
sudo usermod -aG docker <user>
- Install additional dependencies.
sudo apt-get install -y libffi-dev libssl-dev
sudo apt-get install -y python3 python3-pip
sudo apt-get remove python-configparser
- Install docker compose.
sudo pip3 -v install docker-compose
- After finishing docker installation make sure to logout and login to your system user account.
- Navigate to a folder of your choice and clone this repository
git clone [email protected]:Frantisekf/zeroconf-service-discovery-API.git
- After cloning the repository step into it and build the application:
cd zeroconf-service-discovery
docker-compose build
- To run the application, run this command from the zeroconf-service-discovery-API directory:
docker-compose up
- You're done!
Note: you can configure the port
, hostname
and setDEBUG
level in the .env
file
Definition
GET /services
Response
200 OK
on success
[
{
"name": "Fran's MacBook Pro._rfb._tcp.local.",
"hostName": "frans-mbp.fritz.box",
"domainName": "Frans-MacBook-Pro.local.",
"addresses": {
"ipv4": "192.168.178.58",
"ipv6": "fe80::1893:e42f:9c41:1427"
},
"service": {
"type": "_rfb._tcp.local.",
"port": 5900,
"txtRecord": {}
}
},
{
"name": "Fran's MacBook Pro._flametouch._tcp.local.",
"hostName": "frans-mbp.fritz.box",
"domainName": "Frans-MacBook-Pro.local.",
"addresses": {
"ipv4": "192.168.178.58",
"ipv6": "fe80::1893:e42f:9c41:1427"
},
"service": {
"type": "_flametouch._tcp.local.",
"port": 1812,
"txtRecord": {}
}
},
]
POST /services
{
"name": "new2 test service",
"replaceWildcards": false,
"serviceProtocol": "any",
"service": {
"type": "_http._tcp",
"port": 7790,
"txtRecord": {
"property1": "prop",
"property2": "prop",
"property3": "prop"
}
}
}
Response
201 created
on successful register