<%@ page contentType="text/html; charset=UTF-8" %> <%-- - - Copyright (C) 2004-2008 Jive Software, 2017-2026 Ignite Realtime Foundation. All rights reserved. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. --%> <%@ page import="org.jivesoftware.openfire.SessionManager, org.jivesoftware.util.ParamUtils, org.jivesoftware.util.StringUtils, org.jivesoftware.util.CookieUtils, java.util.*" errorPage="error.jsp" %> <%@ page import="org.jivesoftware.openfire.session.*" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %> <%! final int DEFAULT_RANGE = 15; final int[] RANGE_PRESETS = {15, 25, 50, 75, 100}; %> <% webManager.init(request, response, session, application, out ); %> <% // Get parameters int start = ParamUtils.getIntParameter(request,"start",0); int range = ParamUtils.getIntParameter(request,"range",webManager.getRowsPerPage("server-session-summary", DEFAULT_RANGE)); boolean close = ParamUtils.getBooleanParameter(request,"close"); String domainName = ParamUtils.getParameter(request,"hostname"); Cookie csrfCookie = CookieUtils.getCookie(request, "csrf"); String csrfParam = ParamUtils.getParameter(request, "csrf"); if (close) { if (csrfCookie == null || csrfParam == null || !csrfCookie.getValue().equals(csrfParam)) { close = false; } } csrfParam = StringUtils.randomString(15); CookieUtils.setCookie(request, response, "csrf", csrfParam, -1); pageContext.setAttribute("csrf", csrfParam); if (request.getParameter("range") != null) { webManager.setRowsPerPage("server-session-summary", range); } // Get the session manager SessionManager sessionManager = webManager.getSessionManager(); // Close all connections related to the specified domain name if (close) { try { final List incomingServerSessions = sessionManager.getIncomingServerSessions(domainName); for (Session incomingServerSession : incomingServerSessions) { incomingServerSession.markNonResumable(); incomingServerSession.close(); } Collection outgoingServerSessions = sessionManager.getOutgoingServerSessions(domainName); for (OutgoingServerSession outgoingServerSession : outgoingServerSessions) { if (outgoingServerSession != null) { outgoingServerSession.markNonResumable(); outgoingServerSession.close(); } } // Log the event webManager.logEvent("closed server sessions for "+ domainName, "Closed " + incomingServerSessions.size() + " incoming and " + outgoingServerSessions + " outgoing session(s)."); // wait one second Thread.sleep(250L); } catch (Exception ignored) { // Session might have disappeared on its own } // redirect back to this page response.sendRedirect("server-session-summary.jsp?close=success"); return; } // Get the session count final Set connectedDomainNames = new HashSet<>(); connectedDomainNames.addAll(sessionManager.getIncomingServers()); connectedDomainNames.addAll(sessionManager.getOutgoingServers()); final Set domainNames = new TreeSet<>(); final Set failedServers = new HashSet<>(sessionManager.getFailedServers()); domainNames.addAll(connectedDomainNames); domainNames.addAll(failedServers); final int sessionCount = domainNames.size(); // paginator vars int numPages = (int)Math.ceil((double)sessionCount/(double)range); int curPage = (start/range) + 1; int maxIndex = Math.min(start + range, sessionCount); %> <fmt:message key="server.session.summary.title"/> <% if ("success".equals(request.getParameter("close"))) { %>

<% } %>

: <%= connectedDomainNames.size() %> <% if (!failedServers.isEmpty()) { %> - : <%= failedServers.size() %> <% } %> <% if (numPages > 1) { %> - <%= (start+1) %>-<%= (start+range) %> <% } %> - :

<% if (numPages > 1) { %>

: [ <% for (int i=0; i " ><%= (i+1) %><%= sep %> <% } %> ]

<% } %>

" />

<% // Check if no out/in connection to/from a remote server exists if (domainNames.isEmpty()) { %> <% } %> <% int count = 0; final List paginatedDomainNames = new ArrayList<>(domainNames).subList(start, maxIndex); for (String host : paginatedDomainNames) { count++; List inSessions = sessionManager.getIncomingServerSessions(host); List outSessions = sessionManager.getOutgoingServerSessions(host); final boolean isFailedSession = failedServers.contains(host); // Potentially shows a functional _inbound_ session next to an erroneous _outbound_ session. Somewhat confusing, but better than not showing an error at all. if (inSessions.isEmpty() && outSessions.isEmpty() && !isFailedSession) { // If the connections were just closed then skip this host continue; } %> <%@ include file="server-session-row.jspf" %> <% } %>
 
<% if (numPages > 1) { %>

: [ <% for (int i=0; i " ><%= (i+1) %><%= sep %> <% } %> ]

<% } %>

: <%= JiveGlobals.formatDateTime(new Date()) %>