• Stars
    star
    117
  • Rank 301,828 (Top 6 %)
  • Language
    Swift
  • License
    MIT License
  • Created about 8 years ago
  • Updated almost 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Swift NetService (Bonjour / Zeroconf / mDNS) implementation for Linux

Swift NetService (Bonjour / Zeroconf / mDNS) implementation for Linux

Build Status

This module allows you to publish your own Bonjour service on the local network. On macOS NetService is included with Cocoa, however on Linux there's no such thing in the standard library.

Since version 0.5 this library uses dns_sd as the responder, instead of implementing mDNS itself. On macOS this means that it uses the system-wide daemon, and on Linux one should install libavahi-compat-libdnssd-dev to run the system-wide daemon.

Usage

See also NetService-Example. Note that like Apple's NetService, you need to run a RunLoop in order for the callbacks to happen.

There's also a command line tool included called dns-sd, with a subset of the functionality provided by Apple's tool with the same name. You can use this tool to verify the implementation and debug your network when advertisements are not working. Run swift run dns-sd --help for usage instructions.

Publish a NetService

This code will publish a new NetService advertising port 8000. Note that you need to setup a listening socket on port 8000 yourself.

import Foundation
import NetService

let service = NetService(domain: "local.", type: "_hap._tcp.", name: "Zithoek", port: 8000)
service.delegate = ...
service.publish()
withExtendedLifetime((service, delegate)) {
    RunLoop.main.run()
}

Browsing for NetServices

This code will start a search for the given service type.

let browser = NetServiceBrowser()
browser.delegate = ...
browser.searchForServices(ofType: "_airplay._tcp.", inDomain: "local.")
withExtendedLifetime((browser, delegate)) {
    RunLoop.main.run()
}

Credits

This library was written by Bouke Haarsma.

More Repositories

1

SwiftInitializerGenerator

Xcode Source Code Extension to Generate Swift Initializers
Swift
717
star
2

HAP

Swift implementation of the Homekit Accessory Protocol
Swift
361
star
3

docx-mailmerge

Mail merge for Office Open XML (docx) files without the need for Microsoft Office Word.
Python
274
star
4

DNS

Swift implementation of DNS Records / RR
Swift
63
star
5

SRP

Secure Remote Password (SRP) for Swift
Swift
53
star
6

Lark

Swift SOAP Client
Swift
53
star
7

Glob

Glob for Swift 5
Swift
25
star
8

django-federated-login

Django Federated Login provides an authentication bridge between Django projects and OpenID-enabled identity providers.
Python
19
star
9

django-airbrake

Django Airbrake provides a logging handler to push exceptions and other errors to airbrakeapp or other airbrake-compatible exception handler services (e.g. aTech Media's Codebase).
Python
17
star
10

INI

Swift INI parser based on (NS)Scanner
Swift
16
star
11

Swift-PriorityQueue

Binary heap implementation in Swift
Swift
15
star
12

pathfinding

A* pathfinding algorithm in Python using OSM data
Python
8
star
13

HKDF

HMAC-based Extract-and-Expand Key Derivation Function (HKDF) in Swift
Swift
7
star
14

My-Home

My DIY Homekit setup in Swift
Swift
7
star
15

Swift-Security

Proof of concept for accessing Keychain using Swift
Swift
6
star
16

NetService-Example

Swift
5
star
17

mvvm

Proof of concept Model-View-ViewModel implementation in Python
Python
4
star
18

Bignum

Swift big number library
Swift
4
star
19

CLibSodium

Swift overlay for libsodium
Swift
3
star
20

ncurses-example

Swift
3
star
21

SPA941-Google-Contact-Sync

PHP
2
star
22

Lark-Example

Example of Lark SOAP library written in Swift
Swift
2
star
23

hc-icy

ICE / Essent e-thermostaat client in Go
Go
1
star
24

spa-phone-api

Provides an API for Linksys/Sipura VoIP SPA Phones
Python
1
star
25

Cdns_sd

Swift C modulemap for dns_sd.h
Swift
1
star
26

hc-my-homekit

My DIY HomeKit / HomeControl accessories in Go
Go
1
star