support ipv6 in artery (#30190)
This commit is contained in:
parent
390e9f675b
commit
dfd6ae20ea
2 changed files with 14 additions and 4 deletions
|
|
@ -203,7 +203,7 @@ private[io] final class AsyncDnsResolver(
|
|||
* INTERNAL API
|
||||
*/
|
||||
@InternalApi
|
||||
private[io] object AsyncDnsResolver {
|
||||
private[akka] object AsyncDnsResolver {
|
||||
|
||||
private val ipv4Address =
|
||||
"""^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$""".r
|
||||
|
|
@ -211,10 +211,15 @@ private[io] object AsyncDnsResolver {
|
|||
private val ipv6Address =
|
||||
"""^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$""".r
|
||||
|
||||
private def isInetAddress(name: String): Boolean =
|
||||
ipv4Address.findAllMatchIn(name).nonEmpty ||
|
||||
private[akka] def isIpv4Address(name: String): Boolean =
|
||||
ipv4Address.findAllMatchIn(name).nonEmpty
|
||||
|
||||
private[akka] def isIpv6Address(name: String): Boolean =
|
||||
ipv6Address.findAllMatchIn(name).nonEmpty
|
||||
|
||||
private def isInetAddress(name: String): Boolean =
|
||||
isIpv4Address(name) || isIpv6Address(name)
|
||||
|
||||
private val Empty =
|
||||
Future.successful(Answer(-1, immutable.Seq.empty[ResourceRecord], immutable.Seq.empty[ResourceRecord]))
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import akka.util.Helpers.Requiring
|
|||
import akka.util.Helpers.toRootLowerCase
|
||||
import akka.util.WildcardIndex
|
||||
import akka.util.ccompat.JavaConverters._
|
||||
import akka.io.dns.internal.AsyncDnsResolver
|
||||
|
||||
/** INTERNAL API */
|
||||
private[akka] final class ArterySettings private (config: Config) {
|
||||
|
|
@ -292,7 +293,11 @@ private[akka] object ArterySettings {
|
|||
def getHostname(key: String, config: Config): String = config.getString(key) match {
|
||||
case "<getHostAddress>" => InetAddress.getLocalHost.getHostAddress
|
||||
case "<getHostName>" => InetAddress.getLocalHost.getHostName
|
||||
case other => other
|
||||
case other =>
|
||||
if (other.startsWith("[") && other.endsWith("]")) other
|
||||
else if (AsyncDnsResolver.isIpv6Address(other)) {
|
||||
"[" + other + "]"
|
||||
} else other
|
||||
}
|
||||
|
||||
sealed trait Transport {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue