Esempio n. 1
0
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)
	}
}
Esempio n. 2
0
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())
	}
}
Esempio n. 3
0
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(),
	)
}
Esempio n. 4
0
func (ds *DjdnsServer) Run(addr string) error {
	server := new(dns.Server)
	server.Addr = addr
	server.Net = "udp"
	server.Handler = ds
	return server.ListenAndServe()
}
Esempio n. 5
0
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())
	}
}
Esempio n. 6
0
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())
	}

}
Esempio n. 7
0
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)
}
Esempio n. 8
0
File: main.go Progetto: baris/badns
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)
	}
}
Esempio n. 9
0
File: dns.go Progetto: kkumar86/cbfs
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)
	}
}
Esempio n. 10
0
func (s *Server) doRunListener(ds *dns.Server) {
	err := ds.ListenAndServe()
	log.Fatale(err)
}