12 "github.com/grandcat/zeroconf"
16 name = flag.String("name", "GoZeroconfGo", "The name for the service.")
17 service = flag.String("service", "_workstation._tcp", "Set the service type of the new service.")
18 domain = flag.String("domain", "local.", "Set the network domain. Default should be fine.")
19 host = flag.String("host", "pc1", "Set host name for service.")
20 ip = flag.String("ip", "::1", "Set IP a service should be reachable.")
21 port = flag.Int("port", 42424, "Set the port the service is listening to.")
22 waitTime = flag.Int("wait", 10, "Duration in [s] to publish service for.")
28 server, err := zeroconf.RegisterProxy(*name, *service, *domain, *port, *host, []string{*ip}, []string{"txtv=0", "lo=1", "la=2"}, nil)
32 defer server.Shutdown()
33 log.Println("Published proxy service:")
34 log.Println("- Name:", *name)
35 log.Println("- Type:", *service)
36 log.Println("- Domain:", *domain)
37 log.Println("- Port:", *port)
38 log.Println("- Host:", *host)
39 log.Println("- IP:", *ip)
42 sig := make(chan os.Signal, 1)
43 signal.Notify(sig, os.Interrupt, syscall.SIGTERM)
45 var tc <-chan time.Time
47 tc = time.After(time.Second * time.Duration(*waitTime))
57 log.Println("Shutting down.")