| 12 | } |
| 13 | |
| 14 | func NewHttpProxy(s *session.Session) *HttpProxy { |
| 15 | mod := &HttpProxy{ |
| 16 | SessionModule: session.NewSessionModule("http.proxy", s), |
| 17 | proxy: NewHTTPProxy(s, "http.proxy"), |
| 18 | } |
| 19 | |
| 20 | mod.AddParam(session.NewIntParameter("http.port", |
| 21 | "80", |
| 22 | "HTTP port to redirect when the proxy is activated.")) |
| 23 | |
| 24 | mod.AddParam(session.NewStringParameter("http.proxy.address", |
| 25 | session.ParamIfaceAddress, |
| 26 | session.IPv4Validator, |
| 27 | "Address to bind the HTTP proxy to.")) |
| 28 | |
| 29 | mod.AddParam(session.NewIntParameter("http.proxy.port", |
| 30 | "8080", |
| 31 | "Port to bind the HTTP proxy to.")) |
| 32 | |
| 33 | mod.AddParam(session.NewBoolParameter("http.proxy.redirect", |
| 34 | "true", |
| 35 | "Enable or disable port redirection with iptables.")) |
| 36 | |
| 37 | mod.AddParam(session.NewStringParameter("http.proxy.script", |
| 38 | "", |
| 39 | "", |
| 40 | "Path of a proxy JS script.")) |
| 41 | |
| 42 | mod.AddParam(session.NewStringParameter("http.proxy.injectjs", |
| 43 | "", |
| 44 | "", |
| 45 | "URL, path or javascript code to inject into every HTML page.")) |
| 46 | |
| 47 | mod.AddParam(session.NewStringParameter("http.proxy.blacklist", "", "", |
| 48 | "Comma separated list of hostnames to skip while proxying (wildcard expressions can be used).")) |
| 49 | |
| 50 | mod.AddParam(session.NewStringParameter("http.proxy.whitelist", "", "", |
| 51 | "Comma separated list of hostnames to proxy if the blacklist is used (wildcard expressions can be used).")) |
| 52 | |
| 53 | mod.AddParam(session.NewBoolParameter("http.proxy.sslstrip", |
| 54 | "false", |
| 55 | "Enable or disable SSL stripping.")) |
| 56 | |
| 57 | mod.AddHandler(session.NewModuleHandler("http.proxy on", "", |
| 58 | "Start HTTP proxy.", |
| 59 | func(args []string) error { |
| 60 | return mod.Start() |
| 61 | })) |
| 62 | |
| 63 | mod.AddHandler(session.NewModuleHandler("http.proxy off", "", |
| 64 | "Stop HTTP proxy.", |
| 65 | func(args []string) error { |
| 66 | return mod.Stop() |
| 67 | })) |
| 68 | |
| 69 | mod.InitState("stripper") |
| 70 | |
| 71 | return mod |