Class SessionGeoLogger
ILog, when the server setting ServerSettings.GEO_SESSION_LOG is on (it is off by default).Where it is called from (the exact points, all in com.iizix.server):
- connect: the end of the
ClientSessionGyroconstructor, which runs insideClientTransactionProcessor.createRooton the firstTRANS_UPDATEof a new connection - afterSessionTransMgr.onCommConnectedhas stored the remote address and after the user has been authenticated, so the user is known; - reconnect:
ClientTransactionProcessor.onReconnected, whichSessionTransMgr.processManagementTransactionscalls on the client'sMT_RECONNECTIONacknowledgement, afterSessionID.replaceReconnectedhas given the session the new connection'sSessionInfo; - disconnect: the start of
ClientSessionGyro.dispose(), reached fromClientTransactionProcessor.onDisposedwhen the session is disposed of (SessionTransMgr.doDispose) - a paused or broken connection is not a disconnect, the session lives on for reconnection.
Which address. ClientAddressResolver.resolve(InetAddress, ClientAddressResolver.ForwardedHeaders, ClientAddressResolver.TrustedProxies) over the remote address Jetty saw (SessionInfo.getRemoteAddress()) and the forwarded headers captured at the upgrade (ClientTransactionProcessor.getForwardedHeaders()), believed only from the trusted proxies of ServerSettings.GEO_TRUSTED_PROXIES. A private or local address is logged but never looked up (ClientAddressResolver.isPrivateOrLocal(InetAddress)).
Which provider. The default RegionLocationService - IP2Location when the local service is enabled, else the first registered web provider, else none - asked asynchronously: the connect event runs on the Jetty I/O thread, which must never block, so the line is written from the provider's reply thread unless the answer is already cached, in which case it is written at once. The device's own location ($geo), when the client has reported one, is appended with provenance DEVICE and the accuracy the device gave.
One log line per event, INFO, under this class:
Session geolocation connect: session=12 app=demo user=jane device=... ip=203.0.113.9 (source=REMOTE) provider=IP2Location provenance=IP accuracy=unknown country=SE region=Stockholms lan city=Stockholm
- Author:
- Christopher Mindus
Method Summary
Modifier and TypeMethodDescriptionstatic booleanReturns if session geolocation logging is on.static voidonConnected(ClientSessionGyro clientGyro) Called when a client session has been created (connected and authenticated).static voidonDisconnected(ClientSessionGyro clientGyro) Called when a client session is disposed of.static voidonReconnected(ClientSessionGyro clientGyro) Called when a client session has been reconnected on a new connection.
Method Details
onConnected
Called when a client session has been created (connected and authenticated).- Parameters:
clientGyro- The client session gyro.
onReconnected
Called when a client session has been reconnected on a new connection.- Parameters:
clientGyro- The client session gyro.
onDisconnected
Called when a client session is disposed of.- Parameters:
clientGyro- The client session gyro.
isEnabled
public static boolean isEnabled()Returns if session geolocation logging is on.- Returns:
- The state of the
ServerSettings.GEO_SESSION_LOGsetting, false without a server (ServerShellHolder.getInstance()is null until the server is built, whereServerShell.getInstance()would throw).