implement toggle key for redirects restriction

pull/118/head
Shodiq 5 years ago
parent 4c6d320be9
commit 2c8b810368

@ -106,7 +106,7 @@ var DefaultConfig = Config{
FormatJSON: true,
Insecure: false,
PreserveScrollPosition: true,
StatusLine: "[wuzz {{.Version}}]{{if .Duration}} [Response time: {{.Duration}}]{{end}} [Request no.: {{.RequestNumber}}/{{.HistorySize}}] [Search type: {{.SearchType}}]",
StatusLine: "[wuzz {{.Version}}]{{if .Duration}} [Response time: {{.Duration}}]{{end}} [Request no.: {{.RequestNumber}}/{{.HistorySize}}] [Search type: {{.SearchType}}]{{if .DisableRedirect}} [Redirects Restricted Mode {{.DisableRedirect}}]{{end}}",
Timeout: Duration{
defaultTimeoutDuration,
},

@ -57,6 +57,13 @@ func (s *StatusLine) Update(v *gocui.View, a *App) {
}
}
func (s *StatusLineFunctions) DisableRedirect() string {
if s.app.config.General.FollowRedirects {
return ""
}
return "Actived"
}
func NewStatusLine(format string) (*StatusLine, error) {
tpl, err := template.New("status line").Parse(format)
if err != nil {

@ -613,10 +613,7 @@ func (a *App) Layout(g *gocui.Gui) error {
setViewProperties(v, name)
}
}
sv, _ := g.View(STATUSLINE_VIEW)
sv.BgColor = gocui.ColorDefault | gocui.AttrReverse
sv.FgColor = gocui.ColorDefault | gocui.AttrReverse
a.statusLine.Update(sv, a)
refreshStatusLine(a, g)
return nil
}
@ -1099,6 +1096,12 @@ func (a *App) SetKeys(g *gocui.Gui) error {
return nil
})
g.SetKeybinding(ALL_VIEWS, gocui.KeyF12, gocui.ModNone, func(g *gocui.Gui, v *gocui.View) error {
a.config.General.FollowRedirects = !a.config.General.FollowRedirects
refreshStatusLine(a, g)
return nil
})
g.SetKeybinding(REQUEST_METHOD_VIEW, gocui.KeyEnter, gocui.ModNone, a.ToggleMethodList)
cursDown := func(g *gocui.Gui, v *gocui.View) error {
@ -1749,13 +1752,21 @@ func (a *App) InitConfig() {
MinVersion: a.config.General.TLSVersionMin,
MaxVersion: a.config.General.TLSVersionMax,
}
if !a.config.General.FollowRedirects {
CLIENT.CheckRedirect = func(_ *http.Request, _ []*http.Request) error {
return http.ErrUseLastResponse
CLIENT.CheckRedirect = func(_ *http.Request, _ []*http.Request) error {
if a.config.General.FollowRedirects {
return nil
}
return http.ErrUseLastResponse
}
}
func refreshStatusLine(a *App, g *gocui.Gui) {
sv, _ := g.View(STATUSLINE_VIEW)
sv.BgColor = gocui.ColorDefault | gocui.AttrReverse
sv.FgColor = gocui.ColorDefault | gocui.AttrReverse
a.statusLine.Update(sv, a)
}
func initApp(a *App, g *gocui.Gui) {
g.Cursor = true
g.InputEsc = false

Loading…
Cancel
Save