main.go 515 B

12345678910111213141516171819202122232425262728
  1. package main
  2. import (
  3. "log"
  4. "net"
  5. "net/http"
  6. "time"
  7. "golang.org/x/net/netutil"
  8. )
  9. func main() {
  10. l, err := net.Listen("tcp", conf.Bind)
  11. if err != nil {
  12. log.Fatal(err)
  13. }
  14. s := &http.Server{
  15. Handler: newHTTPHandler(),
  16. ReadTimeout: time.Duration(conf.ReadTimeout) * time.Second,
  17. WriteTimeout: time.Duration(conf.WriteTimeout) * time.Second,
  18. MaxHeaderBytes: 1 << 20,
  19. }
  20. log.Printf("Starting server at %s\n", conf.Bind)
  21. log.Fatal(s.Serve(netutil.LimitListener(l, conf.MaxClients)))
  22. }