mirror of
https://github.com/v2fly/v2ray-core.git
synced 2026-10-19 16:17:34 +00:00
finish inverse role server support for webtunnel: fix lint
This commit is contained in:
committed by
Xiaokang Wang (Shelikhoo)
parent
8d0d8f8fd1
commit
f830d1253b
+1
-1
@@ -79,7 +79,7 @@ var cmdGenerateToken = &base.Command{
|
||||
|
||||
if *genOut != "" {
|
||||
content := fmt.Sprintf("private: %s\npublic: %s\n", b64Priv, b64Pub)
|
||||
if err := os.WriteFile(*genOut, []byte(content), 0600); err != nil {
|
||||
if err := os.WriteFile(*genOut, []byte(content), 0o600); err != nil {
|
||||
base.Fatalf("failed to write tokens to file %q: %v", *genOut, err)
|
||||
}
|
||||
if _, err := fmt.Fprintf(os.Stdout, "wrote base64 tokens to %s\n", *genOut); err != nil {
|
||||
|
||||
+9
-24
@@ -1,6 +1,7 @@
|
||||
package httpenrollmentconfirmation
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/base32"
|
||||
"net"
|
||||
"net/http"
|
||||
@@ -8,7 +9,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/v2fly/v2ray-core/v5/common"
|
||||
"github.com/v2fly/v2ray-core/v5/common/signal/done"
|
||||
"github.com/v2fly/v2ray-core/v5/transport/internet/tlsmirror"
|
||||
"github.com/v2fly/v2ray-core/v5/transport/internet/tlsmirror/httponconnection"
|
||||
)
|
||||
@@ -83,31 +83,16 @@ func (c *clientRoundtripper) roundTrip(request *http.Request) (*http.Response, e
|
||||
}
|
||||
defer c.currentConnLock.RUnlock()
|
||||
|
||||
timeoutTimer := time.NewTimer(30 * time.Second)
|
||||
defer timeoutTimer.Stop()
|
||||
|
||||
waitForConnection := done.New()
|
||||
|
||||
var resp *http.Response
|
||||
var error_resp_ error
|
||||
var err error
|
||||
|
||||
go func() {
|
||||
resp_, err_ := c.currentConn.RoundTrip(request)
|
||||
resp = resp_
|
||||
error_resp_ = err_
|
||||
waitForConnection.Close()
|
||||
}()
|
||||
|
||||
select {
|
||||
case <-timeoutTimer.C:
|
||||
err = newError("timeout during enrollment verification round trip")
|
||||
case <-waitForConnection.Wait():
|
||||
err = error_resp_
|
||||
}
|
||||
timeoutContext, _ := context.WithTimeout(context.Background(), time.Second*30)
|
||||
request = request.WithContext(timeoutContext)
|
||||
|
||||
resp, err := c.currentConn.RoundTrip(request)
|
||||
// Use the current connection to perform the round trip
|
||||
if err != nil {
|
||||
if resp != nil && resp.Body != nil {
|
||||
resp.Body.Close()
|
||||
}
|
||||
|
||||
defer func() {
|
||||
c.currentConnLock.RUnlock()
|
||||
c.currentConnLock.Lock()
|
||||
@@ -140,7 +125,7 @@ func (c *clientRoundtripper) createNewConnection() error {
|
||||
c.currentConnInnerConn = conn
|
||||
c.currentConn, err = httponconnection.NewSingleConnectionHTTPTransport(conn, "h2")
|
||||
if err != nil {
|
||||
conn.Close() // Close the connection if transport creation fails
|
||||
_ = conn.Close() // Close the connection if transport creation fails
|
||||
return newError("failed to create HTTP transport: ", err)
|
||||
}
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user