diff --git a/modules/api_rest.go b/modules/api_rest.go index 83ca9c09..4d26e529 100644 --- a/modules/api_rest.go +++ b/modules/api_rest.go @@ -29,7 +29,7 @@ func NewRestAPI(s *session.Session) *RestAPI { api.AddParam(session.NewStringParameter("api.rest.address", session.ParamIfaceAddress, - `^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$`, + session.IPv4Validator, "Address to bind the API REST server to.")) api.AddParam(session.NewIntParameter("api.rest.port", diff --git a/modules/dhcp6_spoof.go b/modules/dhcp6_spoof.go index 3011e87e..5b81207f 100644 --- a/modules/dhcp6_spoof.go +++ b/modules/dhcp6_spoof.go @@ -46,7 +46,7 @@ func NewDHCP6Spoofer(s *session.Session) *DHCP6Spoofer { spoof.AddParam(session.NewStringParameter("dhcp6.spoof.address", session.ParamIfaceAddress, - `^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$`, + session.IPv4Validator, "IP address to map the domains to.")) spoof.AddHandler(session.NewModuleHandler("dhcp6.spoof on", "", diff --git a/modules/dns_spoof.go b/modules/dns_spoof.go index fabf89ae..e7a56a65 100644 --- a/modules/dns_spoof.go +++ b/modules/dns_spoof.go @@ -36,7 +36,7 @@ func NewDNSSpoofer(s *session.Session) *DNSSpoofer { spoof.AddParam(session.NewStringParameter("dns.spoof.address", session.ParamIfaceAddress, - `^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$`, + session.IPv4Validator, "IP address to map the domains to.")) spoof.AddHandler(session.NewModuleHandler("dns.spoof on", "", diff --git a/modules/http_proxy.go b/modules/http_proxy.go index 6043562c..81bbbafd 100644 --- a/modules/http_proxy.go +++ b/modules/http_proxy.go @@ -55,7 +55,7 @@ func NewHttpProxy(s *session.Session) *HttpProxy { p.AddParam(session.NewStringParameter("http.proxy.address", session.ParamIfaceAddress, - `^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$`, + session.IPv4Validator, "Address to bind the HTTP proxy to.")) p.AddParam(session.NewIntParameter("http.proxy.port", diff --git a/modules/http_server.go b/modules/http_server.go index a6594fd0..7e55e2bc 100644 --- a/modules/http_server.go +++ b/modules/http_server.go @@ -30,7 +30,7 @@ func NewHttpServer(s *session.Session) *HttpServer { httpd.AddParam(session.NewStringParameter("http.server.address", session.ParamIfaceAddress, - `^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$`, + session.IPv4Validator, "Address to bind the http server to.")) httpd.AddParam(session.NewIntParameter("http.server.port", diff --git a/session/module_handler.go b/session/module_handler.go index d7f7f89c..e12db3e4 100644 --- a/session/module_handler.go +++ b/session/module_handler.go @@ -7,6 +7,8 @@ import ( "strconv" ) +const IPv4Validator = `^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$` + type ModuleHandler struct { Name string Description string