Add endpoint option for sasl

This commit is contained in:
Benjamin Ramser 2021-07-08 12:05:16 +02:00
parent 7dddca165c
commit aed3b1a95f
2 changed files with 6 additions and 1 deletions
internal/endpoint

View File

@ -64,6 +64,7 @@ type Endpoint struct {
Host string Host string
Port int Port int
TopicName string TopicName string
SASL bool
TLS bool TLS bool
CACertFile string CACertFile string
CertFile string CertFile string
@ -412,6 +413,8 @@ func parseEndpoint(s string) (Endpoint, error) {
endpoint.Kafka.CertFile = val[0] endpoint.Kafka.CertFile = val[0]
case "key": case "key":
endpoint.Kafka.KeyFile = val[0] endpoint.Kafka.KeyFile = val[0]
case "sasl":
endpoint.Kafka.SASL, _ = strconv.ParseBool(val[0])
} }
} }
} }

View File

@ -76,7 +76,9 @@ func (conn *KafkaConn) Send(msg string) error {
} }
cfg.Net.TLS.Enable = true cfg.Net.TLS.Enable = true
cfg.Net.TLS.Config = tlsConfig cfg.Net.TLS.Config = tlsConfig
} else { }
if conn.ep.Kafka.SASL {
log.Debugf("building kafka sasl config") log.Debugf("building kafka sasl config")
cfg.ClientID = "sasl_scram_client" cfg.ClientID = "sasl_scram_client"
cfg.Net.SASL.Enable = true cfg.Net.SASL.Enable = true