mirror of
https://github.com/valyala/fasthttp.git
synced 2026-06-14 15:56:44 +03:00
Issue #105: listen by default only on IPv4, since IPv6 may be misleading / unexpected / buggy
This commit is contained in:
@@ -1068,9 +1068,12 @@ func (ctx *RequestCtx) TimeoutErrorWithResponse(resp *Response) {
|
||||
ctx.timeoutResponse = respCopy
|
||||
}
|
||||
|
||||
// ListenAndServe serves HTTP requests from the given TCP addr.
|
||||
// ListenAndServe serves HTTP requests from the given TCP4 addr.
|
||||
//
|
||||
// Pass custom listener to Serve if you need listening on non-TCP4 media
|
||||
// such as IPv6.
|
||||
func (s *Server) ListenAndServe(addr string) error {
|
||||
ln, err := net.Listen("tcp", addr)
|
||||
ln, err := net.Listen("tcp4", addr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1096,22 +1099,28 @@ func (s *Server) ListenAndServeUNIX(addr string, mode os.FileMode) error {
|
||||
return s.Serve(ln)
|
||||
}
|
||||
|
||||
// ListenAndServeTLS serves HTTPS requests from the given TCP addr.
|
||||
// ListenAndServeTLS serves HTTPS requests from the given TCP4 addr.
|
||||
//
|
||||
// certFile and keyFile are paths to TLS certificate and key files.
|
||||
//
|
||||
// Pass custom listener to Serve if you need listening on non-TCP4 media
|
||||
// such as IPv6.
|
||||
func (s *Server) ListenAndServeTLS(addr, certFile, keyFile string) error {
|
||||
ln, err := net.Listen("tcp", addr)
|
||||
ln, err := net.Listen("tcp4", addr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return s.ServeTLS(ln, certFile, keyFile)
|
||||
}
|
||||
|
||||
// ListenAndServeTLSEmbed serves HTTPS requests from the given TCP addr.
|
||||
// ListenAndServeTLSEmbed serves HTTPS requests from the given TCP4 addr.
|
||||
//
|
||||
// certData and keyData must contain valid TLS certificate and key data.
|
||||
//
|
||||
// Pass custom listener to Serve if you need listening on arbitrary media
|
||||
// such as IPv6.
|
||||
func (s *Server) ListenAndServeTLSEmbed(addr string, certData, keyData []byte) error {
|
||||
ln, err := net.Listen("tcp", addr)
|
||||
ln, err := net.Listen("tcp4", addr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user