In Confluence 9 I have working:
// Get request and retrieve IP address
def request = (new StaticHttpContext()).getRequest()
def remote = request?.getHeader("X-FORWARDED-FOR")
if (!remote) {
remote = request?.remoteAddr
}
This fails for Confluence 10:
Event listener failed: event: com.atlassian.confluence.event.events.content.page.PageViewEvent, id: 851255bb-6d07-47e5-bcfe-cd42e59f743a, script notes: Post Events to splunk.netic.dk groovy.lang.MissingMethodException: No signature of method: com.atlassian.confluence.web.context.StaticHttpContext.getRequest() is applicable for argument types: () values: [] at dk.netic.groovy.post2splunk.run(post2splunk.groovy:23)
So I need the new way to get the Request.
Goal: Get souce IP of the Request via the X-FORWARDED-FOR header