diff --git a/session/module_param.go b/session/module_param.go index d42fe621..9a878574 100644 --- a/session/module_param.go +++ b/session/module_param.go @@ -45,12 +45,12 @@ func NewStringParameter(name string, def_value string, validator string, desc st return NewModuleParameter(name, def_value, STRING, validator, desc) } -func NewBoolParameter(name string, def_value string, validator string, desc string) *ModuleParam { - return NewModuleParameter(name, def_value, BOOL, validator, desc) +func NewBoolParameter(name string, def_value string, desc string) *ModuleParam { + return NewModuleParameter(name, def_value, BOOL, "^(true|false)$", desc) } -func NewIntParameter(name string, def_value string, validator string, desc string) *ModuleParam { - return NewModuleParameter(name, def_value, INT, validator, desc) +func NewIntParameter(name string, def_value string, desc string) *ModuleParam { + return NewModuleParameter(name, def_value, INT, "^[\\d]+$", desc) } func (p ModuleParam) Validate(value string) (error, interface{}) { diff --git a/session/modules/http_proxy.go b/session/modules/http_proxy.go index 0ed65364..9fe01a47 100644 --- a/session/modules/http_proxy.go +++ b/session/modules/http_proxy.go @@ -45,10 +45,24 @@ func NewHttpProxy(s *session.Session) *HttpProxy { script: nil, } - p.AddParam(session.NewIntParameter("http.port", "80", "", "HTTP port to redirect when the proxy is activated.")) - p.AddParam(session.NewIntParameter("http.proxy.port", "8080", "", "Port to bind the HTTP proxy to.")) - p.AddParam(session.NewStringParameter("http.proxy.address", "", `^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$`, "Address to bind the HTTP proxy to.")) - p.AddParam(session.NewStringParameter("http.proxy.script", "", "", "Path of a proxy JS script.")) + p.AddParam(session.NewIntParameter("http.port", + "80", + "HTTP port to redirect when the proxy is activated.")) + + p.AddParam(session.NewIntParameter("http.proxy.port", + "8080", + "Port to bind the HTTP proxy to.")) + + p.AddParam(session.NewStringParameter("http.proxy.address", + "", + `^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$`, + "Address to bind the HTTP proxy to.")) + + p.AddParam(session.NewStringParameter("http.proxy.script", + "", + "", + "Path of a proxy JS script.")) + p.AddHandler(session.NewModuleHandler("http.proxy on", "", "Start HTTP proxy.", func(args []string) error { @@ -206,7 +220,7 @@ func (p *HttpProxy) Stop() error { } } -func (p *HttpProxy) doProxy(req *http.Request) bool { +func (p HttpProxy) doProxy(req *http.Request) bool { blacklist := []string{ "localhost", "127.0.0.1", diff --git a/session/modules/net_probe.go b/session/modules/net_probe.go index c14b5c96..cd21f0ff 100644 --- a/session/modules/net_probe.go +++ b/session/modules/net_probe.go @@ -18,7 +18,9 @@ func NewProber(s *session.Session) *Prober { SessionModule: session.NewSessionModule(s), } - p.AddParam(session.NewIntParameter("net.probe.throttle", "10", "", "If greater than 0, probe packets will be throttled by this value in milliseconds.")) + p.AddParam(session.NewIntParameter("net.probe.throttle", + "10", + "If greater than 0, probe packets will be throttled by this value in milliseconds.")) p.AddHandler(session.NewModuleHandler("net.probe on", "", "Start network hosts probing in background.", diff --git a/session/modules/net_sniff.go b/session/modules/net_sniff.go index 3e00683f..eda5b9e1 100644 --- a/session/modules/net_sniff.go +++ b/session/modules/net_sniff.go @@ -121,11 +121,28 @@ func NewSniffer(s *session.Session) *Sniffer { Stats: nil, } - sniff.AddParam(session.NewBoolParameter("net.sniffer.verbose", "true", "", "Print captured packets to screen.")) - sniff.AddParam(session.NewBoolParameter("net.sniffer.local", "false", "", "If true it will consider packets from/to this computer, otherwise it will skip them.")) - sniff.AddParam(session.NewStringParameter("net.sniffer.filter", "not arp", "", "BPF filter for the sniffer.")) - sniff.AddParam(session.NewStringParameter("net.sniffer.regexp", "", "", "If filled, only packets matching this regular expression will be considered.")) - sniff.AddParam(session.NewStringParameter("net.sniffer.output", "", "", "If set, the sniffer will write captured packets to this file.")) + sniff.AddParam(session.NewBoolParameter("net.sniffer.verbose", + "true", + "Print captured packets to screen.")) + + sniff.AddParam(session.NewBoolParameter("net.sniffer.local", + "false", + "If true it will consider packets from/to this computer, otherwise it will skip them.")) + + sniff.AddParam(session.NewStringParameter("net.sniffer.filter", + "not arp", + "", + "BPF filter for the sniffer.")) + + sniff.AddParam(session.NewStringParameter("net.sniffer.regexp", + "", + "", + "If filled, only packets matching this regular expression will be considered.")) + + sniff.AddParam(session.NewStringParameter("net.sniffer.output", + "", + "", + "If set, the sniffer will write captured packets to this file.")) sniff.AddHandler(session.NewModuleHandler("net.sniffer stats", "", "Print sniffer session configuration and statistics.",