joao-r-reis commented on code in PR #1858:
URL:
https://github.com/apache/cassandra-gocql-driver/pull/1858#discussion_r1943099750
##########
host_source.go:
##########
@@ -186,19 +198,17 @@ func validIpAddr(addr net.IP) bool {
}
func (h *HostInfo) connectAddressLocked() (net.IP, string) {
- if validIpAddr(h.connectAddress) {
+ if h.connectAddress != nil {
return h.connectAddress, "connect_address"
- } else if validIpAddr(h.rpcAddress) {
+ } else if h.rpcAddress != nil {
return h.rpcAddress, "rpc_adress"
- } else if validIpAddr(h.preferredIP) {
- // where does perferred_ip get set?
+ } else if h.preferredIP != nil {
return h.preferredIP, "preferred_ip"
- } else if validIpAddr(h.broadcastAddress) {
+ } else if h.broadcastAddress != nil {
Review Comment:
We should keep the `validIpAddr` check on all of these (except the last) so
that the "fallback" priority still works otherwise this would be a behavior
change and could cause bugs.
Just skip the check on the last one (h.peer), this will be checked either
way in `hostInfoFromMap` before returning the host info object so we're good.
##########
host_source.go:
##########
@@ -584,6 +600,9 @@ func (s *Session) hostInfoFromMap(row
map[string]interface{}, host *HostInfo) (*
}
ip, port := s.cfg.translateAddressPort(host.ConnectAddress(), host.port)
+ if !validIpAddr(ip) {
+ return nil, fmt.Errorf("invalid connect address after
translating %v:%v", ip.String(), host.port)
Review Comment:
Just realized this will be called even if there is no address translator so
maybe changing this error message to be less confusing:
"invalid host address (before translation: %v:%v, after translation:
%v:%v)", host.ConnectAddress(), host.port, ip.String(), port)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]