Skip to content

Commit 1c6db08

Browse files
mingshunvangie
authored andcommitted
fix: device-connect on https
1 parent 5b6dd9e commit 1c6db08

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

packages/cli/internal/server/device_keeper.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package server
22

33
import (
4+
"crypto/tls"
45
"io"
56
"log"
67
"net"
@@ -21,6 +22,12 @@ import (
2122
"k8s.io/utils/keymutex"
2223
)
2324

25+
var deviceConnectClient = &http.Client{
26+
Transport: &http.Transport{
27+
TLSNextProto: make(map[string]func(authority string, c *tls.Conn) http.RoundTripper),
28+
},
29+
}
30+
2431
type DeviceKeeper struct {
2532
adbClient *adb.Adb
2633
deviceWatcher *adb.DeviceWatcher
@@ -233,7 +240,7 @@ func connectAP(url, token, protocol, serial string) (*smux.Session, error) {
233240
req.Header.Set("Upgrade", protocol)
234241
req.Header.Set("User-Agent", "GBOX-cli")
235242
req.Header.Set("Authorization", "Bearer "+token)
236-
resp, err := http.DefaultClient.Do(req)
243+
resp, err := deviceConnectClient.Do(req)
237244
if err != nil {
238245
return nil, errors.Wrapf(err, "failed to connect to access point %s via %s protocol", url, protocol)
239246
}
@@ -262,7 +269,7 @@ func connectAP(url, token, protocol, serial string) (*smux.Session, error) {
262269
func (dm *DeviceKeeper) processDeviceSession(session *DeviceSession, serial string) {
263270
defer func() {
264271
if r := recover(); r != nil {
265-
log.Printf("recovered from device %s processDeviceSession goroutine: %v", serial, r)
272+
log.Printf("recovered from device %s processDeviceSession goroutine: %v: %s", serial, r, string(debug.Stack()))
266273
}
267274
}()
268275

0 commit comments

Comments
 (0)