use of org.apache.beam.vendor.grpc.v1p43p2.io.netty.channel.unix.DomainSocketAddress in project netty by netty.
the class KQueueSocketTest method testPeerCreds.
@Test
public void testPeerCreds() throws IOException {
BsdSocket s1 = BsdSocket.newSocketDomain();
BsdSocket s2 = BsdSocket.newSocketDomain();
try {
DomainSocketAddress dsa = UnixTestUtils.newDomainSocketAddress();
s1.bind(dsa);
s1.listen(1);
assertTrue(s2.connect(dsa));
byte[] addr = new byte[64];
s1.accept(addr);
PeerCredentials pc = s1.getPeerCredentials();
assertNotEquals(pc.uid(), -1);
} finally {
s1.close();
s2.close();
}
}
use of org.apache.beam.vendor.grpc.v1p43p2.io.netty.channel.unix.DomainSocketAddress in project zuul by Netflix.
the class SocketAddressPropertyTest method bindTypeWorks_udsWithEquals.
@Test
public void bindTypeWorks_udsWithEquals() {
SocketAddress address = SocketAddressProperty.Decoder.INSTANCE.apply("UDS=/var/run/zuul=.sock");
assertEquals(DomainSocketAddress.class, address.getClass());
DomainSocketAddress domainSocketAddress = (DomainSocketAddress) address;
assertEquals("/var/run/zuul=.sock", domainSocketAddress.path());
}
use of org.apache.beam.vendor.grpc.v1p43p2.io.netty.channel.unix.DomainSocketAddress in project grpc-java by grpc.
the class Utils method parseServerSocketAddress.
/**
* Parse a {@link SocketAddress} from the given string.
*/
public static SocketAddress parseServerSocketAddress(String value) {
if (value.startsWith(UNIX_DOMAIN_SOCKET_PREFIX)) {
DomainSocketAddress domainAddress = parseUnixSocketAddress(value);
File file = new File(domainAddress.path());
try {
if (file.createNewFile()) {
// If this application created the file, delete it when the application exits.
file.deleteOnExit();
}
} catch (IOException ex) {
throw new RuntimeException(ex);
}
return domainAddress;
} else {
// Standard TCP/IP address.
String[] parts = value.split(":", 2);
if (parts.length < 2) {
throw new IllegalArgumentException("Address must be a unix:// path or be in the form host:port. Got: " + value);
}
String host = parts[0];
int port = Integer.parseInt(parts[1]);
return new InetSocketAddress(host, port);
}
}
use of org.apache.beam.vendor.grpc.v1p43p2.io.netty.channel.unix.DomainSocketAddress in project grpc-java by grpc.
the class Utils method parseUnixSocketAddress.
private static DomainSocketAddress parseUnixSocketAddress(String value) {
Preconditions.checkArgument(value.startsWith(UNIX_DOMAIN_SOCKET_PREFIX), "Must start with %s: %s", UNIX_DOMAIN_SOCKET_PREFIX, value);
// Unix Domain Socket address.
// Create the underlying file for the Unix Domain Socket.
String filePath = value.substring(UNIX_DOMAIN_SOCKET_PREFIX.length());
File file = new File(filePath);
if (!file.isAbsolute()) {
throw new IllegalArgumentException("File path must be absolute: " + filePath);
}
// Create the SocketAddress referencing the file.
return new DomainSocketAddress(file);
}
use of org.apache.beam.vendor.grpc.v1p43p2.io.netty.channel.unix.DomainSocketAddress in project grpc-java by grpc.
the class BinlogHelperTest method socketToProto_unix.
@Test
public void socketToProto_unix() throws Exception {
String path = "/some/path";
DomainSocketAddress socketAddress = new DomainSocketAddress(path);
assertEquals(Address.newBuilder().setType(Address.Type.TYPE_UNIX).setAddress("/some/path").build(), BinlogHelper.socketToProto(socketAddress));
}
Aggregations