func main() { flag.Parse() log.SetOutput(os.Stdout) log.SetLevel(log.DebugLevel) var client *docker.Client if os.Getenv("DOCKER_HOST") != "" { var err error certPath := os.Getenv("DOCKER_CERT_PATH") client, err = docker.NewTLSClient(os.Getenv("DOCKER_HOST"), path.Join(certPath, "cert.pem"), path.Join(certPath, "key.pem"), path.Join(certPath, "ca.pem")) if err != nil { log.Fatal(err) } } else { var err error client, err = docker.NewClient("unix:///var/run/docker.sock") if err != nil { log.Fatal(err) } } handler := Handler{docker: client, domain: fmt.Sprintf("%s.", *domain)} server := dns.Server{} server.Handler = &handler server.Net = *network server.Addr = *addr err := server.ListenAndServe() if err != nil { log.Fatal(err) } }
func (s *Server) start(ds *dns.Server) { log.Printf("start %s listener on %s\n", ds.Net, s.Addr()) err := ds.ListenAndServe() if err != nil { log.Printf("start %s listener on %s failed:%s\n", ds.Net, s.Addr(), err.Error()) } }
func runDNSServer(server *dns.Server, errc chan error) { logger.Printf("DNS/%s listening on %s\n", server.Net, server.Addr) errc <- fmt.Errorf( "[error] DNS/%s - server failed: %s", server.Net, server.ListenAndServe(), ) }
func (ds *DjdnsServer) Run(addr string) error { server := new(dns.Server) server.Addr = addr server.Net = "udp" server.Handler = ds return server.ListenAndServe() }
func (s *Server) start(ds *dns.Server) { log.Infof("Start %s listener on %s", ds.Net, s.Addr()) err := ds.ListenAndServe() if err != nil { log.Fatalf("Start %s listener on %s failed: %s", ds.Net, s.Addr(), err.Error()) } }
func (s *Server) start(ds *dns.Server) { fmt.Println("Start listener on ", ds.Net, ":", s.Addr()) err := ds.ListenAndServe() if err != nil { fmt.Println("Start listener failed:", ds.Net, ":", s.Addr(), err.Error()) } }
func main() { log.SetFlags(log.Flags() | log.Lmicroseconds) flag.Usage = func() { fmt.Fprintln(os.Stderr, "Arguments:") flag.PrintDefaults() fmt.Fprint(os.Stderr, logFormatExample) } flag.Parse() dns.HandleFunc(".", serve) server := dns.Server{Addr: *flListen, Net: "udp"} err := server.ListenAndServe() eexit(err) }
func start(ctx *cli.Context) { addr := fmt.Sprintf(":%d", ctx.Int("port")) net := "udp" if ctx.Bool("tcp") { net = "tcp" } handler := BaDNSHandler{hostPrefix: ctx.String("host-prefix")} enableGlitches(ctx, &handler) server := dns.Server{Addr: addr, Net: net, Handler: handler} if err := server.ListenAndServe(); err != nil { log.Fatal("Failed to start the server", err) } }
func dnsServices() { if *dnsBinding == "" { return } log.Printf("Starting DNS services on %v.", *dnsBinding) d := dnsService{} serv := dns.Server{ Net: "udp", Addr: *dnsBinding, Handler: d, } err := serv.ListenAndServe() if err != nil { log.Fatalf("DNS server failure: %v", err) } }
func (s *Server) doRunListener(ds *dns.Server) { err := ds.ListenAndServe() log.Fatale(err) }