mirror of
https://github.com/luxfi/zap.git
synced 2026-10-30 15:04:16 +00:00
Per HIP-0069 — one service type, no transition window, no backwards compat. Non-compliant deployments fail loudly so we detect and fix them rather than papering over them. Removed: - LEGACY_SERVICE_TYPE (`_hanzo-zap._tcp.local.`) - Dual-publish (canonical + legacy) on `publish()` - Dual-browse on `browse()` - All de-dup logic that existed only because of the dual records The only Hanzo service-type is `_hanzo._tcp.local.`. Verified live with macOS dns-sd: the omniserver advertises only on canonical, and is reachable via canonical browse from sibling python and the extension's native-messaging helper.
41 lines
930 B
Go
41 lines
930 B
Go
package zapmdns_test
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"time"
|
|
|
|
zapmdns "github.com/zap-proto/mdns"
|
|
)
|
|
|
|
// ExamplePublish — what every Go service in the Hanzo stack does on startup.
|
|
func ExamplePublish() {
|
|
pub, err := zapmdns.Publish(zapmdns.PublishOptions{
|
|
Role: zapmdns.RoleKMS,
|
|
Port: 8443,
|
|
Version: "0.1.0",
|
|
Proto: "zap/1",
|
|
Auth: "iam",
|
|
Capabilities: []string{"sign", "verify", "encrypt", "decrypt"},
|
|
})
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
defer pub.Close()
|
|
// service runs forever ...
|
|
_ = pub
|
|
}
|
|
|
|
// ExampleBrowse — find every KMS on the LAN within 2 seconds.
|
|
func ExampleBrowse() {
|
|
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
|
|
defer cancel()
|
|
services, err := zapmdns.Browse(ctx, zapmdns.RoleKMS, 2*time.Second)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
for _, s := range services {
|
|
fmt.Printf("%s %s caps=%v\n", s.ServerID, s.URL(), s.Capabilities)
|
|
}
|
|
}
|