Skip to content

Commit 3717bef

Browse files
author
Al S-M
committed
add other schemes to connection url
and remove fallthroughs, don't think they help clarity
1 parent ac0513a commit 3717bef

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

netconn.go

+2-6
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func openConnection(uri *url.URL, tlsc *tls.Config, timeout time.Duration, heade
3939
case "wss":
4040
conn, err := NewWebsocket(uri.String(), tlsc, timeout, headers)
4141
return conn, err
42-
case "tcp":
42+
case "mqtt", "tcp":
4343
allProxy := os.Getenv("all_proxy")
4444
if len(allProxy) == 0 {
4545
conn, err := net.DialTimeout("tcp", uri.Host, timeout)
@@ -61,11 +61,7 @@ func openConnection(uri *url.URL, tlsc *tls.Config, timeout time.Duration, heade
6161
return nil, err
6262
}
6363
return conn, nil
64-
case "ssl":
65-
fallthrough
66-
case "tls":
67-
fallthrough
68-
case "tcps":
64+
case "ssl", "tls", "mqtts", "mqtt+ssl", "tcps":
6965
allProxy := os.Getenv("all_proxy")
7066
if len(allProxy) == 0 {
7167
conn, err := tls.DialWithDialer(&net.Dialer{Timeout: timeout}, "tcp", uri.Host, tlsc)

unit_router_test.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func Test_AddRoute(t *testing.T) {
4343
}
4444

4545
func Test_AddRoute_Wildcards(t *testing.T) {
46-
router, _ := newRouter()
46+
router := newRouter()
4747
cb := func(client Client, msg Message) {
4848
}
4949
router.addRoute("#", cb)
@@ -55,15 +55,16 @@ func Test_AddRoute_Wildcards(t *testing.T) {
5555
}
5656

5757
func Test_DeleteRoute_Wildcards(t *testing.T) {
58-
router, _ := newRouter()
58+
router := newRouter()
5959
cb := func(client Client, msg Message) {
6060
}
6161
router.addRoute("#", cb)
6262
router.addRoute("topic1", cb)
6363
router.deleteRoute("topic1")
64-
64+
6565
expected := "#"
66-
got := router.routes.Front().Value.(*route).topic; if !(router.routes.Front().Value.(*route).topic == "#") {
66+
got := router.routes.Front().Value.(*route).topic
67+
if !(router.routes.Front().Value.(*route).topic == "#") {
6768
t.Fatalf("deleteRoute deleted wrong route when wildcards are used, got topic '%s', expected route with topic '%s'", got, expected)
6869
}
6970
}

0 commit comments

Comments
 (0)