Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for -vv flag #142

Merged
merged 2 commits into from
Jul 27, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,11 @@ CONFIGURATION:
-deny string Denied list of IP/CIDR's to be proxied

DEBUG:
-silent Silent
-nc, -no-color No Color (default true)
-version Version
-v, -verbose Verbose
-silent Silent
-nc, -no-color No Color (default true)
-version Version
-v, -verbose Verbose
-vv, -very-verbose Very Verbose
```

### Running Proxify
Expand Down
4 changes: 3 additions & 1 deletion internal/runner/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type Options struct {
Directory string
CertCacheSize int
Verbose bool
VeryVerbose bool
Silent bool
Version bool
ListenAddrHTTP string
Expand Down Expand Up @@ -105,6 +106,7 @@ func ParseOptions() *Options {
flagSet.BoolVarP(&options.NoColor, "no-color", "nc", true, "No Color"),
flagSet.BoolVar(&options.Version, "version", false, "Version"),
flagSet.BoolVarP(&options.Verbose, "verbose", "v", false, "Verbose"),
flagSet.BoolVarP(&options.VeryVerbose, "very-verbose", "vv", false, "Very Verbose"),
)

_ = flagSet.Parse()
Expand All @@ -125,7 +127,7 @@ func ParseOptions() *Options {
}

func (options *Options) configureOutput() {
if options.Verbose {
if options.Verbose || options.VeryVerbose {
gologger.DefaultLogger.SetMaxLevel(levels.LevelVerbose)
}
if options.NoColor {
Expand Down
1 change: 1 addition & 0 deletions internal/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ func NewRunner(options *Options) (*Runner, error) {
Directory: options.Directory,
CertCacheSize: options.CertCacheSize,
Verbose: options.Verbose,
VeryVerbose: options.VeryVerbose,
ListenAddrHTTP: options.ListenAddrHTTP,
ListenAddrSocks5: options.ListenAddrSocks5,
OutputDirectory: options.OutputDirectory,
Expand Down
5 changes: 3 additions & 2 deletions pkg/logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const (

type OptionsLogger struct {
Verbose bool
VeryVerbose bool
OutputFolder string
DumpRequest bool
DumpResponse bool
Expand Down Expand Up @@ -135,7 +136,7 @@ func (l *Logger) LogRequest(req *http.Request, userdata types.UserData) error {
l.asyncqueue <- types.OutputData{Data: reqdump, Userdata: userdata}
}

if l.options.Verbose {
if l.options.VeryVerbose {
contentType := req.Header.Get("Content-Type")
b, _ := ioutil.ReadAll(req.Body)
if isASCIICheckRequired(contentType) && !govalidator.IsPrintableASCII(string(b)) {
Expand Down Expand Up @@ -166,7 +167,7 @@ func (l *Logger) LogResponse(resp *http.Response, userdata types.UserData) error
if l.options.OutputFolder != "" || l.options.Kafka.Addr != "" || l.options.Elastic.Addr != "" {
l.asyncqueue <- types.OutputData{Data: respdump, Userdata: userdata}
}
if l.options.Verbose {
if l.options.VeryVerbose {
contentType := resp.Header.Get("Content-Type")
bodyBytes := bytes.TrimPrefix(respdump, respdumpNoBody)
if isASCIICheckRequired(contentType) && !govalidator.IsPrintableASCII(string(bodyBytes)) {
Expand Down
4 changes: 3 additions & 1 deletion proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type Options struct {
DumpResponse bool
Silent bool
Verbose bool
VeryVerbose bool
CertCacheSize int
Directory string
ListenAddrHTTP string
Expand Down Expand Up @@ -331,7 +332,7 @@ func NewProxy(options *Options) (*Proxy, error) {
httpproxy = goproxy.NewProxyHttpServer()
if options.Silent {
httpproxy.Logger = log.New(ioutil.Discard, "", log.Ltime|log.Lshortfile)
} else if options.Verbose {
} else if options.Verbose || options.VeryVerbose {
httpproxy.Verbose = true
} else {
httpproxy.Verbose = false
Expand All @@ -347,6 +348,7 @@ func NewProxy(options *Options) (*Proxy, error) {

logger := logger.NewLogger(&logger.OptionsLogger{
Verbose: options.Verbose,
VeryVerbose: options.VeryVerbose,
OutputFolder: options.OutputDirectory,
DumpRequest: options.DumpRequest,
DumpResponse: options.DumpResponse,
Expand Down
5 changes: 4 additions & 1 deletion socket.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type SocketConn struct {
sentBytes uint64
receivedBytes uint64
Verbose bool
VeryVerbose bool
OutputHex bool
Timeout time.Duration
RequestMatchReplaceDSL string
Expand All @@ -52,6 +53,7 @@ type SocketProxyOptions struct {
TLSServerConfig *tls.Config
TLSServer bool
Verbose bool
VeryVerbose bool
OutputHex bool
Timeout time.Duration
RequestMatchReplaceDSL string
Expand Down Expand Up @@ -108,7 +110,7 @@ func (p *SocketProxy) Run() error {
log.Println(err)
return err
}
go p.Proxy(conn) //nolint
go p.Proxy(conn) //nolint
}
}

Expand All @@ -120,6 +122,7 @@ func (p *SocketProxy) Proxy(conn net.Conn) error {

socketConn.Timeout = p.options.Timeout
socketConn.Verbose = p.options.Verbose
socketConn.VeryVerbose = p.options.VeryVerbose
socketConn.OutputHex = p.options.OutputHex

socketConn.lconn = conn
Expand Down