Skip to content

Commit

Permalink
added the option to disable following redirects (#588)
Browse files Browse the repository at this point in the history
  • Loading branch information
Darion authored Sep 14, 2023
1 parent 52cc6d0 commit 5e84d3d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmd/katana/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ pipelines offering both headless and non-headless crawling.`)
flagSet.StringVarP(&options.Strategy, "strategy", "s", "depth-first", "Visit strategy (depth-first, breadth-first)"),
flagSet.BoolVarP(&options.IgnoreQueryParams, "ignore-query-params", "iqp", false, "Ignore crawling same path with different query-param values"),
flagSet.BoolVarP(&options.TlsImpersonate, "tls-impersonate", "tlsi", false, "enable experimental client hello (ja3) tls randomization"),
flagSet.BoolVarP(&options.DisableRedirects, "disable-redirects", "dr", false, "disable following redirects (default false)"),
)

flagSet.CreateGroup("debug", "Debug",
Expand Down
3 changes: 3 additions & 0 deletions pkg/engine/common/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ func BuildHttpClient(dialer *fastdialer.Dialer, options *types.Options, redirect
Transport: transport,
Timeout: time.Duration(options.Timeout) * time.Second,
CheckRedirect: func(req *http.Request, via []*http.Request) error {
if options.DisableRedirects {
return http.ErrUseLastResponse
}
if len(via) == 10 {
return errorutil.New("stopped after 10 redirects")
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/types/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ type Options struct {
Debug bool
// TlsImpersonate enables experimental tls ClientHello randomization for standard crawler
TlsImpersonate bool
//DisableRedirects disables the following of redirects
DisableRedirects bool
}

func (options *Options) ParseCustomHeaders() map[string]string {
Expand Down

0 comments on commit 5e84d3d

Please sign in to comment.