mirror of https://github.com/tidwall/tile38.git
Add option to select sha function
This commit is contained in:
parent
ab89a79fae
commit
c47097acab
|
@ -65,6 +65,8 @@ type Endpoint struct {
|
||||||
Port int
|
Port int
|
||||||
TopicName string
|
TopicName string
|
||||||
SASL bool
|
SASL bool
|
||||||
|
SASLSHA256 bool
|
||||||
|
SASLSHA512 bool
|
||||||
TLS bool
|
TLS bool
|
||||||
CACertFile string
|
CACertFile string
|
||||||
CertFile string
|
CertFile string
|
||||||
|
@ -415,6 +417,10 @@ func parseEndpoint(s string) (Endpoint, error) {
|
||||||
endpoint.Kafka.KeyFile = val[0]
|
endpoint.Kafka.KeyFile = val[0]
|
||||||
case "sasl":
|
case "sasl":
|
||||||
endpoint.Kafka.SASL, _ = strconv.ParseBool(val[0])
|
endpoint.Kafka.SASL, _ = strconv.ParseBool(val[0])
|
||||||
|
case "sha256":
|
||||||
|
endpoint.Kafka.SASLSHA256, _ = strconv.ParseBool(val[0])
|
||||||
|
case "sha512":
|
||||||
|
endpoint.Kafka.SASLSHA512, _ = strconv.ParseBool(val[0])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,8 +84,14 @@ func (conn *KafkaConn) Send(msg string) error {
|
||||||
cfg.Net.SASL.User = os.Getenv("KAFKA_USERNAME")
|
cfg.Net.SASL.User = os.Getenv("KAFKA_USERNAME")
|
||||||
cfg.Net.SASL.Password = os.Getenv("KAFKA_PASSWORD")
|
cfg.Net.SASL.Password = os.Getenv("KAFKA_PASSWORD")
|
||||||
cfg.Net.SASL.Handshake = true
|
cfg.Net.SASL.Handshake = true
|
||||||
cfg.Net.SASL.SCRAMClientGeneratorFunc = func() sarama.SCRAMClient { return &XDGSCRAMClient{HashGeneratorFcn: SHA512} }
|
if conn.ep.Kafka.SASLSHA256 {
|
||||||
cfg.Net.SASL.Mechanism = sarama.SASLTypeSCRAMSHA512
|
cfg.Net.SASL.SCRAMClientGeneratorFunc = func() sarama.SCRAMClient { return &XDGSCRAMClient{HashGeneratorFcn: SHA256} }
|
||||||
|
cfg.Net.SASL.Mechanism = sarama.SASLTypeSCRAMSHA256
|
||||||
|
}
|
||||||
|
if conn.ep.Kafka.SASLSHA512 {
|
||||||
|
cfg.Net.SASL.SCRAMClientGeneratorFunc = func() sarama.SCRAMClient { return &XDGSCRAMClient{HashGeneratorFcn: SHA512} }
|
||||||
|
cfg.Net.SASL.Mechanism = sarama.SASLTypeSCRAMSHA512
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg.Net.DialTimeout = time.Second
|
cfg.Net.DialTimeout = time.Second
|
||||||
|
|
Loading…
Reference in New Issue