50
// a different port for each node.
51
// see also https://github.com/gocql/gocql/pull/1635
52
>
func (plugin *FixedAddressTranslatorPlugin) GetTranslator(cfg *config.Cassandra) (gocql.AddressTranslator, error) {
fixed_address_translator.go
53
>
if cfg.AddressTranslator == nil {
54
return nil, errors.New("there is no addressTranslator configuration in cassandra configuration")
55
}
56
58
>
if opts == nil {
59
return nil, errors.New("there are no options for translator plugin")
60
}
61
63
>
64
>
if !found || len(advertisedHostname) == 0 {
65
return nil, errors.New("detected no advertised-hostname key or empty value for translator plugin options")
66
}
67
69
>
ips, _ := net.LookupIP(advertisedHostname)
70
>
for _, ip := range ips {
71
>
if ipv4 := ip.To4(); ipv4 != nil {
72
>
resolvedIp = ipv4
73
>
break
74
}
75
}
76
78
return nil, fmt.Errorf("no resolved IP for advertised hostname %q", advertisedHostname)
79
}
80
82
>
return resolvedIp, port
83
>
}), nil
84
}