SCADA support

This commit is contained in:
Armon Dadgar
2015-09-14 15:33:08 -07:00
parent d4e8279293
commit cf3c6aa8a7
6 changed files with 408 additions and 3 deletions

View File

@@ -18,6 +18,12 @@ import (
const (
// ErrInvalidMethod is used if the HTTP method is not supported
ErrInvalidMethod = "Invalid method"
// scadaHTTPAddr is the address associated with the
// HTTPServer. When populating an ACL token for a request,
// this is checked to switch between the ACLToken and
// AtlasACLToken
scadaHTTPAddr = "SCADA"
)
// HTTPServer is used to wrap an Agent and expose it over an HTTP interface
@@ -26,6 +32,7 @@ type HTTPServer struct {
mux *http.ServeMux
listener net.Listener
logger *log.Logger
addr string
}
// NewHTTPServer starts new HTTP server over the agent
@@ -45,6 +52,7 @@ func NewHTTPServer(agent *Agent, config *Config, logOutput io.Writer) (*HTTPServ
mux: mux,
listener: ln,
logger: log.New(logOutput, "", log.LstdFlags),
addr: ln.Addr().String(),
}
srv.registerHandlers(config.EnableDebug)
@@ -53,6 +61,27 @@ func NewHTTPServer(agent *Agent, config *Config, logOutput io.Writer) (*HTTPServ
return srv, nil
}
// newScadaHttp creates a new HTTP server wrapping the SCADA
// listener such that HTTP calls can be sent from the brokers.
func newScadaHttp(agent *Agent, list net.Listener) *HTTPServer {
// Create the mux
mux := http.NewServeMux()
// Create the server
srv := &HTTPServer{
agent: agent,
mux: mux,
listener: list,
logger: agent.logger,
addr: scadaHTTPAddr,
}
srv.registerHandlers(false) // Never allow debug for SCADA
// Start the server
go http.Serve(list, mux)
return srv
}
// Shutdown is used to shutdown the HTTP server
func (s *HTTPServer) Shutdown() {
if s != nil {