|
@@ -11,6 +11,7 @@ import (
|
|
|
"net/http"
|
|
|
"os"
|
|
|
"strings"
|
|
|
+ "time"
|
|
|
)
|
|
|
|
|
|
var (
|
|
@@ -83,6 +84,7 @@ func (s *Server) generateList(w http.ResponseWriter, r *http.Request) {
|
|
|
func handle(url string, zone chan string) {
|
|
|
body, err := fetch(url)
|
|
|
if err != nil {
|
|
|
+ zone <- ""
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -90,7 +92,10 @@ func handle(url string, zone chan string) {
|
|
|
}
|
|
|
|
|
|
func fetch(url string) (string, error) {
|
|
|
- req, err := http.Get(url)
|
|
|
+ client := http.Client{
|
|
|
+ Timeout: 3 * time.Second,
|
|
|
+ }
|
|
|
+ req, err := client.Get(url)
|
|
|
if err != nil {
|
|
|
return "", err
|
|
|
}
|