Browse Source

rename httpserv into httpp (#3014)

pull/3015/head
Alessandro Ros 2 years ago committed by GitHub
parent
commit
3161e73a58
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 6
      internal/api/api.go
  2. 6
      internal/metrics/metrics.go
  3. 6
      internal/playback/server.go
  4. 6
      internal/pprof/pprof.go
  5. 2
      internal/protocols/httpp/handler_exit_on_panic.go
  6. 2
      internal/protocols/httpp/handler_filter_requests.go
  7. 2
      internal/protocols/httpp/handler_logger.go
  8. 2
      internal/protocols/httpp/handler_server_header.go
  9. 2
      internal/protocols/httpp/location_with_trailing_slash.go
  10. 2
      internal/protocols/httpp/location_with_trailing_slash_test.go
  11. 2
      internal/protocols/httpp/remote_addr.go
  12. 4
      internal/protocols/httpp/wrapped_server.go
  13. 2
      internal/protocols/httpp/wrapped_server_test.go
  14. 10
      internal/servers/hls/http_server.go
  15. 4
      internal/servers/hls/server.go
  16. 12
      internal/servers/webrtc/http_server.go

6
internal/api/api.go

@ -20,7 +20,7 @@ import (
"github.com/bluenviron/mediamtx/internal/conf" "github.com/bluenviron/mediamtx/internal/conf"
"github.com/bluenviron/mediamtx/internal/defs" "github.com/bluenviron/mediamtx/internal/defs"
"github.com/bluenviron/mediamtx/internal/logger" "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/record"
"github.com/bluenviron/mediamtx/internal/restrictnetwork" "github.com/bluenviron/mediamtx/internal/restrictnetwork"
"github.com/bluenviron/mediamtx/internal/servers/hls" "github.com/bluenviron/mediamtx/internal/servers/hls"
@ -169,7 +169,7 @@ type API struct {
SRTServer SRTServer SRTServer SRTServer
Parent apiParent Parent apiParent
httpServer *httpserv.WrappedServer httpServer *httpp.WrappedServer
mutex sync.RWMutex mutex sync.RWMutex
} }
@ -248,7 +248,7 @@ func (a *API) Initialize() error {
network, address := restrictnetwork.Restrict("tcp", a.Address) network, address := restrictnetwork.Restrict("tcp", a.Address)
var err error var err error
a.httpServer, err = httpserv.NewWrappedServer( a.httpServer, err = httpp.NewWrappedServer(
network, network,
address, address,
time.Duration(a.ReadTimeout), time.Duration(a.ReadTimeout),

6
internal/metrics/metrics.go

@ -14,7 +14,7 @@ import (
"github.com/bluenviron/mediamtx/internal/api" "github.com/bluenviron/mediamtx/internal/api"
"github.com/bluenviron/mediamtx/internal/conf" "github.com/bluenviron/mediamtx/internal/conf"
"github.com/bluenviron/mediamtx/internal/logger" "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/bluenviron/mediamtx/internal/restrictnetwork"
) )
@ -36,7 +36,7 @@ type Metrics struct {
ReadTimeout conf.StringDuration ReadTimeout conf.StringDuration
Parent metricsParent Parent metricsParent
httpServer *httpserv.WrappedServer httpServer *httpp.WrappedServer
mutex sync.Mutex mutex sync.Mutex
pathManager api.PathManager pathManager api.PathManager
rtspServer api.RTSPServer rtspServer api.RTSPServer
@ -58,7 +58,7 @@ func (m *Metrics) Initialize() error {
network, address := restrictnetwork.Restrict("tcp", m.Address) network, address := restrictnetwork.Restrict("tcp", m.Address)
var err error var err error
m.httpServer, err = httpserv.NewWrappedServer( m.httpServer, err = httpp.NewWrappedServer(
network, network,
address, address,
time.Duration(m.ReadTimeout), time.Duration(m.ReadTimeout),

6
internal/playback/server.go

@ -12,7 +12,7 @@ import (
"github.com/bluenviron/mediamtx/internal/conf" "github.com/bluenviron/mediamtx/internal/conf"
"github.com/bluenviron/mediamtx/internal/logger" "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/bluenviron/mediamtx/internal/restrictnetwork"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )
@ -59,7 +59,7 @@ type Server struct {
PathConfs map[string]*conf.Path PathConfs map[string]*conf.Path
Parent logger.Writer Parent logger.Writer
httpServer *httpserv.WrappedServer httpServer *httpp.WrappedServer
mutex sync.RWMutex mutex sync.RWMutex
} }
@ -76,7 +76,7 @@ func (p *Server) Initialize() error {
network, address := restrictnetwork.Restrict("tcp", p.Address) network, address := restrictnetwork.Restrict("tcp", p.Address)
var err error var err error
p.httpServer, err = httpserv.NewWrappedServer( p.httpServer, err = httpp.NewWrappedServer(
network, network,
address, address,
time.Duration(p.ReadTimeout), time.Duration(p.ReadTimeout),

6
internal/pprof/pprof.go

@ -10,7 +10,7 @@ import (
"github.com/bluenviron/mediamtx/internal/conf" "github.com/bluenviron/mediamtx/internal/conf"
"github.com/bluenviron/mediamtx/internal/logger" "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/bluenviron/mediamtx/internal/restrictnetwork"
) )
@ -24,7 +24,7 @@ type PPROF struct {
ReadTimeout conf.StringDuration ReadTimeout conf.StringDuration
Parent pprofParent Parent pprofParent
httpServer *httpserv.WrappedServer httpServer *httpp.WrappedServer
} }
// Initialize initializes PPROF. // Initialize initializes PPROF.
@ -32,7 +32,7 @@ func (pp *PPROF) Initialize() error {
network, address := restrictnetwork.Restrict("tcp", pp.Address) network, address := restrictnetwork.Restrict("tcp", pp.Address)
var err error var err error
pp.httpServer, err = httpserv.NewWrappedServer( pp.httpServer, err = httpp.NewWrappedServer(
network, network,
address, address,
time.Duration(pp.ReadTimeout), time.Duration(pp.ReadTimeout),

2
internal/protocols/httpserv/handler_exit_on_panic.go → internal/protocols/httpp/handler_exit_on_panic.go

@ -1,4 +1,4 @@
package httpserv package httpp
import ( import (
"fmt" "fmt"

2
internal/protocols/httpserv/handler_filter_requests.go → internal/protocols/httpp/handler_filter_requests.go

@ -1,4 +1,4 @@
package httpserv package httpp
import ( import (
"net/http" "net/http"

2
internal/protocols/httpserv/handler_logger.go → internal/protocols/httpp/handler_logger.go

@ -1,4 +1,4 @@
package httpserv package httpp
import ( import (
"bytes" "bytes"

2
internal/protocols/httpserv/handler_server_header.go → internal/protocols/httpp/handler_server_header.go

@ -1,4 +1,4 @@
package httpserv package httpp
import ( import (
"net/http" "net/http"

2
internal/protocols/httpserv/location_with_trailing_slash.go → internal/protocols/httpp/location_with_trailing_slash.go

@ -1,4 +1,4 @@
package httpserv package httpp
import "net/url" import "net/url"

2
internal/protocols/httpserv/location_with_trailing_slash_test.go → internal/protocols/httpp/location_with_trailing_slash_test.go

@ -1,4 +1,4 @@
package httpserv package httpp
import ( import (
"net/url" "net/url"

2
internal/protocols/httpserv/remote_addr.go → internal/protocols/httpp/remote_addr.go

@ -1,4 +1,4 @@
package httpserv package httpp
import ( import (
"net" "net"

4
internal/protocols/httpserv/wrapped_server.go → internal/protocols/httpp/wrapped_server.go

@ -1,5 +1,5 @@
// Package httpserv contains HTTP server utilities. // Package httpp contains HTTP utilities.
package httpserv package httpp
import ( import (
"context" "context"

2
internal/protocols/httpserv/wrapped_server_test.go → internal/protocols/httpp/wrapped_server_test.go

@ -1,4 +1,4 @@
package httpserv package httpp
import ( import (
"io" "io"

10
internal/servers/hls/http_server.go

@ -15,7 +15,7 @@ import (
"github.com/bluenviron/mediamtx/internal/conf" "github.com/bluenviron/mediamtx/internal/conf"
"github.com/bluenviron/mediamtx/internal/defs" "github.com/bluenviron/mediamtx/internal/defs"
"github.com/bluenviron/mediamtx/internal/logger" "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/bluenviron/mediamtx/internal/restrictnetwork"
) )
@ -43,7 +43,7 @@ type httpServer struct {
pathManager defs.PathManager pathManager defs.PathManager
parent *Server parent *Server
inner *httpserv.WrappedServer inner *httpp.WrappedServer
} }
func (s *httpServer) initialize() error { func (s *httpServer) initialize() error {
@ -64,7 +64,7 @@ func (s *httpServer) initialize() error {
network, address := restrictnetwork.Restrict("tcp", s.address) network, address := restrictnetwork.Restrict("tcp", s.address)
var err error var err error
s.inner, err = httpserv.NewWrappedServer( s.inner, err = httpp.NewWrappedServer(
network, network,
address, address,
time.Duration(s.readTimeout), time.Duration(s.readTimeout),
@ -137,7 +137,7 @@ func (s *httpServer) onRequest(ctx *gin.Context) {
dir, fname = pa, "" dir, fname = pa, ""
if !strings.HasSuffix(dir, "/") { 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) ctx.Writer.WriteHeader(http.StatusMovedPermanently)
return return
} }
@ -170,7 +170,7 @@ func (s *httpServer) onRequest(ctx *gin.Context) {
return 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 // wait some seconds to mitigate brute force attacks
<-time.After(pauseAfterAuthError) <-time.After(pauseAfterAuthError)

4
internal/servers/hls/server.go

@ -11,7 +11,7 @@ import (
"github.com/bluenviron/mediamtx/internal/conf" "github.com/bluenviron/mediamtx/internal/conf"
"github.com/bluenviron/mediamtx/internal/defs" "github.com/bluenviron/mediamtx/internal/defs"
"github.com/bluenviron/mediamtx/internal/logger" "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. // ErrMuxerNotFound is returned when a muxer is not found.
@ -154,7 +154,7 @@ outer:
r.processRequest(&req) r.processRequest(&req)
default: default:
r := s.createMuxer(req.path, httpserv.RemoteAddr(req.ctx)) r := s.createMuxer(req.path, httpp.RemoteAddr(req.ctx))
r.processRequest(&req) r.processRequest(&req)
} }

12
internal/servers/webrtc/http_server.go

@ -17,7 +17,7 @@ import (
"github.com/bluenviron/mediamtx/internal/conf" "github.com/bluenviron/mediamtx/internal/conf"
"github.com/bluenviron/mediamtx/internal/defs" "github.com/bluenviron/mediamtx/internal/defs"
"github.com/bluenviron/mediamtx/internal/logger" "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/protocols/webrtc"
"github.com/bluenviron/mediamtx/internal/restrictnetwork" "github.com/bluenviron/mediamtx/internal/restrictnetwork"
) )
@ -61,7 +61,7 @@ type httpServer struct {
pathManager defs.PathManager pathManager defs.PathManager
parent *Server parent *Server
inner *httpserv.WrappedServer inner *httpp.WrappedServer
} }
func (s *httpServer) initialize() error { func (s *httpServer) initialize() error {
@ -81,7 +81,7 @@ func (s *httpServer) initialize() error {
network, address := restrictnetwork.Restrict("tcp", s.address) network, address := restrictnetwork.Restrict("tcp", s.address)
var err error var err error
s.inner, err = httpserv.NewWrappedServer( s.inner, err = httpp.NewWrappedServer(
network, network,
address, address,
time.Duration(s.readTimeout), time.Duration(s.readTimeout),
@ -129,7 +129,7 @@ func (s *httpServer) checkAuthOutsideSession(ctx *gin.Context, path string, publ
return false 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 // wait some seconds to mitigate brute force attacks
<-time.After(pauseAfterAuthError) <-time.After(pauseAfterAuthError)
@ -178,7 +178,7 @@ func (s *httpServer) onWHIPPost(ctx *gin.Context, path string, publish bool) {
res := s.parent.newSession(webRTCNewSessionReq{ res := s.parent.newSession(webRTCNewSessionReq{
pathName: path, pathName: path,
remoteAddr: httpserv.RemoteAddr(ctx), remoteAddr: httpp.RemoteAddr(ctx),
query: ctx.Request.URL.RawQuery, query: ctx.Request.URL.RawQuery,
user: user, user: user,
pass: pass, 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) 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] != '/': 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) ctx.Writer.WriteHeader(http.StatusMovedPermanently)
default: default:

Loading…
Cancel
Save