Package com.linecorp.armeria.common.util
Class DomainSocketAddress
java.lang.Object
java.net.SocketAddress
java.net.InetSocketAddress
com.linecorp.armeria.common.util.DomainSocketAddress
- All Implemented Interfaces:
Serializable
An
InetSocketAddress
that refers to a Unix domain socket path.
This class extends InetSocketAddress
to ensure the backward compatibility with existing
Armeria API that uses InetSocketAddress
in its API. This address will have the following properties:
- hostname and hostString -
"unix:<path>"
, e.g."unix:/var/run/server.sock"
- address - an IPv6 address that falls into IPv6 Discard Prefix
Pitfalls
Comparing two DomainSocketAddress
es using InetSocketAddress.equals(Object)
will always return true
because there's no way to override InetSocketAddress.equals(Object)
, which compares only the IP
addresses for resolved addresses. You should never use DomainSocketAddress
as a key of a Map
,
or as an element of a Set
; consider using Endpoint
instead.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionConverts this address to anEndpoint
.io.netty.channel.unix.DomainSocketAddress
Converts this address to a NettyDomainSocketAddress
.Returns the authority (host) form of this address which can be used as a part ofURI
.boolean
Returnstrue
if this address is in the abstract namespace.static boolean
Returns whether the specifiedInetAddress
matches the special IPv6 address ofDomainSocketAddress
.static DomainSocketAddress
of
(io.netty.channel.unix.DomainSocketAddress nettyAddr) Returns a newly createdDomainSocketAddress
with the Unix domain socket path of the specified Netty address.static DomainSocketAddress
Returns a newly createdDomainSocketAddress
with the specifiedpath
to the Unix domain socket.static DomainSocketAddress
Returns a newly createdDomainSocketAddress
with the specifiedPath
to the Unix domain socket.path()
Returns the path to the Unix domain socket.toString()
Returns a string representation of this address, such as"/path/to/sock"
or"@sock"
(abstract namespace).Methods inherited from class java.net.InetSocketAddress
createUnresolved, equals, getAddress, getHostName, getHostString, getPort, hashCode, isUnresolved
-
Method Details
-
of
Returns a newly createdDomainSocketAddress
with the specifiedPath
to the Unix domain socket. -
of
Returns a newly createdDomainSocketAddress
with the specifiedpath
to the Unix domain socket. -
of
Returns a newly createdDomainSocketAddress
with the Unix domain socket path of the specified Netty address. -
isDomainSocketAddress
Returns whether the specifiedInetAddress
matches the special IPv6 address ofDomainSocketAddress
. For example:DomainSocketAddress sockAddr = DomainSocketAddress.of("/var/run/server.sock"); InetAddress inetAddr = sockAddr.getAddress(); assert isDomainSocketAddress(inetAddr);
-
path
Returns the path to the Unix domain socket. -
isAbstract
public boolean isAbstract()Returnstrue
if this address is in the abstract namespace. -
authority
Returns the authority (host) form of this address which can be used as a part ofURI
. -
asNettyAddress
public io.netty.channel.unix.DomainSocketAddress asNettyAddress()Converts this address to a NettyDomainSocketAddress
.- Returns:
- the converted Netty address
-
asEndpoint
Converts this address to anEndpoint
. -
toString
Returns a string representation of this address, such as"/path/to/sock"
or"@sock"
(abstract namespace).- Overrides:
toString
in classInetSocketAddress
-