This commit is contained in:
gospider
2025-04-02 15:13:38 +08:00
parent e7d6e15e04
commit 34a1587e94
6 changed files with 145 additions and 105 deletions

View File

@@ -4,7 +4,10 @@ import (
"context"
"log"
"testing"
"time"
"github.com/gospider007/gtls"
"github.com/gospider007/proxy"
"github.com/gospider007/requests"
)
@@ -27,6 +30,44 @@ func TestHttp3(t *testing.T) {
t.Error("resp.Proto!= HTTP/3.0")
}
}
func TestHttp3Proxy(t *testing.T) {
proxyAddress := "127.0.0.1:1080"
// server, err := socks5.NewClassicServer("127.0.0.1:1080", "127.0.0.1", "", "", 0, 0)
// if err != nil {
// log.Println(err)
// return
// }
// go server.ListenAndServe(nil)
proxyC, err := proxy.NewClient(nil, proxy.ClientOption{Addr: proxyAddress, DisVerify: true})
if err != nil {
log.Println(err)
return
}
defer proxyC.Close()
go proxyC.Run()
// [0 87 164 1 116 253 33 138 106 82]
// [0 87 162 31 139 8 0 0 0 0]
time.Sleep(time.Second)
// href := "https://google.com"
href := "https://cloudflare-quic.com/"
resp, err := requests.Get(context.Background(), href,
requests.RequestOption{
ClientOption: requests.ClientOption{
DialOption: requests.DialOption{
// AddrType: gtls.Ipv4,
GetAddrType: func(host string) gtls.AddrType {
log.Print("我开始喽")
return gtls.Ipv4
},
},
Proxy: "socks5://" + proxyAddress,
ForceHttp3: true,
},
})
if err != nil {
log.Panic(err)
return
}
log.Print(resp.StatusCode())
log.Print(resp.Proto())
}