• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ghettovoice / gosip / 20275641102

16 Dec 2025 04:42PM UTC coverage: 40.889% (-33.6%) from 74.523%
20275641102

push

github

ghettovoice
Refactor SIP stack with transaction/transport layers and improved API

- Implement TransactionLayer with request/response routing and graceful shutdown
- Add TransportLayer for centralized transport management
- Client/server transaction implementation with persistence support
- Add transaction factories and automatic cleanup on termination
- Introduce InboundMessage/OutboundMessage wrappers with type-safe accessors
- Add StatsRecorder interface for transport statistics
- Consolidate Send/Render/NewResponse methods with optional options
- Add log package with context-based logger
- Support compact header rendering
- Message RTT calculation
- Optimization: upgrade abnf lib, fix race conditions, read timeouts
- Improve error handling and validation
- Add comprehensive test coverage

7324 of 19365 new or added lines in 110 files covered. (37.82%)

19 existing lines in 3 files now uncovered.

8439 of 20639 relevant lines covered (40.89%)

8.25 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

52.38
/header/proxy_authorization.go
1
package header
2

3
import (
4
        "errors"
5
        "fmt"
6
        "io"
7
        "strconv"
8

9
        "braces.dev/errtrace"
10
        "github.com/ghettovoice/abnf"
11

12
        "github.com/ghettovoice/gosip/internal/errorutil"
13
        "github.com/ghettovoice/gosip/internal/ioutil"
14
        "github.com/ghettovoice/gosip/internal/util"
15
)
16

17
type ProxyAuthorization Authorization
18

19
func (*ProxyAuthorization) CanonicName() Name { return "Proxy-Authorization" }
6✔
20

NEW
21
func (*ProxyAuthorization) CompactName() Name { return "Proxy-Authorization" }
×
22

23
func (hdr *ProxyAuthorization) RenderTo(w io.Writer, opts *RenderOptions) (num int, err error) {
7✔
24
        if hdr == nil {
8✔
25
                return 0, nil
1✔
26
        }
1✔
27

28
        cw := ioutil.GetCountingWriter(w)
6✔
29
        defer ioutil.FreeCountingWriter(cw)
6✔
30
        cw.Fprint(hdr.CanonicName(), ": ")
6✔
31
        cw.Call(func(w io.Writer) (int, error) {
12✔
32
                return errtrace.Wrap2((*Authorization)(hdr).renderValueTo(w, opts))
6✔
33
        })
6✔
34
        return errtrace.Wrap2(cw.Result())
6✔
35
}
36

37
func (hdr *ProxyAuthorization) Render(opts *RenderOptions) string {
5✔
38
        if hdr == nil {
6✔
39
                return ""
1✔
40
        }
1✔
41

42
        sb := util.GetStringBuilder()
4✔
43
        defer util.FreeStringBuilder(sb)
4✔
44
        hdr.RenderTo(sb, opts) //nolint:errcheck
4✔
45
        return sb.String()
4✔
46
}
47

48
func (hdr *ProxyAuthorization) RenderValue() string {
3✔
49
        return (*Authorization)(hdr).RenderValue()
3✔
50
}
3✔
51

52
func (hdr *ProxyAuthorization) String() string { return hdr.RenderValue() }
3✔
53

NEW
54
func (hdr *ProxyAuthorization) Format(f fmt.State, verb rune) {
×
NEW
55
        switch verb {
×
NEW
56
        case 's':
×
NEW
57
                if f.Flag('+') {
×
NEW
58
                        hdr.RenderTo(f, nil) //nolint:errcheck
×
NEW
59
                        return
×
NEW
60
                }
×
NEW
61
                fmt.Fprint(f, hdr.String())
×
NEW
62
                return
×
NEW
63
        case 'q':
×
NEW
64
                if f.Flag('+') {
×
NEW
65
                        fmt.Fprint(f, strconv.Quote(hdr.Render(nil)))
×
NEW
66
                        return
×
NEW
67
                }
×
NEW
68
                fmt.Fprint(f, strconv.Quote(hdr.String()))
×
NEW
69
                return
×
NEW
70
        default:
×
NEW
71
                type hideMethods ProxyAuthorization
×
NEW
72
                type ProxyAuthorization hideMethods
×
NEW
73
                fmt.Fprintf(f, fmt.FormatString(f, verb), (*ProxyAuthorization)(hdr))
×
NEW
74
                return
×
75
        }
76
}
77

78
func (hdr *ProxyAuthorization) Clone() Header {
5✔
79
        hdr2, ok := (*Authorization)(hdr).Clone().(*Authorization)
5✔
80
        if !ok {
6✔
81
                return nil
1✔
82
        }
1✔
83
        return (*ProxyAuthorization)(hdr2)
4✔
84
}
85

86
func (hdr *ProxyAuthorization) Equal(val any) bool {
21✔
87
        var other *ProxyAuthorization
21✔
88
        switch v := val.(type) {
21✔
89
        case ProxyAuthorization:
1✔
90
                other = &v
1✔
91
        case *ProxyAuthorization:
19✔
92
                other = v
19✔
93
        default:
1✔
94
                return false
1✔
95
        }
96
        return (*Authorization)(hdr).Equal((*Authorization)(other))
20✔
97
}
98

99
func (hdr *ProxyAuthorization) IsValid() bool { return (*Authorization)(hdr).IsValid() }
6✔
100

NEW
101
func (hdr *ProxyAuthorization) MarshalJSON() ([]byte, error) {
×
NEW
102
        return errtrace.Wrap2(ToJSON(hdr))
×
NEW
103
}
×
104

105
var zeroProxyAuthorization ProxyAuthorization
106

NEW
107
func (hdr *ProxyAuthorization) UnmarshalJSON(data []byte) error {
×
NEW
108
        gh, err := FromJSON(data)
×
NEW
109
        if err != nil {
×
NEW
110
                *hdr = zeroProxyAuthorization
×
NEW
111
                if errors.Is(err, errNotHeaderJSON) {
×
NEW
112
                        return nil
×
NEW
113
                }
×
NEW
114
                return errtrace.Wrap(err)
×
115
        }
116

NEW
117
        h, ok := gh.(*ProxyAuthorization)
×
NEW
118
        if !ok {
×
NEW
119
                *hdr = zeroProxyAuthorization
×
NEW
120
                return errtrace.Wrap(errorutil.Errorf("unexpected header: got %T, want %T", gh, hdr))
×
NEW
121
        }
×
122

NEW
123
        *hdr = *h
×
NEW
124
        return nil
×
125
}
126

127
func buildFromProxyAuthorizationNode(node *abnf.Node) *ProxyAuthorization {
3✔
128
        return (*ProxyAuthorization)(buildFromAuthorizationNode(node))
3✔
129
}
3✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc