123456789101112131415161718192021222324252627282930313233343536373839 |
- 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()
- }
- func NewRestls(ctx context.Context, conn net.Conn, config *tls.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
- }
|