(src, dst, addr, host, path string, tc *tls.Config, timeout int, tlsfingerprint utls.ClientHelloID, fragmentMinLength, fragmentMaxLength, fragmentMinDelay, fragmentMaxDelay int64)
| 35 | ) |
| 36 | |
| 37 | func WebSocketDial(src, dst, addr, host, path string, tc *tls.Config, timeout int, tlsfingerprint utls.ClientHelloID, fragmentMinLength, fragmentMaxLength, fragmentMinDelay, fragmentMaxDelay int64) (net.Conn, error) { |
| 38 | var c net.Conn |
| 39 | var err error |
| 40 | if src == "" || dst == "" { |
| 41 | c, err = DialTCP("tcp", "", addr) |
| 42 | } |
| 43 | if src != "" && dst != "" { |
| 44 | c, err = NATDial("tcp", src, dst, addr) |
| 45 | } |
| 46 | if err != nil { |
| 47 | return nil, err |
| 48 | } |
| 49 | if timeout != 0 { |
| 50 | if err := c.SetDeadline(time.Now().Add(time.Duration(timeout) * time.Second)); err != nil { |
| 51 | c.Close() |
| 52 | return nil, err |
| 53 | } |
| 54 | } |
| 55 | if tc != nil { |
| 56 | if fragmentMinLength != 0 && fragmentMaxLength != 0 && fragmentMinDelay != 0 && fragmentMaxDelay != 0 { |
| 57 | c = &TLSFragmentConn{ |
| 58 | Conn: c, |
| 59 | MinLength: fragmentMinLength, |
| 60 | MaxLength: fragmentMaxLength, |
| 61 | MinDelay: fragmentMinDelay, |
| 62 | MaxDelay: fragmentMaxDelay, |
| 63 | } |
| 64 | } |
| 65 | if tlsfingerprint.Client == "" { |
| 66 | c1 := tls.Client(c, tc) |
| 67 | if err := c1.Handshake(); err != nil { |
| 68 | c1.Close() |
| 69 | return nil, err |
| 70 | } |
| 71 | s := host |
| 72 | h, _, err := net.SplitHostPort(host) |
| 73 | if err == nil { |
| 74 | s = h |
| 75 | } |
| 76 | if !tc.InsecureSkipVerify { |
| 77 | if err := c1.VerifyHostname(s); err != nil { |
| 78 | c1.Close() |
| 79 | return nil, err |
| 80 | } |
| 81 | } |
| 82 | c = c1 |
| 83 | } |
| 84 | if tlsfingerprint.Client != "" { |
| 85 | c1 := utls.UClient(c, &utls.Config{ |
| 86 | ServerName: tc.ServerName, |
| 87 | NextProtos: tc.NextProtos, |
| 88 | InsecureSkipVerify: tc.InsecureSkipVerify, |
| 89 | RootCAs: tc.RootCAs, |
| 90 | }, tlsfingerprint) |
| 91 | s := host |
| 92 | h, _, err := net.SplitHostPort(host) |
| 93 | if err == nil { |
| 94 | s = h |
no test coverage detected