36 lines
594 B
Go
36 lines
594 B
Go
package main
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"git.3crabs.ru/VLADIMIR/net/http"
|
|
)
|
|
|
|
type CustomDNS struct{}
|
|
|
|
func (*CustomDNS) GetIP(domain string) (string, error) {
|
|
if domain == "test.ru" {
|
|
return "127.0.0.1:8081", nil
|
|
}
|
|
return "", errors.New("ip not found")
|
|
}
|
|
|
|
func main() {
|
|
client := http.Client{
|
|
DNS: &CustomDNS{},
|
|
Transport: &http.HttpTransport{},
|
|
}
|
|
_, err := client.Do(
|
|
"GET",
|
|
"http://test.ru/",
|
|
[]http.Header{
|
|
{Name: "Host", Value: "3crabs.ru"},
|
|
{Name: "User-Agent", Value: "3crabs/0.0.1"},
|
|
{Name: "Accept", Value: "*/*"},
|
|
},
|
|
)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
}
|