From 454ccf4b05bc9433d424157ed331e24df5ec1930 Mon Sep 17 00:00:00 2001 From: InnovativeUS <86477631+InnovativeUS@users.noreply.github.com> Date: Sat, 15 Jun 2024 07:57:30 +0100 Subject: [PATCH 1/6] fix(sip): default the SIP URI port to 5060 if it is not provided --- sip/uri.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sip/uri.go b/sip/uri.go index b002843..db5b40a 100644 --- a/sip/uri.go +++ b/sip/uri.go @@ -132,5 +132,9 @@ func (uri *Uri) Addr() string { // HostPort represents host:port part func (uri *Uri) HostPort() string { p := strconv.Itoa(uri.Port) + // Default the SIP port if it is not provided + if p == "0" { + p = "5060" + } return uri.Host + ":" + p } From f56d04202ff569f8aeb09b95f2d79b9a6f83dce1 Mon Sep 17 00:00:00 2001 From: InnovativeUS <86477631+InnovativeUS@users.noreply.github.com> Date: Sat, 15 Jun 2024 08:06:26 +0100 Subject: [PATCH 2/6] fix: update mod --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 089f33f..e85a644 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/emiago/sipgo +module github.com/InnovativeUS/sipgo go 1.20 From 0a4634d296865abc814e1a4d5e55c40081f80d93 Mon Sep 17 00:00:00 2001 From: InnovativeUS <86477631+InnovativeUS@users.noreply.github.com> Date: Wed, 27 Nov 2024 03:04:27 +0000 Subject: [PATCH 3/6] revert: module rename --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 2469e8f..456d138 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/InnovativeUS/sipgo +module github.com/emiago/sipgo go 1.20 From 7377f846552b57f1f1a4b349f41d7f1ba6e2f317 Mon Sep 17 00:00:00 2001 From: InnovativeUS <86477631+InnovativeUS@users.noreply.github.com> Date: Wed, 27 Nov 2024 03:08:15 +0000 Subject: [PATCH 4/6] chore: revert uri change --- sip/uri.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/sip/uri.go b/sip/uri.go index 0cd3055..4c953bb 100644 --- a/sip/uri.go +++ b/sip/uri.go @@ -146,9 +146,5 @@ func (uri *Uri) Addr() string { // HostPort represents host:port part func (uri *Uri) HostPort() string { p := strconv.Itoa(uri.Port) - // Default the SIP port if it is not provided - if p == "0" { - p = "5060" - } return uri.Host + ":" + p } From 7304a2cf74ac63c1d05bf348aefb20f0f770bddb Mon Sep 17 00:00:00 2001 From: InnovativeUS <86477631+InnovativeUS@users.noreply.github.com> Date: Wed, 27 Nov 2024 03:30:36 +0000 Subject: [PATCH 5/6] fix: use default port definitions --- sip/parse_uri_test.go | 2 ++ sip/uri.go | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/sip/parse_uri_test.go b/sip/parse_uri_test.go index 33a0fa5..26f442c 100644 --- a/sip/parse_uri_test.go +++ b/sip/parse_uri_test.go @@ -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{ @@ -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()) } }) diff --git a/sip/uri.go b/sip/uri.go index 4c953bb..c0779aa 100644 --- a/sip/uri.go +++ b/sip/uri.go @@ -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 } From 5754110839d131d43b612edd4fb22bd17ff7d2f5 Mon Sep 17 00:00:00 2001 From: InnovativeUS <86477631+InnovativeUS@users.noreply.github.com> Date: Wed, 27 Nov 2024 04:22:14 +0000 Subject: [PATCH 6/6] test: remove test cross pollination --- sip/parse_uri_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/sip/parse_uri_test.go b/sip/parse_uri_test.go index 26f442c..4f54911 100644 --- a/sip/parse_uri_test.go +++ b/sip/parse_uri_test.go @@ -39,6 +39,7 @@ func TestParseUri(t *testing.T) { }) t.Run("sip case insensitive", func(t *testing.T) { + uri = Uri{} testCases := []string{ "sip:alice@atlanta.com", "SIP:alice@atlanta.com",