Skip to content

Commit

Permalink
fix: use default port definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
InnovativeUS committed Nov 27, 2024
1 parent e11ca47 commit 7304a2c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions sip/parse_uri_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func TestParseUri(t *testing.T) {
assert.Equal(t, "alice", uri.User)
assert.Equal(t, "atlanta.com", uri.Host)
assert.False(t, uri.IsEncrypted())
assert.Equal(t, "atlanta.com:5060", uri.HostPort())
}

testCases = []string{
Expand All @@ -63,6 +64,7 @@ func TestParseUri(t *testing.T) {
assert.Equal(t, "alice", uri.User)
assert.Equal(t, "atlanta.com", uri.Host)
assert.True(t, uri.IsEncrypted())
assert.Equal(t, "atlanta.com:5061", uri.HostPort())
}

})
Expand Down
12 changes: 11 additions & 1 deletion sip/uri.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,16 @@ func (uri *Uri) Addr() string {

// HostPort represents host:port part
func (uri *Uri) HostPort() string {
p := strconv.Itoa(uri.Port)
transport := TransportTCP
if uri.IsEncrypted() {
transport = TransportTLS
}

port := uri.Port
if port == 0 {
port = DefaultPort(transport)
}

p := strconv.Itoa(port)
return uri.Host + ":" + p
}

0 comments on commit 7304a2c

Please sign in to comment.