Files
go-sip/internal/dispatcher/rejected_data.go
T

31 lines
896 B
Go

package dispatcher
import (
"context"
"crypto/sha256"
"encoding/hex"
"errors"
"log/slog"
"git.ipao.vip/rogee/go-sip/internal/store"
)
func (r *Runtime) rejectInvalidData(ctx context.Context, queue, routing string, raw []byte, cause error) error {
originalCause := cause
if !r.Broker.OwnsRejectionRoute(queue, routing) {
cause = store.ErrUnidentifiableData
} else {
cause = r.Bootstrap.Store.RejectData(r.Bootstrap.DispatcherID, raw, cause)
}
if errors.Is(cause, store.ErrUnidentifiableData) {
sum := sha256.Sum256(raw)
slog.ErrorContext(ctx, "unidentifiable incoming garbage discarded", "queue", queue, "bytes", len(raw), "body_sha256", hex.EncodeToString(sum[:]), "reason", originalCause)
return nil
}
if cause != nil {
return cause
}
slog.WarnContext(ctx, "incoming data rejected; original and feedback persisted", "queue", queue, "bytes", len(raw))
return nil
}