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

ghettovoice / gosip / 20275310719

16 Dec 2025 04:28PM UTC coverage: 40.903% (-33.8%) from 74.691%
20275310719

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

7327 of 19365 new or added lines in 110 files covered. (37.84%)

19 existing lines in 3 files now uncovered.

8442 of 20639 relevant lines covered (40.9%)

8.24 hits per line

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

50.59
/header/proxy_require.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
// ProxyRequire represents the Proxy-Require header field.
18
// The Proxy-Require header field is used to indicate proxy-sensitive features that must be supported by the proxy.
19
type ProxyRequire Require
20

21
// CanonicName returns the canonical name of the header.
22
func (ProxyRequire) CanonicName() Name { return "Proxy-Require" }
5✔
23

24
// CompactName returns the compact name of the header (Proxy-Require has no compact form).
NEW
25
func (ProxyRequire) CompactName() Name { return "Proxy-Require" }
×
26

27
// RenderTo writes the header to the provided writer.
28
func (hdr ProxyRequire) RenderTo(w io.Writer, _ *RenderOptions) (num int, err error) {
6✔
29
        if hdr == nil {
7✔
30
                return 0, nil
1✔
31
        }
1✔
32

33
        cw := ioutil.GetCountingWriter(w)
5✔
34
        defer ioutil.FreeCountingWriter(cw)
5✔
35
        cw.Fprint(hdr.CanonicName(), ": ")
5✔
36
        cw.Call(Require(hdr).renderValueTo)
5✔
37
        return errtrace.Wrap2(cw.Result())
5✔
38
}
39

40
// RenderOptions returns the string representation of the header.
41
func (hdr ProxyRequire) Render(opts *RenderOptions) string {
4✔
42
        if hdr == nil {
5✔
43
                return ""
1✔
44
        }
1✔
45

46
        sb := util.GetStringBuilder()
3✔
47
        defer util.FreeStringBuilder(sb)
3✔
48
        hdr.RenderTo(sb, opts) //nolint:errcheck
3✔
49
        return sb.String()
3✔
50
}
51

52
// RenderValue returns the header value without the name prefix.
53
func (hdr ProxyRequire) RenderValue() string {
3✔
54
        return Require(hdr).RenderValue()
3✔
55
}
3✔
56

57
// String returns the string representation of the header value.
58
func (hdr ProxyRequire) String() string { return hdr.RenderValue() }
3✔
59

60
// Format implements fmt.Formatter for custom formatting of the header.
NEW
61
func (hdr ProxyRequire) Format(f fmt.State, verb rune) {
×
NEW
62
        switch verb {
×
NEW
63
        case 's':
×
NEW
64
                if f.Flag('+') {
×
NEW
65
                        hdr.RenderTo(f, nil) //nolint:errcheck
×
NEW
66
                        return
×
NEW
67
                }
×
NEW
68
                fmt.Fprint(f, hdr.String())
×
NEW
69
                return
×
NEW
70
        case 'q':
×
NEW
71
                if f.Flag('+') {
×
NEW
72
                        fmt.Fprint(f, strconv.Quote(hdr.Render(nil)))
×
NEW
73
                        return
×
NEW
74
                }
×
NEW
75
                fmt.Fprint(f, strconv.Quote(hdr.String()))
×
NEW
76
                return
×
NEW
77
        default:
×
NEW
78
                type hideMethods ProxyRequire
×
NEW
79
                type ProxyRequire hideMethods
×
NEW
80
                fmt.Fprintf(f, fmt.FormatString(f, verb), ProxyRequire(hdr))
×
NEW
81
                return
×
82
        }
83
}
84

85
// Clone returns a copy of the header.
86
func (hdr ProxyRequire) Clone() Header {
3✔
87
        hdr2, ok := Require(hdr).Clone().(Require)
3✔
88
        if !ok {
3✔
NEW
89
                return nil
×
NEW
90
        }
×
91
        return ProxyRequire(hdr2)
3✔
92
}
93

94
// Equal compares this header with another for equality.
95
func (hdr ProxyRequire) Equal(val any) bool {
17✔
96
        var other ProxyRequire
17✔
97
        switch v := val.(type) {
17✔
98
        case ProxyRequire:
14✔
99
                other = v
14✔
100
        case *ProxyRequire:
2✔
101
                if v == nil {
3✔
102
                        return false
1✔
103
                }
1✔
104
                other = *v
1✔
105
        default:
1✔
106
                return false
1✔
107
        }
108
        return Require(hdr).Equal(Require(other))
15✔
109
}
110

111
// IsValid checks whether the header is syntactically valid.
112
func (hdr ProxyRequire) IsValid() bool { return Require(hdr).IsValid() }
4✔
113

NEW
114
func (hdr ProxyRequire) MarshalJSON() ([]byte, error) {
×
NEW
115
        return errtrace.Wrap2(ToJSON(hdr))
×
NEW
116
}
×
117

NEW
118
func (hdr *ProxyRequire) UnmarshalJSON(data []byte) error {
×
NEW
119
        gh, err := FromJSON(data)
×
NEW
120
        if err != nil {
×
NEW
121
                *hdr = nil
×
NEW
122
                if errors.Is(err, errNotHeaderJSON) {
×
NEW
123
                        return nil
×
NEW
124
                }
×
NEW
125
                return errtrace.Wrap(err)
×
126
        }
127

NEW
128
        h, ok := gh.(ProxyRequire)
×
NEW
129
        if !ok {
×
NEW
130
                *hdr = nil
×
NEW
131
                return errtrace.Wrap(errorutil.Errorf("unexpected header: got %T, want %T", gh, *hdr))
×
NEW
132
        }
×
133

NEW
134
        *hdr = h
×
NEW
135
        return nil
×
136
}
137

138
func buildFromProxyRequireNode(node *abnf.Node) ProxyRequire {
1✔
139
        return ProxyRequire(buildFromRequireNode(node))
1✔
140
}
1✔
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