use of org.jgroups.stack.IpAddress in project JGroups by belaban.
the class SSL_KEY_EXCHANGE method createSocketTo.
protected SSLSocket createSocketTo(Address target) throws Exception {
SSLSocketFactory sslSocketFactory = this.client_ssl_ctx.getSocketFactory();
if (target instanceof IpAddress)
return createSocketTo((IpAddress) target, sslSocketFactory);
IpAddress dest = (IpAddress) down_prot.down(new Event(Event.GET_PHYSICAL_ADDRESS, target));
SSLSocket sock;
for (int i = 0; i <= port_range; i++) {
try {
sock = (SSLSocket) sslSocketFactory.createSocket(dest.getIpAddress(), port + i);
sock.setSoTimeout(socket_timeout);
sock.setEnabledCipherSuites(sock.getSupportedCipherSuites());
sock.startHandshake();
SSLSession sslSession = sock.getSession();
log.debug("%s: created SSL connection to %s (%s); protocol: %s, cipher suite: %s", local_addr, target, sock.getRemoteSocketAddress(), sslSession.getProtocol(), sslSession.getCipherSuite());
if (session_verifier != null)
session_verifier.verify(sslSession);
return sock;
} catch (SecurityException sec_ex) {
throw sec_ex;
} catch (Throwable t) {
}
}
throw new IllegalStateException(String.format("failed connecting to %s (port range [%d - %d])", dest.getIpAddress(), port, port + port_range));
}
use of org.jgroups.stack.IpAddress in project JGroups by belaban.
the class TCPGOSSIP method removeInitialHost.
@ManagedOperation
public boolean removeInitialHost(String hostname, int port) {
InetSocketAddress isa = new InetSocketAddress(hostname, port);
stubManager.unregisterStub(new IpAddress(isa.getAddress(), isa.getPort()));
return initial_hosts.remove(isa);
}
use of org.jgroups.stack.IpAddress in project JGroups by belaban.
the class IpAddressTest method testStreamable.
public void testStreamable() throws Exception {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
DataOutputStream oos = new DataOutputStream(bos);
byte[] buf = null;
ByteArrayInputStream bis = null;
DataInputStream ois;
IpAddress a2, b2, x, x2, y, y2;
x = createStackConformantAddress(5555);
y = createStackConformantAddress(1111);
a.writeTo(oos);
b.writeTo(oos);
x.writeTo(oos);
y.writeTo(oos);
buf = bos.toByteArray();
bis = new ByteArrayInputStream(buf);
ois = new DataInputStream(bis);
a2 = new IpAddress();
a2.readFrom(ois);
b2 = new IpAddress();
b2.readFrom(ois);
x2 = new IpAddress();
x2.readFrom(ois);
y2 = new IpAddress();
y2.readFrom(ois);
Assert.assertEquals(a, a2);
Assert.assertEquals(b, b2);
assert y2.getIpAddress() != null;
Assert.assertEquals(1111, y2.getPort());
}
use of org.jgroups.stack.IpAddress in project JGroups by belaban.
the class IpAddressTest method setUp.
@BeforeClass
void setUp() throws Exception {
StackType type = Util.getIpStackType();
if (type == StackType.IPv6) {
a = new IpAddress("::1", 5555);
b = new IpAddress("::1", 5555);
d = new IpAddress("::1", 5556);
e = new IpAddress("::1", 5555);
f = new IpAddress("2001:0db8:0000:0000:0000:002e:0370:2334", 80);
g = new IpAddress("2001:0db8:0000:0000:0000:002e:0370:2334", 8080);
h = new IpAddress("ff0e::3:4:5", 5555);
} else {
a = new IpAddress("localhost", 5555);
b = new IpAddress("localhost", 5555);
d = new IpAddress("localhost", 5556);
e = new IpAddress("127.0.0.1", 5555);
f = new IpAddress("www.ibm.com", 80);
g = new IpAddress("www.ibm.com", 8080);
h = new IpAddress("224.0.0.1", 5555);
}
c = b;
}
use of org.jgroups.stack.IpAddress in project JGroups by belaban.
the class IpAddressTest method testConstructor.
public void testConstructor() throws Exception {
IpAddress tmp = new IpAddress("192.168.1.5:7800");
assert tmp.getPort() == 7800;
assert tmp.getIpAddress().equals(InetAddress.getByName("192.168.1.5"));
tmp = new IpAddress("10.1.2.3");
assert tmp.getPort() == 0;
assert tmp.getIpAddress().equals(InetAddress.getByName("10.1.2.3"));
tmp = new IpAddress("fe80::21b:21ff:fe07:a3b0:6000");
assert tmp.getPort() == 6000;
assert tmp.getIpAddress().equals(InetAddress.getByName("fe80::21b:21ff:fe07:a3b0"));
}
Aggregations