本文整理汇总了Golang中github.com/miekg/dns.Server类的典型用法代码示例。如果您正苦于以下问题:Golang Server类的具体用法?Golang Server怎么用?Golang Server使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Server类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: start
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())
}
}
示例2: runDNSServer
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(),
)
}
示例3: start
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())
}
}
示例4: start
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())
}
}
示例5: main
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)
}
示例6: start
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)
}
}
示例7: dnsServices
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)
}
}
示例8: main
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)
}
}
示例9: Run
func (ds *DjdnsServer) Run(addr string) error {
server := new(dns.Server)
server.Addr = addr
server.Net = "udp"
server.Handler = ds
return server.ListenAndServe()
}
示例10: doRunListener
func (s *Server) doRunListener(ds *dns.Server) {
err := ds.ListenAndServe()
log.Fatale(err)
}