1package gocql 2 3import "net" 4 5// AddressTranslator provides a way to translate node addresses (and ports) that are 6// discovered or received as a node event. This can be useful in an ec2 environment, 7// for instance, to translate public IPs to private IPs. 8type AddressTranslator interface { 9 // Translate will translate the provided address and/or port to another 10 // address and/or port. If no translation is possible, Translate will return the 11 // address and port provided to it. 12 Translate(addr net.IP, port int) (net.IP, int) 13} 14 15type AddressTranslatorFunc func(addr net.IP, port int) (net.IP, int) 16 17func (fn AddressTranslatorFunc) Translate(addr net.IP, port int) (net.IP, int) { 18 return fn(addr, port) 19} 20 21// IdentityTranslator will do nothing but return what it was provided. It is essentially a no-op. 22func IdentityTranslator() AddressTranslator { 23 return AddressTranslatorFunc(func(addr net.IP, port int) (net.IP, int) { 24 return addr, port 25 }) 26} 27