Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log auth attempts. #241

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions pkg/sip/outbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (c *Client) newCall(ctx context.Context, conf *config.Config, log logger.Lo
call := &outboundCall{
c: c,
log: log,
cc: c.newOutbound(id, URI{
cc: c.newOutbound(log, id, URI{
User: sipConf.from,
Host: sipConf.host,
Addr: contact.Addr,
Expand Down Expand Up @@ -516,7 +516,7 @@ func (c *outboundCall) transferCall(ctx context.Context, transferTo string, dial
return nil
}

func (c *Client) newOutbound(id LocalTag, from, contact URI) *sipOutbound {
func (c *Client) newOutbound(log logger.Logger, id LocalTag, from, contact URI) *sipOutbound {
from = from.Normalize()
fromHeader := &sip.FromHeader{
DisplayName: from.User,
Expand All @@ -528,6 +528,7 @@ func (c *Client) newOutbound(id LocalTag, from, contact URI) *sipOutbound {
}
fromHeader.Params.Add("tag", string(id))
return &sipOutbound{
log: log,
c: c,
id: id,
from: fromHeader,
Expand All @@ -537,6 +538,7 @@ func (c *Client) newOutbound(id LocalTag, from, contact URI) *sipOutbound {
}

type sipOutbound struct {
log logger.Logger
c *Client
id LocalTag
from *sip.FromHeader
Expand Down Expand Up @@ -648,6 +650,11 @@ authLoop:
authHeaderName = "Proxy-Authenticate"
authHeaderRespName = "Proxy-Authorization"
}
cid := ""
if h := resp.CallID(); h != nil {
cid = h.Value()
}
c.log.Infow("auth requested", "sipCallID", cid, "status", resp.StatusCode, "body", string(resp.Body()))
// auth required
if user == "" || pass == "" {
return nil, errors.New("server required auth, but no username or password was provided")
Expand Down
3 changes: 3 additions & 0 deletions pkg/sip/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,9 @@ func LoggerWithParams(log logger.Logger, c Signaling) logger.Logger {
if tag := c.Tag(); tag != "" {
log = log.WithValues("sipTag", tag)
}
if cid := c.CallID(); cid != "" {
log = log.WithValues("sipCallID", cid)
}
return log
}

Expand Down
Loading