beck-8 / s3-tools Goto Github PK
View Code? Open in Web Editor NEWs3-migrate
License: Apache License 2.0
s3-migrate
License: Apache License 2.0
type randomRoundTripper struct {
resolver *net.Resolver
}
func (r *randomRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
// 解析域名,获取所有 IP 地址
ips, err := r.resolver.LookupIP(context.Background(), "ip4", req.URL.Hostname())
if err != nil {
return nil, err
}
// 随机选择一个 IP 地址
selectedIP := ips[rand.Intn(len(ips))]
fmt.Println(req.Host, req.URL.Host)
// 替换请求的 Host 字段为选定的 IP 地址
req.URL.Host = selectedIP.String()
fmt.Println(req.Header, req.Host, req.URL.Host, req.Method)
// 使用默认的 Transport 进行实际的请求
return http.DefaultTransport.RoundTrip(req)
}
...
func main() {
// 创建自定义的 RoundTripper
transport := &randomRoundTripper{
resolver: net.DefaultResolver,
}
// 创建自定义的 Client
client := &http.Client{
Transport: transport,
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.