Skip to content

Commit

Permalink
Add gau user-agent
Browse files Browse the repository at this point in the history
  • Loading branch information
lc committed Jul 10, 2020
1 parent ace300f commit 91e0ed3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
6 changes: 1 addition & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ import (
"github.com/lc/gau/providers"
)

const (
Version = `1.0.3`
)

func run(config *providers.Config, domains []string) {
var providerList []providers.Provider

Expand Down Expand Up @@ -100,7 +96,7 @@ func main() {
flag.Parse()

if *version {
fmt.Printf("gau version: %s\n", Version)
fmt.Printf("gau version: %s\n", providers.Version)
os.Exit(0)
}

Expand Down
14 changes: 13 additions & 1 deletion providers/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ import (
"net/http"
)

const (
// Version of gau
Version = `1.0.3`
// UserAgent for the HTTP Client
userAgent = "Mozilla/5.0 (compatible; gau/" + Version + "; https://github.com/lc/gau)"
)

// A generic interface for providers
type Provider interface {
Fetch(string, chan<- string) error
Expand All @@ -21,7 +28,12 @@ type Config struct {
// MakeRequest tries to make a GET request for the given URL and retries on failure.
func (c *Config) MakeRequest(url string) (resp *http.Response, err error) {
for retries := int(c.MaxRetries); ; retries-- {
resp, err = c.Client.Get(url)
req, err := http.NewRequest("GET", url, nil)
if err != nil {
return nil, err
}
req.Header.Add("User-Agent", userAgent)
resp, err = c.Client.Do(req)
if err != nil {
if retries == 0 {
return nil, err
Expand Down

0 comments on commit 91e0ed3

Please sign in to comment.