MCPcopy
hub / github.com/bettercap/bettercap / NewHttpsServer

Function NewHttpsServer

modules/https_server/https_server.go:24–69  ·  view source on GitHub ↗
(s *session.Session)

Source from the content-addressed store, hash-verified

22}
23
24func NewHttpsServer(s *session.Session) *HttpsServer {
25 mod := &HttpsServer{
26 SessionModule: session.NewSessionModule("https.server", s),
27 server: &http.Server{},
28 }
29
30 mod.AddParam(session.NewStringParameter("https.server.path",
31 ".",
32 "",
33 "Server folder."))
34
35 mod.AddParam(session.NewStringParameter("https.server.address",
36 session.ParamIfaceAddress,
37 session.IPv4Validator,
38 "Address to bind the HTTPS server to."))
39
40 mod.AddParam(session.NewIntParameter("https.server.port",
41 "443",
42 "Port to bind the HTTPS server to."))
43
44 mod.AddParam(session.NewStringParameter("https.server.certificate",
45 "~/.bettercap-httpd.cert.pem",
46 "",
47 "TLS certificate file (will be auto generated if filled but not existing)."))
48
49 mod.AddParam(session.NewStringParameter("https.server.key",
50 "~/.bettercap-httpd.key.pem",
51 "",
52 "TLS key file (will be auto generated if filled but not existing)."))
53
54 tls.CertConfigToModule("https.server", &mod.SessionModule, tls.DefaultLegitConfig)
55
56 mod.AddHandler(session.NewModuleHandler("https.server on", "",
57 "Start HTTPS server.",
58 func(args []string) error {
59 return mod.Start()
60 }))
61
62 mod.AddHandler(session.NewModuleHandler("https.server off", "",
63 "Stop HTTPS server.",
64 func(args []string) error {
65 return mod.Stop()
66 }))
67
68 return mod
69}
70
71func (mod *HttpsServer) Name() string {
72 return "https.server"

Callers 1

LoadModulesFunction · 0.92

Calls 9

StartMethod · 0.95
StopMethod · 0.95
NewSessionModuleFunction · 0.92
NewStringParameterFunction · 0.92
NewIntParameterFunction · 0.92
CertConfigToModuleFunction · 0.92
NewModuleHandlerFunction · 0.92
AddParamMethod · 0.80
AddHandlerMethod · 0.80

Tested by

no test coverage detected