stream: can use user certificates
Signed-off-by: JulienBalestra <julien.balestra@datadoghq.com>
This commit is contained in:
parent
a3af7393fe
commit
b82b524260
@ -114,6 +114,10 @@ type PluginConfig struct {
|
|||||||
SystemdCgroup bool `toml:"systemd_cgroup" json:"systemdCgroup"`
|
SystemdCgroup bool `toml:"systemd_cgroup" json:"systemdCgroup"`
|
||||||
// EnableTLSStreaming indicates to enable the TLS streaming support.
|
// EnableTLSStreaming indicates to enable the TLS streaming support.
|
||||||
EnableTLSStreaming bool `toml:"enable_tls_streaming" json:"enableTLSStreaming"`
|
EnableTLSStreaming bool `toml:"enable_tls_streaming" json:"enableTLSStreaming"`
|
||||||
|
// TLSCertFileStreaming is the path to a certificate file
|
||||||
|
TLSCertFileStreaming string `toml:"tls_cert_file_streaming" json:"tlsCertFileStreaming"`
|
||||||
|
// TLSKeyFileStreaming is the path to a private key file
|
||||||
|
TLSKeyFileStreaming string `toml:"tls_key_file_streaming" json:"tlsKeyFileStreaming"`
|
||||||
// MaxContainerLogLineSize is the maximum log line size in bytes for a container.
|
// MaxContainerLogLineSize is the maximum log line size in bytes for a container.
|
||||||
// Log line longer than the limit will be split into multiple lines. Non-positive
|
// Log line longer than the limit will be split into multiple lines. Non-positive
|
||||||
// value means no limit.
|
// value means no limit.
|
||||||
|
@ -44,8 +44,21 @@ func newStreamServer(c *criService, addr, port string) (streaming.Server, error)
|
|||||||
}
|
}
|
||||||
config := streaming.DefaultConfig
|
config := streaming.DefaultConfig
|
||||||
config.Addr = net.JoinHostPort(addr, port)
|
config.Addr = net.JoinHostPort(addr, port)
|
||||||
runtime := newStreamRuntime(c)
|
run := newStreamRuntime(c)
|
||||||
if c.config.EnableTLSStreaming {
|
if !c.config.EnableTLSStreaming {
|
||||||
|
return streaming.NewServer(config, run)
|
||||||
|
}
|
||||||
|
if c.config.TLSCertFileStreaming != "" && c.config.TLSKeyFileStreaming != "" {
|
||||||
|
tlsCert, err := tls.LoadX509KeyPair(c.config.TLSCertFileStreaming, c.config.TLSKeyFileStreaming)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "failed to load x509 key pair for stream server")
|
||||||
|
}
|
||||||
|
config.TLSConfig = &tls.Config{
|
||||||
|
Certificates: []tls.Certificate{tlsCert},
|
||||||
|
}
|
||||||
|
return streaming.NewServer(config, run)
|
||||||
|
}
|
||||||
|
// generating self-sign certs
|
||||||
tlsCert, err := newTLSCert()
|
tlsCert, err := newTLSCert()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "failed to generate tls certificate for stream server")
|
return nil, errors.Wrap(err, "failed to generate tls certificate for stream server")
|
||||||
@ -54,8 +67,7 @@ func newStreamServer(c *criService, addr, port string) (streaming.Server, error)
|
|||||||
Certificates: []tls.Certificate{tlsCert},
|
Certificates: []tls.Certificate{tlsCert},
|
||||||
InsecureSkipVerify: true,
|
InsecureSkipVerify: true,
|
||||||
}
|
}
|
||||||
}
|
return streaming.NewServer(config, run)
|
||||||
return streaming.NewServer(config, runtime)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type streamRuntime struct {
|
type streamRuntime struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user