@@ -2,37 +2,40 @@ package runner
22
33import (
44 "flag"
5+ "fmt"
56 "os"
67 "path/filepath"
78 "strings"
89
910 "github.com/projectdiscovery/gologger"
1011 "github.com/projectdiscovery/gologger/levels"
12+ "github.com/projectdiscovery/simplehttpserver/pkg/httpserver"
1113)
1214
1315// Options of the tool
1416type Options struct {
15- ListenAddress string
16- Folder string
17- BasicAuth string
18- username string
19- password string
20- Realm string
21- TLSCertificate string
22- TLSKey string
23- TLSDomain string
24- HTTPS bool
25- Verbose bool
26- EnableUpload bool
27- EnableTCP bool
28- RulesFile string
29- TCPWithTLS bool
30- Version bool
31- Silent bool
32- Sandbox bool
33- MaxFileSize int
34- HTTP1Only bool
17+ ListenAddress string
18+ Folder string
19+ BasicAuth string
20+ username string
21+ password string
22+ Realm string
23+ TLSCertificate string
24+ TLSKey string
25+ TLSDomain string
26+ HTTPS bool
27+ Verbose bool
28+ EnableUpload bool
29+ EnableTCP bool
30+ RulesFile string
31+ TCPWithTLS bool
32+ Version bool
33+ Silent bool
34+ Sandbox bool
35+ MaxFileSize int
36+ HTTP1Only bool
3537 MaxDumpBodySize int
38+ HTTPHeaders HTTPHeaders
3639}
3740
3841// ParseOptions parses the command line options for application
@@ -61,6 +64,7 @@ func ParseOptions() *Options {
6164 flag .BoolVar (& options .HTTP1Only , "http1" , false , "Enable only HTTP1" )
6265 flag .IntVar (& options .MaxFileSize , "max-file-size" , 50 , "Max Upload File Size" )
6366 flag .IntVar (& options .MaxDumpBodySize , "max-dump-body-size" , - 1 , "Max Dump Body Size" )
67+ flag .Var (& options .HTTPHeaders , "header" , "Add HTTP Response Header (name: value), can be used multiple times" )
6468 flag .Parse ()
6569
6670 // Read the inputs and configure the logging
@@ -113,3 +117,21 @@ func (options *Options) FolderAbsPath() string {
113117 }
114118 return abspath
115119}
120+
121+ // HTTPHeaders is a slice of HTTPHeader structs
122+ type HTTPHeaders []httpserver.HTTPHeader
123+
124+ func (h * HTTPHeaders ) String () string {
125+ return fmt .Sprint (* h )
126+ }
127+
128+ // Set sets a new header, which must be a string of the form 'name: value'
129+ func (h * HTTPHeaders ) Set (value string ) error {
130+ tokens := strings .SplitN (value , ":" , 2 )
131+ if len (tokens ) != 2 {
132+ return fmt .Errorf ("header '%s' not in format 'name: value'" , value )
133+ }
134+
135+ * h = append (* h , httpserver.HTTPHeader {Name : tokens [0 ], Value : tokens [1 ]})
136+ return nil
137+ }
0 commit comments