From 3161e73a587558437f480fc4fa98048beb3736bf Mon Sep 17 00:00:00 2001 From: Alessandro Ros Date: Tue, 13 Feb 2024 13:04:56 +0100 Subject: [PATCH] rename httpserv into httpp (#3014) --- internal/api/api.go | 6 +++--- internal/metrics/metrics.go | 6 +++--- internal/playback/server.go | 6 +++--- internal/pprof/pprof.go | 6 +++--- .../{httpserv => httpp}/handler_exit_on_panic.go | 2 +- .../{httpserv => httpp}/handler_filter_requests.go | 2 +- .../protocols/{httpserv => httpp}/handler_logger.go | 2 +- .../{httpserv => httpp}/handler_server_header.go | 2 +- .../location_with_trailing_slash.go | 2 +- .../location_with_trailing_slash_test.go | 2 +- .../protocols/{httpserv => httpp}/remote_addr.go | 2 +- .../protocols/{httpserv => httpp}/wrapped_server.go | 4 ++-- .../{httpserv => httpp}/wrapped_server_test.go | 2 +- internal/servers/hls/http_server.go | 10 +++++----- internal/servers/hls/server.go | 4 ++-- internal/servers/webrtc/http_server.go | 12 ++++++------ 16 files changed, 35 insertions(+), 35 deletions(-) rename internal/protocols/{httpserv => httpp}/handler_exit_on_panic.go (96%) rename internal/protocols/{httpserv => httpp}/handler_filter_requests.go (95%) rename internal/protocols/{httpserv => httpp}/handler_logger.go (98%) rename internal/protocols/{httpserv => httpp}/handler_server_header.go (93%) rename internal/protocols/{httpserv => httpp}/location_with_trailing_slash.go (95%) rename internal/protocols/{httpserv => httpp}/location_with_trailing_slash_test.go (97%) rename internal/protocols/{httpserv => httpp}/remote_addr.go (95%) rename internal/protocols/{httpserv => httpp}/wrapped_server.go (96%) rename internal/protocols/{httpserv => httpp}/wrapped_server_test.go (97%) diff --git a/internal/api/api.go b/internal/api/api.go index 4f650663..4a83f38a 100644 --- a/internal/api/api.go +++ b/internal/api/api.go @@ -20,7 +20,7 @@ import ( "github.com/bluenviron/mediamtx/internal/conf" "github.com/bluenviron/mediamtx/internal/defs" "github.com/bluenviron/mediamtx/internal/logger" - "github.com/bluenviron/mediamtx/internal/protocols/httpserv" + "github.com/bluenviron/mediamtx/internal/protocols/httpp" "github.com/bluenviron/mediamtx/internal/record" "github.com/bluenviron/mediamtx/internal/restrictnetwork" "github.com/bluenviron/mediamtx/internal/servers/hls" @@ -169,7 +169,7 @@ type API struct { SRTServer SRTServer Parent apiParent - httpServer *httpserv.WrappedServer + httpServer *httpp.WrappedServer mutex sync.RWMutex } @@ -248,7 +248,7 @@ func (a *API) Initialize() error { network, address := restrictnetwork.Restrict("tcp", a.Address) var err error - a.httpServer, err = httpserv.NewWrappedServer( + a.httpServer, err = httpp.NewWrappedServer( network, address, time.Duration(a.ReadTimeout), diff --git a/internal/metrics/metrics.go b/internal/metrics/metrics.go index b495d612..9383a470 100644 --- a/internal/metrics/metrics.go +++ b/internal/metrics/metrics.go @@ -14,7 +14,7 @@ import ( "github.com/bluenviron/mediamtx/internal/api" "github.com/bluenviron/mediamtx/internal/conf" "github.com/bluenviron/mediamtx/internal/logger" - "github.com/bluenviron/mediamtx/internal/protocols/httpserv" + "github.com/bluenviron/mediamtx/internal/protocols/httpp" "github.com/bluenviron/mediamtx/internal/restrictnetwork" ) @@ -36,7 +36,7 @@ type Metrics struct { ReadTimeout conf.StringDuration Parent metricsParent - httpServer *httpserv.WrappedServer + httpServer *httpp.WrappedServer mutex sync.Mutex pathManager api.PathManager rtspServer api.RTSPServer @@ -58,7 +58,7 @@ func (m *Metrics) Initialize() error { network, address := restrictnetwork.Restrict("tcp", m.Address) var err error - m.httpServer, err = httpserv.NewWrappedServer( + m.httpServer, err = httpp.NewWrappedServer( network, address, time.Duration(m.ReadTimeout), diff --git a/internal/playback/server.go b/internal/playback/server.go index 5d5d5868..b3e4fc2f 100644 --- a/internal/playback/server.go +++ b/internal/playback/server.go @@ -12,7 +12,7 @@ import ( "github.com/bluenviron/mediamtx/internal/conf" "github.com/bluenviron/mediamtx/internal/logger" - "github.com/bluenviron/mediamtx/internal/protocols/httpserv" + "github.com/bluenviron/mediamtx/internal/protocols/httpp" "github.com/bluenviron/mediamtx/internal/restrictnetwork" "github.com/gin-gonic/gin" ) @@ -59,7 +59,7 @@ type Server struct { PathConfs map[string]*conf.Path Parent logger.Writer - httpServer *httpserv.WrappedServer + httpServer *httpp.WrappedServer mutex sync.RWMutex } @@ -76,7 +76,7 @@ func (p *Server) Initialize() error { network, address := restrictnetwork.Restrict("tcp", p.Address) var err error - p.httpServer, err = httpserv.NewWrappedServer( + p.httpServer, err = httpp.NewWrappedServer( network, address, time.Duration(p.ReadTimeout), diff --git a/internal/pprof/pprof.go b/internal/pprof/pprof.go index 63803fc9..a15bc028 100644 --- a/internal/pprof/pprof.go +++ b/internal/pprof/pprof.go @@ -10,7 +10,7 @@ import ( "github.com/bluenviron/mediamtx/internal/conf" "github.com/bluenviron/mediamtx/internal/logger" - "github.com/bluenviron/mediamtx/internal/protocols/httpserv" + "github.com/bluenviron/mediamtx/internal/protocols/httpp" "github.com/bluenviron/mediamtx/internal/restrictnetwork" ) @@ -24,7 +24,7 @@ type PPROF struct { ReadTimeout conf.StringDuration Parent pprofParent - httpServer *httpserv.WrappedServer + httpServer *httpp.WrappedServer } // Initialize initializes PPROF. @@ -32,7 +32,7 @@ func (pp *PPROF) Initialize() error { network, address := restrictnetwork.Restrict("tcp", pp.Address) var err error - pp.httpServer, err = httpserv.NewWrappedServer( + pp.httpServer, err = httpp.NewWrappedServer( network, address, time.Duration(pp.ReadTimeout), diff --git a/internal/protocols/httpserv/handler_exit_on_panic.go b/internal/protocols/httpp/handler_exit_on_panic.go similarity index 96% rename from internal/protocols/httpserv/handler_exit_on_panic.go rename to internal/protocols/httpp/handler_exit_on_panic.go index c3b0e51e..adf9fb12 100644 --- a/internal/protocols/httpserv/handler_exit_on_panic.go +++ b/internal/protocols/httpp/handler_exit_on_panic.go @@ -1,4 +1,4 @@ -package httpserv +package httpp import ( "fmt" diff --git a/internal/protocols/httpserv/handler_filter_requests.go b/internal/protocols/httpp/handler_filter_requests.go similarity index 95% rename from internal/protocols/httpserv/handler_filter_requests.go rename to internal/protocols/httpp/handler_filter_requests.go index 682d711e..c167ea47 100644 --- a/internal/protocols/httpserv/handler_filter_requests.go +++ b/internal/protocols/httpp/handler_filter_requests.go @@ -1,4 +1,4 @@ -package httpserv +package httpp import ( "net/http" diff --git a/internal/protocols/httpserv/handler_logger.go b/internal/protocols/httpp/handler_logger.go similarity index 98% rename from internal/protocols/httpserv/handler_logger.go rename to internal/protocols/httpp/handler_logger.go index f18d1702..6e1967f1 100644 --- a/internal/protocols/httpserv/handler_logger.go +++ b/internal/protocols/httpp/handler_logger.go @@ -1,4 +1,4 @@ -package httpserv +package httpp import ( "bytes" diff --git a/internal/protocols/httpserv/handler_server_header.go b/internal/protocols/httpp/handler_server_header.go similarity index 93% rename from internal/protocols/httpserv/handler_server_header.go rename to internal/protocols/httpp/handler_server_header.go index 86a2121e..89ab797f 100644 --- a/internal/protocols/httpserv/handler_server_header.go +++ b/internal/protocols/httpp/handler_server_header.go @@ -1,4 +1,4 @@ -package httpserv +package httpp import ( "net/http" diff --git a/internal/protocols/httpserv/location_with_trailing_slash.go b/internal/protocols/httpp/location_with_trailing_slash.go similarity index 95% rename from internal/protocols/httpserv/location_with_trailing_slash.go rename to internal/protocols/httpp/location_with_trailing_slash.go index 339a4d5c..108531cd 100644 --- a/internal/protocols/httpserv/location_with_trailing_slash.go +++ b/internal/protocols/httpp/location_with_trailing_slash.go @@ -1,4 +1,4 @@ -package httpserv +package httpp import "net/url" diff --git a/internal/protocols/httpserv/location_with_trailing_slash_test.go b/internal/protocols/httpp/location_with_trailing_slash_test.go similarity index 97% rename from internal/protocols/httpserv/location_with_trailing_slash_test.go rename to internal/protocols/httpp/location_with_trailing_slash_test.go index e5d20c3a..9622ed9e 100644 --- a/internal/protocols/httpserv/location_with_trailing_slash_test.go +++ b/internal/protocols/httpp/location_with_trailing_slash_test.go @@ -1,4 +1,4 @@ -package httpserv +package httpp import ( "net/url" diff --git a/internal/protocols/httpserv/remote_addr.go b/internal/protocols/httpp/remote_addr.go similarity index 95% rename from internal/protocols/httpserv/remote_addr.go rename to internal/protocols/httpp/remote_addr.go index cbee6a6d..2490c535 100644 --- a/internal/protocols/httpserv/remote_addr.go +++ b/internal/protocols/httpp/remote_addr.go @@ -1,4 +1,4 @@ -package httpserv +package httpp import ( "net" diff --git a/internal/protocols/httpserv/wrapped_server.go b/internal/protocols/httpp/wrapped_server.go similarity index 96% rename from internal/protocols/httpserv/wrapped_server.go rename to internal/protocols/httpp/wrapped_server.go index abc5e84c..4e23f35a 100644 --- a/internal/protocols/httpserv/wrapped_server.go +++ b/internal/protocols/httpp/wrapped_server.go @@ -1,5 +1,5 @@ -// Package httpserv contains HTTP server utilities. -package httpserv +// Package httpp contains HTTP utilities. +package httpp import ( "context" diff --git a/internal/protocols/httpserv/wrapped_server_test.go b/internal/protocols/httpp/wrapped_server_test.go similarity index 97% rename from internal/protocols/httpserv/wrapped_server_test.go rename to internal/protocols/httpp/wrapped_server_test.go index 1db5d4e9..e30e2b85 100644 --- a/internal/protocols/httpserv/wrapped_server_test.go +++ b/internal/protocols/httpp/wrapped_server_test.go @@ -1,4 +1,4 @@ -package httpserv +package httpp import ( "io" diff --git a/internal/servers/hls/http_server.go b/internal/servers/hls/http_server.go index 94de2366..5de849d1 100644 --- a/internal/servers/hls/http_server.go +++ b/internal/servers/hls/http_server.go @@ -15,7 +15,7 @@ import ( "github.com/bluenviron/mediamtx/internal/conf" "github.com/bluenviron/mediamtx/internal/defs" "github.com/bluenviron/mediamtx/internal/logger" - "github.com/bluenviron/mediamtx/internal/protocols/httpserv" + "github.com/bluenviron/mediamtx/internal/protocols/httpp" "github.com/bluenviron/mediamtx/internal/restrictnetwork" ) @@ -43,7 +43,7 @@ type httpServer struct { pathManager defs.PathManager parent *Server - inner *httpserv.WrappedServer + inner *httpp.WrappedServer } func (s *httpServer) initialize() error { @@ -64,7 +64,7 @@ func (s *httpServer) initialize() error { network, address := restrictnetwork.Restrict("tcp", s.address) var err error - s.inner, err = httpserv.NewWrappedServer( + s.inner, err = httpp.NewWrappedServer( network, address, time.Duration(s.readTimeout), @@ -137,7 +137,7 @@ func (s *httpServer) onRequest(ctx *gin.Context) { dir, fname = pa, "" if !strings.HasSuffix(dir, "/") { - ctx.Writer.Header().Set("Location", httpserv.LocationWithTrailingSlash(ctx.Request.URL)) + ctx.Writer.Header().Set("Location", httpp.LocationWithTrailingSlash(ctx.Request.URL)) ctx.Writer.WriteHeader(http.StatusMovedPermanently) return } @@ -170,7 +170,7 @@ func (s *httpServer) onRequest(ctx *gin.Context) { return } - s.Log(logger.Info, "connection %v failed to authenticate: %v", httpserv.RemoteAddr(ctx), terr.Message) + s.Log(logger.Info, "connection %v failed to authenticate: %v", httpp.RemoteAddr(ctx), terr.Message) // wait some seconds to mitigate brute force attacks <-time.After(pauseAfterAuthError) diff --git a/internal/servers/hls/server.go b/internal/servers/hls/server.go index 2a7553c5..a673e6cf 100644 --- a/internal/servers/hls/server.go +++ b/internal/servers/hls/server.go @@ -11,7 +11,7 @@ import ( "github.com/bluenviron/mediamtx/internal/conf" "github.com/bluenviron/mediamtx/internal/defs" "github.com/bluenviron/mediamtx/internal/logger" - "github.com/bluenviron/mediamtx/internal/protocols/httpserv" + "github.com/bluenviron/mediamtx/internal/protocols/httpp" ) // ErrMuxerNotFound is returned when a muxer is not found. @@ -154,7 +154,7 @@ outer: r.processRequest(&req) default: - r := s.createMuxer(req.path, httpserv.RemoteAddr(req.ctx)) + r := s.createMuxer(req.path, httpp.RemoteAddr(req.ctx)) r.processRequest(&req) } diff --git a/internal/servers/webrtc/http_server.go b/internal/servers/webrtc/http_server.go index afd6f84d..8b8e5fe6 100644 --- a/internal/servers/webrtc/http_server.go +++ b/internal/servers/webrtc/http_server.go @@ -17,7 +17,7 @@ import ( "github.com/bluenviron/mediamtx/internal/conf" "github.com/bluenviron/mediamtx/internal/defs" "github.com/bluenviron/mediamtx/internal/logger" - "github.com/bluenviron/mediamtx/internal/protocols/httpserv" + "github.com/bluenviron/mediamtx/internal/protocols/httpp" "github.com/bluenviron/mediamtx/internal/protocols/webrtc" "github.com/bluenviron/mediamtx/internal/restrictnetwork" ) @@ -61,7 +61,7 @@ type httpServer struct { pathManager defs.PathManager parent *Server - inner *httpserv.WrappedServer + inner *httpp.WrappedServer } func (s *httpServer) initialize() error { @@ -81,7 +81,7 @@ func (s *httpServer) initialize() error { network, address := restrictnetwork.Restrict("tcp", s.address) var err error - s.inner, err = httpserv.NewWrappedServer( + s.inner, err = httpp.NewWrappedServer( network, address, time.Duration(s.readTimeout), @@ -129,7 +129,7 @@ func (s *httpServer) checkAuthOutsideSession(ctx *gin.Context, path string, publ return false } - s.Log(logger.Info, "connection %v failed to authenticate: %v", httpserv.RemoteAddr(ctx), terr.Message) + s.Log(logger.Info, "connection %v failed to authenticate: %v", httpp.RemoteAddr(ctx), terr.Message) // wait some seconds to mitigate brute force attacks <-time.After(pauseAfterAuthError) @@ -178,7 +178,7 @@ func (s *httpServer) onWHIPPost(ctx *gin.Context, path string, publish bool) { res := s.parent.newSession(webRTCNewSessionReq{ pathName: path, - remoteAddr: httpserv.RemoteAddr(ctx), + remoteAddr: httpp.RemoteAddr(ctx), query: ctx.Request.URL.RawQuery, user: user, pass: pass, @@ -330,7 +330,7 @@ func (s *httpServer) onRequest(ctx *gin.Context) { s.onPage(ctx, ctx.Request.URL.Path[1:len(ctx.Request.URL.Path)-len("/publish")], true) case ctx.Request.URL.Path[len(ctx.Request.URL.Path)-1] != '/': - ctx.Writer.Header().Set("Location", httpserv.LocationWithTrailingSlash(ctx.Request.URL)) + ctx.Writer.Header().Set("Location", httpp.LocationWithTrailingSlash(ctx.Request.URL)) ctx.Writer.WriteHeader(http.StatusMovedPermanently) default: