1
0
mirror of https://github.com/fumiama/terasu.git synced 2026-06-05 01:00:23 +08:00

feat: new implementations

This commit is contained in:
源文雨
2024-04-19 00:12:45 +09:00
parent b7e45bc58e
commit 719e0c1683
15 changed files with 682 additions and 162 deletions

View File

@@ -13,32 +13,5 @@
## Usage
```go
cli := http.Client{
Transport: &http.Transport{
DialTLS: func(network, addr string) (net.Conn, error) {
host, port, err := net.SplitHostPort(addr)
if err != nil {
return nil, err
}
addrs, err := net.DefaultResolver.LookupHost(ctx, host)
if err != nil {
return nil, err
}
conn, err := net.Dial(network, net.JoinHostPort(addrs[0], port))
if err != nil {
return nil, err
}
tlsConn := tls.Client(conn, &tls.Config{
ServerName: host,
})
err = terasu.Use(tlsConn).Handshake()
if err != nil {
_ = tlsConn.Close()
return nil, err
}
return tlsConn, nil
},
},
}
resp, err := cli.Get(url)
terasu.Use(tlsConn).Handshake()
```