// NewProvider creates a new SCADA provider using the given configuration. // Requests for the HTTP capability are passed off to the listener that is // returned. func NewHTTPProvider(c *Config, logOutput io.Writer) (*Provider, net.Listener, error) { // Get the configuration of the provider config := providerConfig(c) config.LogOutput = logOutput // Set the HTTP capability config.Service.Capabilities["http"] = 1 // SCADA_INSECURE env variable is used for testing to disable TLS // certificate verification. insecure := c.Insecure if !insecure { if os.Getenv("SCADA_INSECURE") != "" { insecure = true } } if insecure { config.TLSConfig = &tls.Config{ InsecureSkipVerify: true, } } // Create an HTTP listener and handler list := newScadaListener(c.Atlas.Infrastructure) config.Handlers["http"] = func(capability string, meta map[string]string, conn io.ReadWriteCloser) error { return list.PushRWC(conn) } // Create the provider provider, err := sc.NewProvider(config) if err != nil { list.Close() return nil, nil, err } return &Provider{provider}, list, nil }
// NewProvider creates a new SCADA provider using the given configuration. // Requests for the HTTP capability are passed off to the listener that is // returned. func NewHTTPProvider(c *Config, logOutput io.Writer) (*Provider, net.Listener, error) { // Get the configuration of the provider config := providerConfig(c) config.LogOutput = logOutput // Set the HTTP capability config.Service.Capabilities["http"] = 1 // Create an HTTP listener and handler list := newScadaListener(c.Atlas.Infrastructure) config.Handlers["http"] = func(capability string, meta map[string]string, conn io.ReadWriteCloser) error { return list.PushRWC(conn) } // Create the provider provider, err := sc.NewProvider(config) if err != nil { list.Close() return nil, nil, err } return &Provider{provider}, list, nil }