34 lines
531 B
Go
34 lines
531 B
Go
package justcaptcha
|
|
|
|
import (
|
|
"context"
|
|
"net"
|
|
"net/http"
|
|
"strings"
|
|
)
|
|
|
|
func CheckCaptcha(id string, url string) (bool, error) {
|
|
var c http.Client
|
|
var r *http.Response
|
|
var err error
|
|
|
|
if strings.Contains(url, ":") {
|
|
c = http.Client{}
|
|
} else {
|
|
c = http.Client{
|
|
Transport: &http.Transport{
|
|
DialContext: func(_ context.Context, _, addr string) (net.Conn, error) {
|
|
return net.Dial("unix", addr)
|
|
},
|
|
},
|
|
}
|
|
}
|
|
|
|
r, err = c.Get(url)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
return r.StatusCode == 200, nil
|
|
}
|