mihomo/transport/restls/restls.go
wwqgtxx 39d6a0d7ba
Some checks failed
Test / test (1.20, macos-13) (push) Waiting to run
Test / test (1.20, macos-latest) (push) Waiting to run
Test / test (1.20, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.20, windows-latest) (push) Waiting to run
Test / test (1.21, macos-13) (push) Waiting to run
Test / test (1.21, macos-latest) (push) Waiting to run
Test / test (1.21, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.21, windows-latest) (push) Waiting to run
Test / test (1.22, macos-13) (push) Waiting to run
Test / test (1.22, macos-latest) (push) Waiting to run
Test / test (1.22, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.22, windows-latest) (push) Waiting to run
Test / test (1.23, macos-13) (push) Waiting to run
Test / test (1.23, macos-latest) (push) Waiting to run
Test / test (1.23, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.23, windows-latest) (push) Waiting to run
Test / test (1.24, macos-13) (push) Waiting to run
Test / test (1.24, macos-latest) (push) Waiting to run
Test / test (1.24, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.24, windows-latest) (push) Waiting to run
Test / test (1.20, ubuntu-latest) (push) Failing after 1s
Test / test (1.21, ubuntu-latest) (push) Failing after 1s
Test / test (1.22, ubuntu-latest) (push) Failing after 1s
Test / test (1.23, ubuntu-latest) (push) Failing after 1s
Test / test (1.24, ubuntu-latest) (push) Failing after 1s
Trigger CMFA Update / trigger-CMFA-update (push) Failing after 1s
chore: update utls to 1.7.0
2025-04-21 12:07:33 +08:00

44 lines
758 B
Go

package restls
import (
"context"
"net"
tls "github.com/3andne/restls-client-go"
)
const (
Mode string = "restls"
)
type Restls struct {
*tls.UConn
}
func (r *Restls) Upstream() any {
return r.UConn.NetConn()
}
type Config = tls.Config
var NewRestlsConfig = tls.NewRestlsConfig
// NewRestls return a Restls Connection
func NewRestls(ctx context.Context, conn net.Conn, config *Config) (net.Conn, error) {
clientHellowID := tls.HelloChrome_Auto
if config != nil {
clientIDPtr := config.ClientID.Load()
if clientIDPtr != nil {
clientHellowID = *clientIDPtr
}
}
restls := &Restls{
UConn: tls.UClient(conn, config, clientHellowID),
}
if err := restls.HandshakeContext(ctx); err != nil {
return nil, err
}
return restls, nil
}