org.bdware.doip.audit.writer.ClientContext Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of doip-audit-tool Show documentation
Show all versions of doip-audit-tool Show documentation
doip audit tool developed by bdware
package org.bdware.doip.audit.writer;
import io.netty.channel.Channel;
import org.bdware.doip.audit.client.DoIdWrapper;
public class ClientContext extends EndpointContext {
private final Channel channel;
private final DoIdWrapper serverDoid;
private final DoIdWrapper clientDoid;
public ClientContext(DoIdWrapper clientDoid, DoIdWrapper serverDoid, Channel channel) {
this.channel = channel;
this.serverDoid = serverDoid;
this.clientDoid = clientDoid;
}
@Override
public String getClientIP() {
try {
return extractIP(channel.localAddress());
} catch (Exception e) {
return null;
}
}
@Override
public String getClientDoId() {
if (clientDoid != null) return clientDoid.getDoId();
return null;
}
@Override
public String getServerIP() {
try {
return extractIP(channel.remoteAddress());
} catch (Exception e) {
return null;
}
}
@Override
public String getServerDoId() {
if (serverDoid != null) return serverDoid.getDoId();
return null;
}
}