fix: setup device and driver

This commit is contained in:
lilong.129
2025-02-18 18:04:18 +08:00
parent c8f7e2fa70
commit 7b052f0d98
14 changed files with 175 additions and 149 deletions

View File

@@ -270,24 +270,17 @@ func (s *DriverSession) RequestWithRetry(method string, rawURL string, rawBody [
return
}
func (s *DriverSession) InitConnection(localPort int) error {
func (s *DriverSession) SetupPortForward(localPort int) error {
conn, err := net.Dial("tcp", fmt.Sprintf("127.0.0.1:%d", localPort))
if err != nil {
return fmt.Errorf("create tcp connection error %v", err)
}
s.client = NewHTTPClientWithConnection(conn, s.timeout)
return nil
}
func NewHTTPClientWithConnection(conn net.Conn, timeout time.Duration) *http.Client {
return &http.Client{
Transport: &http.Transport{
DialContext: func(_ context.Context, _, _ string) (net.Conn, error) {
return conn, nil
},
s.client.Transport = &http.Transport{
DialContext: func(_ context.Context, _, _ string) (net.Conn, error) {
return conn, nil
},
Timeout: timeout,
}
return nil
}
type DriverRawResponse []byte