Java Code Examples for io.vertx.core.net.SocketAddress#host()

The following examples show how to use io.vertx.core.net.SocketAddress#host() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VertxHttpExchange.java    From quarkus-http with Apache License 2.0 5 votes vote down vote up
@Override
public InetSocketAddress getSourceAddress() {
    SocketAddress socketAddress = request.remoteAddress();
    if (socketAddress == null) {
        return null;
    }
    return new InetSocketAddress(socketAddress.host(), socketAddress.port());
}
 
Example 2
Source File: TestVertxServerRequestToHttpServletRequest.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetgetLocalAddr(@Mocked SocketAddress sa) {
  new Expectations() {
    {
      sa.host();
      result = "host";
      vertxRequest.localAddress();
      result = sa;
    }
  };

  Assert.assertEquals("host", request.getLocalAddr());
}
 
Example 3
Source File: RemoteHostAttribute.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@Override
public String readAttribute(final RoutingContext exchange) {
    final SocketAddress remoteAddr = exchange.request().remoteAddress();
    if (remoteAddr == null) {
        return null;
    }
    return remoteAddr.host();
}
 
Example 4
Source File: RemoteIPAttribute.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@Override
public String readAttribute(final RoutingContext exchange) {
    final SocketAddress sourceAddress = exchange.request().remoteAddress();
    if (sourceAddress == null) {
        return null;
    }
    return sourceAddress.host();
}
 
Example 5
Source File: LocalIPAttribute.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@Override
public String readAttribute(final RoutingContext exchange) {
    SocketAddress localAddress = exchange.request().localAddress();
    if (localAddress == null) {
        return null;
    }
    return localAddress.host();
}
 
Example 6
Source File: LazyHostSupplier.java    From quarkus with Apache License 2.0 5 votes vote down vote up
public String getRemoteHost() {
    if (initialized) {
        return this.remoteHost;
    } else {
        SocketAddress socketAddress = request.remoteAddress();
        // client address may not be available with VirtualHttp;
        this.remoteHost = socketAddress != null ? socketAddress.host() : null;
        initialized = true;
        return this.remoteHost;
    }
}
 
Example 7
Source File: VertxServerHttpRequest.java    From vertx-spring-boot with Apache License 2.0 5 votes vote down vote up
@Override
public InetSocketAddress getRemoteAddress() {
    SocketAddress address = delegate.remoteAddress();
    if (address == null) {
        return null;
    }
    return new InetSocketAddress(address.host(), address.port());
}
 
Example 8
Source File: VertxTcpClient.java    From jetlinks-community with Apache License 2.0 5 votes vote down vote up
@Override
public InetSocketAddress getRemoteAddress() {
    if (null == socket) {
        return null;
    }
    SocketAddress socketAddress = socket.remoteAddress();
    return new InetSocketAddress(socketAddress.host(), socketAddress.port());
}
 
Example 9
Source File: VertxHttpExchange.java    From quarkus-http with Apache License 2.0 5 votes vote down vote up
@Override
public InetSocketAddress getDestinationAddress() {
    SocketAddress socketAddress = request.localAddress();
    if (socketAddress == null) {
        return null;
    }
    return new InetSocketAddress(socketAddress.host(), socketAddress.port());
}
 
Example 10
Source File: Labels.java    From vertx-micrometer-metrics with Apache License 2.0 4 votes vote down vote up
public static String fromAddress(SocketAddress address) {
  return address == null ? "?" : (address.host() + ":" + address.port());
}
 
Example 11
Source File: AccessLogHandler.java    From mpns with Apache License 2.0 4 votes vote down vote up
private String getClientAddress(HttpServerRequest request) {
    SocketAddress address = request.remoteAddress();
    if (address == null) return null;
    return address.host();
}
 
Example 12
Source File: VertxHttpServerRequest.java    From graviteeio-access-management with Apache License 2.0 4 votes vote down vote up
@Override
public String remoteAddress() {
    SocketAddress address = httpServerRequest.remoteAddress();
    return (address != null) ? address.host() : null;
}
 
Example 13
Source File: VertxHttpServerRequest.java    From graviteeio-access-management with Apache License 2.0 4 votes vote down vote up
@Override
public String localAddress() {
    SocketAddress address = httpServerRequest.localAddress();
    return (address != null) ? address.host() : null;
}
 
Example 14
Source File: VertxHttpServerRequest.java    From gravitee-gateway with Apache License 2.0 4 votes vote down vote up
@Override
public String remoteAddress() {
    SocketAddress address = httpServerRequest.remoteAddress();
    return (address != null) ? address.host() : null;
}
 
Example 15
Source File: VertxHttpServerRequest.java    From gravitee-gateway with Apache License 2.0 4 votes vote down vote up
@Override
public String localAddress() {
    SocketAddress address = httpServerRequest.localAddress();
    return (address != null) ? address.host() : null;
}
 
Example 16
Source File: TCPMetricsImpl.java    From vertx-dropwizard-metrics with Apache License 2.0 4 votes vote down vote up
static String addressName(SocketAddress address) {
  if (address == null) return null;

  return address.host() + ":" + address.port();
}
 
Example 17
Source File: LoggerHandlerImpl.java    From vertx-web with Apache License 2.0 4 votes vote down vote up
private String getClientAddress(SocketAddress inetSocketAddress) {
  if (inetSocketAddress == null) {
    return null;
  }
  return inetSocketAddress.host();
}
 
Example 18
Source File: RequestFromVertx.java    From wisdom with Apache License 2.0 4 votes vote down vote up
/**
 * The request host.
 */
@Override
public String host() {
    SocketAddress remote = request.remoteAddress();
    return remote.host();
}