mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +00:00
fixed client ip address
This commit is contained in:
parent
ade836c08a
commit
526f0c09bc
4 changed files with 13 additions and 6 deletions
|
@ -145,6 +145,7 @@ public class Session {
|
|||
callbackMetadata.put(Bisocket.IS_CALLBACK_SERVER, "true");
|
||||
CallbackHandler callbackHandler = new CallbackHandler();
|
||||
callbackClient.addListener(callbackHandler, callbackMetadata);
|
||||
callbackClient.invoke("");
|
||||
|
||||
this.sessionId = callbackClient.getSessionId();
|
||||
boolean registerResult = false;
|
||||
|
|
|
@ -53,6 +53,7 @@ import org.jboss.remoting.ClientDisconnectedException;
|
|||
import org.jboss.remoting.ConnectionListener;
|
||||
import org.jboss.remoting.InvocationRequest;
|
||||
import org.jboss.remoting.InvokerLocator;
|
||||
import org.jboss.remoting.Remoting;
|
||||
import org.jboss.remoting.ServerInvocationHandler;
|
||||
import org.jboss.remoting.ServerInvoker;
|
||||
import org.jboss.remoting.callback.InvokerCallbackHandler;
|
||||
|
@ -175,6 +176,9 @@ public class Main {
|
|||
|
||||
@Override
|
||||
public Object invoke(final InvocationRequest invocation) throws Throwable {
|
||||
String sessionId = invocation.getSessionId();
|
||||
InetAddress clientAddress = (InetAddress) invocation.getRequestPayload().get(Remoting.CLIENT_ADDRESS);
|
||||
SessionManager.getInstance().getSession(sessionId).setHost(clientAddress.getHostAddress());
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -183,8 +187,7 @@ public class Main {
|
|||
ServerInvokerCallbackHandler handler = (ServerInvokerCallbackHandler) callbackHandler;
|
||||
try {
|
||||
String sessionId = handler.getClientSessionId();
|
||||
InetAddress clientAddress = handler.getCallbackClient().getAddressSeenByServer();
|
||||
SessionManager.getInstance().createSession(sessionId, callbackHandler, clientAddress.getHostAddress());
|
||||
SessionManager.getInstance().createSession(sessionId, callbackHandler);
|
||||
} catch (Throwable ex) {
|
||||
logger.fatal("", ex);
|
||||
}
|
||||
|
|
|
@ -55,10 +55,9 @@ public class Session {
|
|||
private boolean isAdmin = false;
|
||||
private AsynchInvokerCallbackHandler callbackHandler;
|
||||
|
||||
public Session(String sessionId, InvokerCallbackHandler callbackHandler, String host) {
|
||||
public Session(String sessionId, InvokerCallbackHandler callbackHandler) {
|
||||
this.sessionId = sessionId;
|
||||
this.callbackHandler = (AsynchInvokerCallbackHandler) callbackHandler;
|
||||
this.host = host;
|
||||
this.isAdmin = false;
|
||||
this.timeConnected = new Date();
|
||||
}
|
||||
|
@ -134,4 +133,8 @@ public class Session {
|
|||
public Date getConnectionTime() {
|
||||
return timeConnected;
|
||||
}
|
||||
|
||||
void setHost(String hostAddress) {
|
||||
this.host = hostAddress;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,8 +57,8 @@ public class SessionManager {
|
|||
return sessions.get(sessionId);
|
||||
}
|
||||
|
||||
public void createSession(String sessionId, InvokerCallbackHandler callbackHandler, String host) {
|
||||
Session session = new Session(sessionId, callbackHandler, host);
|
||||
public void createSession(String sessionId, InvokerCallbackHandler callbackHandler) {
|
||||
Session session = new Session(sessionId, callbackHandler);
|
||||
sessions.put(sessionId, session);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue