mirror of
https://github.com/bluenviron/mediamtx
synced 2025-02-21 22:16:52 +00:00
tidy up logs
This commit is contained in:
parent
bc9cbc8605
commit
9bab230e0d
@ -475,7 +475,7 @@ There are multiple ways to monitor the server usage over time:
|
||||
* The current number of clients, publishers and readers is printed in each log line; for instance, the line:
|
||||
|
||||
```
|
||||
2020/01/01 00:00:00 [3/2] [client 127.0.0.1:44428] OPTION
|
||||
2020/01/01 00:00:00 [3/2] [conn 127.0.0.1:44428] OPTION
|
||||
```
|
||||
|
||||
means that there are 3 publishers and 2 readers.
|
||||
|
@ -235,7 +235,7 @@ func (c *Converter) run() {
|
||||
|
||||
go func() {
|
||||
for req := range c.request {
|
||||
req.W.WriteHeader(http.StatusInternalServerError)
|
||||
req.W.WriteHeader(http.StatusNotFound)
|
||||
req.Res <- nil
|
||||
}
|
||||
}()
|
||||
@ -338,6 +338,8 @@ func (c *Converter) runInner(ctx context.Context) error {
|
||||
c.path.OnReadPublisherPlay(readpublisher.PlayReq{c, resc}) //nolint:govet
|
||||
<-resc
|
||||
|
||||
c.log(logger.Info, "is converting into HLS")
|
||||
|
||||
writerDone := make(chan error)
|
||||
go func() {
|
||||
writerDone <- func() error {
|
||||
@ -496,14 +498,14 @@ func (c *Converter) runInner(ctx context.Context) error {
|
||||
if time.Since(t) >= closeAfterInactivity {
|
||||
c.ringBuffer.Close()
|
||||
<-writerDone
|
||||
return fmt.Errorf("TODO")
|
||||
return nil
|
||||
}
|
||||
|
||||
case err := <-writerDone:
|
||||
return err
|
||||
|
||||
case <-ctx.Done():
|
||||
return fmt.Errorf("TODO")
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,9 +15,9 @@ import (
|
||||
"github.com/aler9/rtsp-simple-server/internal/externalcmd"
|
||||
"github.com/aler9/rtsp-simple-server/internal/logger"
|
||||
"github.com/aler9/rtsp-simple-server/internal/readpublisher"
|
||||
"github.com/aler9/rtsp-simple-server/internal/source"
|
||||
"github.com/aler9/rtsp-simple-server/internal/rtmpsource"
|
||||
"github.com/aler9/rtsp-simple-server/internal/rtspsource"
|
||||
"github.com/aler9/rtsp-simple-server/internal/source"
|
||||
"github.com/aler9/rtsp-simple-server/internal/stats"
|
||||
"github.com/aler9/rtsp-simple-server/internal/streamproc"
|
||||
)
|
||||
|
@ -2,6 +2,7 @@ package rtmpconn
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
@ -141,7 +142,7 @@ func (c *Conn) IsReadPublisher() {}
|
||||
func (c *Conn) IsSource() {}
|
||||
|
||||
func (c *Conn) log(level logger.Level, format string, args ...interface{}) {
|
||||
c.parent.Log(level, "[client %v] "+format, append([]interface{}{c.conn.NetConn().RemoteAddr()}, args...)...)
|
||||
c.parent.Log(level, "[conn %v] "+format, append([]interface{}{c.conn.NetConn().RemoteAddr()}, args...)...)
|
||||
}
|
||||
|
||||
func (c *Conn) ip() net.IP {
|
||||
@ -223,9 +224,10 @@ func (c *Conn) runRead(ctx context.Context) error {
|
||||
res := <-sres
|
||||
|
||||
if res.Err != nil {
|
||||
if _, ok := res.Err.(readpublisher.ErrAuthCritical); ok {
|
||||
if terr, ok := res.Err.(readpublisher.ErrAuthCritical); ok {
|
||||
// wait some seconds to stop brute force attacks
|
||||
<-time.After(pauseAfterAuthError)
|
||||
return errors.New(terr.Message)
|
||||
}
|
||||
return res.Err
|
||||
}
|
||||
@ -403,9 +405,10 @@ func (c *Conn) runPublish(ctx context.Context) error {
|
||||
res := <-resc
|
||||
|
||||
if res.Err != nil {
|
||||
if _, ok := res.Err.(readpublisher.ErrAuthCritical); ok {
|
||||
if terr, ok := res.Err.(readpublisher.ErrAuthCritical); ok {
|
||||
// wait some seconds to stop brute force attacks
|
||||
<-time.After(pauseAfterAuthError)
|
||||
return errors.New(terr.Message)
|
||||
}
|
||||
return res.Err
|
||||
}
|
||||
@ -529,7 +532,9 @@ func (c *Conn) validateCredentials(
|
||||
|
||||
if query.Get("user") != pathUser ||
|
||||
query.Get("pass") != pathPass {
|
||||
return readpublisher.ErrAuthCritical{}
|
||||
return readpublisher.ErrAuthCritical{
|
||||
Message: "wrong username or password",
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -5,9 +5,9 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/aler9/rtsp-simple-server/internal/rtmpconn"
|
||||
"github.com/aler9/rtsp-simple-server/internal/logger"
|
||||
"github.com/aler9/rtsp-simple-server/internal/pathman"
|
||||
"github.com/aler9/rtsp-simple-server/internal/rtmpconn"
|
||||
"github.com/aler9/rtsp-simple-server/internal/stats"
|
||||
)
|
||||
|
||||
|
@ -11,9 +11,9 @@ import (
|
||||
"github.com/aler9/gortsplib"
|
||||
"github.com/aler9/gortsplib/pkg/base"
|
||||
|
||||
"github.com/aler9/rtsp-simple-server/internal/rtspconn"
|
||||
"github.com/aler9/rtsp-simple-server/internal/logger"
|
||||
"github.com/aler9/rtsp-simple-server/internal/pathman"
|
||||
"github.com/aler9/rtsp-simple-server/internal/rtspconn"
|
||||
"github.com/aler9/rtsp-simple-server/internal/rtspsession"
|
||||
"github.com/aler9/rtsp-simple-server/internal/stats"
|
||||
)
|
||||
|
@ -11,10 +11,10 @@ import (
|
||||
"github.com/aler9/gortsplib/pkg/base"
|
||||
"github.com/aler9/gortsplib/pkg/headers"
|
||||
|
||||
"github.com/aler9/rtsp-simple-server/internal/rtspconn"
|
||||
"github.com/aler9/rtsp-simple-server/internal/externalcmd"
|
||||
"github.com/aler9/rtsp-simple-server/internal/logger"
|
||||
"github.com/aler9/rtsp-simple-server/internal/readpublisher"
|
||||
"github.com/aler9/rtsp-simple-server/internal/rtspconn"
|
||||
"github.com/aler9/rtsp-simple-server/internal/streamproc"
|
||||
)
|
||||
|
||||
@ -22,8 +22,6 @@ const (
|
||||
pauseAfterAuthError = 2 * time.Second
|
||||
)
|
||||
|
||||
var errTerminated = errors.New("terminated")
|
||||
|
||||
// PathMan is implemented by pathman.PathMan.
|
||||
type PathMan interface {
|
||||
OnReadPublisherSetupPlay(readpublisher.SetupPlayReq)
|
||||
@ -195,11 +193,10 @@ func (s *Session) OnSetup(c *rtspconn.Conn, ctx *gortsplib.ServerHandlerOnSetupC
|
||||
return terr.Response, nil
|
||||
|
||||
case readpublisher.ErrAuthCritical:
|
||||
s.log(logger.Info, "ERR: %v", terr.Message)
|
||||
|
||||
// wait some seconds to stop brute force attacks
|
||||
<-time.After(pauseAfterAuthError)
|
||||
return terr.Response, errTerminated
|
||||
|
||||
return terr.Response, errors.New(terr.Message)
|
||||
|
||||
case readpublisher.ErrNoOnePublishing:
|
||||
return &base.Response{
|
||||
|
2
main.go
2
main.go
@ -11,12 +11,12 @@ import (
|
||||
|
||||
"github.com/aler9/rtsp-simple-server/internal/conf"
|
||||
"github.com/aler9/rtsp-simple-server/internal/confwatcher"
|
||||
"github.com/aler9/rtsp-simple-server/internal/hlsserver"
|
||||
"github.com/aler9/rtsp-simple-server/internal/logger"
|
||||
"github.com/aler9/rtsp-simple-server/internal/metrics"
|
||||
"github.com/aler9/rtsp-simple-server/internal/pathman"
|
||||
"github.com/aler9/rtsp-simple-server/internal/pprof"
|
||||
"github.com/aler9/rtsp-simple-server/internal/rlimit"
|
||||
"github.com/aler9/rtsp-simple-server/internal/hlsserver"
|
||||
"github.com/aler9/rtsp-simple-server/internal/rtmpserver"
|
||||
"github.com/aler9/rtsp-simple-server/internal/rtspserver"
|
||||
"github.com/aler9/rtsp-simple-server/internal/stats"
|
||||
|
Loading…
Reference in New Issue
Block a user