listeners = new ArrayList<>();
- boolean enabled = true;
-
- public Echo(int port) throws UnknownHostException, SocketException {
- this.socket = new DatagramSocket(port, InetAddress.getByName("0.0.0.0"));
- }
-
- @Override
- public void run() {
- try {
- //System.out.println("Listening for ECHO: " + socket.getLocalAddress().getHostAddress() + ":" + socket.getLocalPort());
- while (true) {
-
- DatagramPacket packet = new DatagramPacket(new byte[8], 8);
-
- socket.receive(packet);
-
- System.out.println("ECHO Packet Received in: " + socket.getLocalAddress().getHostAddress() + ":" + socket.getLocalPort() + " From: " + packet.getAddress().getHostAddress() + ":" + packet.getPort());
-
- for (DatagramListener listener : listeners) {
- try {
- listener.datagramReceived(packet);
- } catch (Exception e) {
- Log.warn("An exception occurred while dispatching a 'datagramReceived' event!", e);
- }
- }
-
- packet.setAddress(packet.getAddress());
- packet.setPort(packet.getPort());
- if (!Arrays.equals(packet.getData(), password))
- for (int i = 0; i < 3; i++)
- socket.send(packet);
- }
- } catch (IOException ioe) {
- if (enabled) {
- }
- }
- }
-
- public void cancel() {
- this.enabled = false;
- socket.close();
- }
-}
diff --git a/xmppserver/src/main/java/org/jivesoftware/openfire/mediaproxy/MediaProxy.java b/xmppserver/src/main/java/org/jivesoftware/openfire/mediaproxy/MediaProxy.java
deleted file mode 100644
index 73908e4c7b..0000000000
--- a/xmppserver/src/main/java/org/jivesoftware/openfire/mediaproxy/MediaProxy.java
+++ /dev/null
@@ -1,258 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Jive Software, 2017-2019 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.
- */
-
-package org.jivesoftware.openfire.mediaproxy;
-
-import java.util.Collection;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * A Media Proxy relays UDP traffic between two IPs to provide connectivity between
- * two parties that are behind NAT devices. It also provides connectivity
- * between two parties that are directly connected to the internet or one party on the
- * internet and another behind a NAT.
- *
- * Each connection relay between two parties is called a session. You can setup a MediaProxy
- * for all network interfaces with an empty constructor, or bind it to a specific interface
- * with the MediaProxy(String localhost) constructor. The media proxy ONLY works if you
- * are directly connected to the Internet with a valid IP address..
- *
- * @author Thiago Camargo
- */
-public class MediaProxy implements SessionListener {
-
- private static final Logger Log = LoggerFactory.getLogger(MediaProxy.class);
-
- final private Map sessions = new ConcurrentHashMap<>();
-
- private String ipAddress;
-
- private int minPort = 10000;
- private int maxPort = 20000;
-
- private long idleTime = 60000;
-
- // Lifetime of a Channel in Seconds
- private long lifetime = 9000;
-
- /**
- * Contruct a MediaProxy instance that will listen on a specific network interface.
- *
- * @param ipAddress the IP address on this server that will listen for packets.
- */
- public MediaProxy(String ipAddress) {
- this.ipAddress = ipAddress;
- }
-
- /**
- * Get the public IP of this media proxy that listen for incomming packets.
- *
- * @return the host that listens for incomming packets.
- */
- public String getPublicIP() {
- return ipAddress;
- }
-
- /**
- * Returns the max time (in millis) that a session can remain open without
- * receiving any packets. After this time period elapses, the session is
- * automatically closed.
- *
- * @return the max idle time (in millis).
- */
- public long getIdleTime() {
- return idleTime;
- }
-
- /**
- * Sets the max time (in millis) that a session can remain open without
- * receiving any packets. After this time period elapses, the session is
- * automatically closed.
- *
- * @param idleTime the max idle time in millis.
- */
- public void setIdleTime(long idleTime) {
- this.idleTime = idleTime;
- }
-
- /**
- * Returns the list of all currently active and running sessions.
- *
- * @return List of the Agents
- */
- public Collection getSessions() {
- return sessions.values();
- }
-
- /**
- * Returns the minimum port value to listen for incoming packets.
- *
- * @return the minimum port value.
- */
- public int getMinPort() {
- return minPort;
- }
-
- /**
- * Sets the minimum port value to listen from incoming packets.
- *
- * @param minPort the minimum port value.
- */
- public void setMinPort(int minPort) {
- this.minPort = minPort;
- }
-
- /**
- * Returns the maximum port value to listen for incoming packets.
- *
- * @return the maximun port value.
- */
- public int getMaxPort() {
- return maxPort;
- }
-
- /**
- * Sets the maximum port value to listen for incoming packets.
- *
- * @param maxPort the maximun port value.
- */
- public void setMaxPort(int maxPort) {
- this.maxPort = maxPort;
- }
-
- /**
- * Returns the maximum lifetime (in seconds) of a session. After the time period
- * elapses, the session will be destroyed even if currently active.
- *
- * @return the max lifetime of a session (in seconds).
- */
- public long getLifetime() {
- return lifetime;
- }
-
- /**
- * Sets the maximum lifetime (in seconds) of a session. After the time period
- * elapses, the session will be destroyed even if currently active.
- *
- * @param lifetime the max lifetime of a session (in seconds).
- */
- public void setLifetime(long lifetime) {
- this.lifetime = lifetime;
- }
-
- /**
- * Returns a media proxy session with the specified ID.
- *
- * @param sid the session ID.
- * @return the session or {@code null} if the session doesn't exist.
- */
- public MediaProxySession getSession(String sid) {
- MediaProxySession proxySession = sessions.get(sid);
- if (proxySession != null) {
- if (Log.isDebugEnabled()) {
- Log.debug("MediaProxy: SID: " + sid + " agentSID: " + proxySession.getSID());
- return proxySession;
- }
- }
- return null;
- }
-
- /**
- * Implements Session Listener stopAgent event.
- * Remove the stopped session from the sessions list.
- *
- * @param session the session that stopped
- */
- @Override
- public void sessionClosed(MediaProxySession session) {
- sessions.remove(session.getSID());
- if (Log.isDebugEnabled()) {
- Log.debug("MediaProxy: Session: " + session.getSID() + " removed.");
- }
- }
-
- /**
- * Add a new Dynamic Session to the mediaproxy for defined IPs and ports.
- * The IP and port pairs can change depending of the Senders IP and port.
- * Which means that the IP and port values of the points can dynamic change after the Channel is opened.
- * When the agent receives a packet from Point A, the channel set the point A IP and port according to
- * the received packet sender IP and port.
- * Every packet received from Point B will be relayed to the new Point A IP and port.
- * When the agent receives a packet from Point B, the channel set the point B IP and port according to
- * the received packet sender IP and port.
- * Every packet received from Point A will be relayed to the new Point B IP and port.
- * Create a dynamic channel between two IPs. ( Dynamic Point A - Dynamic Point B )
- *
- * @param id id of the candidate returned (Could be a Jingle session ID)
- * @param creator the agent creator name or description
- * @param hostA the hostname or IP of the point A of the Channel
- * @param portA the port number point A of the Channel
- * @param hostB the hostname or IP of the point B of the Channel
- * @param portB the port number point B of the Channel
- * @return the added ProxyCandidate
- */
- public ProxyCandidate addRelayAgent(String id, String creator, String hostA, int portA,
- String hostB, int portB)
- {
- RelaySession session = new RelaySession(id, creator, ipAddress, hostA, portA, hostB, portB, minPort, maxPort);
- sessions.put(id, session);
- session.addKeepAlive(idleTime);
- session.addLifeTime(lifetime);
- session.addAgentListener(this);
- return session;
- }
-
- /**
- * Add a new Dynamic Session to the mediaproxy WITHOUT defined IPs and ports.
- * The IP and port pairs WILL change depending of the Senders IP and port.
- * Which means that the IP and port values of the points will dynamic change after the Channel is opened
- * and received packet from both points.
- * When the agent receives a packet from Point A, the channel set the point A IP and port according to
- * the received packet sender IP and port.
- * Every packet received from Point B will be relayed to the new Point A IP and port.
- * When the agent receives a packet from Point B, the channel set the point B IP and port according to
- * the received packet sender IP and port.
- * Every packet received from Point A will be relayed to the new Point B IP and port.
- * Create a dynamic channel between two IPs. ( Dynamic Point A - Dynamic Point B )
- *
- * @param id id of the candidate returned (Could be a Jingle session ID)
- * @param creator the agent creator name or description
- * @return the added ProxyCandidate
- */
- public ProxyCandidate addRelayAgent(String id, String creator) {
- return addRelayAgent(id, creator, ipAddress, 40000, ipAddress, 40004);
- }
-
- /**
- * Stop every running sessions.
- */
- void stopProxy() {
- for (MediaProxySession session : getSessions()) {
- try {
- session.clearAgentListeners();
- session.stopAgent();
- }
- catch (Exception e) {
- Log.error("Error cleaning up media proxy sessions", e);
- }
- }
- sessions.clear();
- }
-}
diff --git a/xmppserver/src/main/java/org/jivesoftware/openfire/mediaproxy/MediaProxyService.java b/xmppserver/src/main/java/org/jivesoftware/openfire/mediaproxy/MediaProxyService.java
deleted file mode 100644
index 7afe72768c..0000000000
--- a/xmppserver/src/main/java/org/jivesoftware/openfire/mediaproxy/MediaProxyService.java
+++ /dev/null
@@ -1,480 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Jive Software, 2017-2025 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.
- */
-
-package org.jivesoftware.openfire.mediaproxy;
-
-import org.dom4j.Attribute;
-import org.dom4j.DocumentHelper;
-import org.dom4j.Element;
-import org.jivesoftware.openfire.*;
-import org.jivesoftware.openfire.auth.UnauthorizedException;
-import org.jivesoftware.openfire.container.BasicModule;
-import org.jivesoftware.openfire.disco.*;
-import org.jivesoftware.util.JiveGlobals;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.xmpp.forms.DataForm;
-import org.xmpp.packet.IQ;
-import org.xmpp.packet.JID;
-import org.xmpp.packet.Packet;
-import org.xmpp.packet.PacketError;
-
-import java.net.SocketException;
-import java.net.UnknownHostException;
-import java.util.*;
-
-/**
- * A proxy service for UDP traffic such as RTP. It provides Jingle transport candidates
- * to be used for media transmission. The media proxy is especially useful for users
- * behind NAT devices or firewalls that prevent peer to peer communication.
- *
- * @author Thiago Camargo
- */
-public class MediaProxyService extends BasicModule
- implements ServerItemsProvider, RoutableChannelHandler, DiscoInfoProvider, DiscoItemsProvider {
-
- private static final Logger Log = LoggerFactory.getLogger(MediaProxyService.class);
-
- private String serviceName;
- private RoutingTable routingTable;
- private PacketRouter router;
- private Echo echo = null;
- private int echoPort = 10020;
- private SessionManager sessionManager = null;
-
- private MediaProxy mediaProxy = null;
- private boolean enabled = true;
-
- public static final String NAMESPACE = "http://www.jivesoftware.com/protocol/rtpbridge";
-
- /**
- * Constructs a new MediaProxyService.
- */
- public MediaProxyService() {
- super("Media Proxy Service");
- }
-
- @Override
- public void initialize(XMPPServer server) {
- super.initialize(server);
-
- sessionManager = server.getSessionManager();
- // In some cases, the domain name of the server may not be the actual address of the machine
- // (ie, when using DNS SRV records). In that case, the "mediaproxy.externalip" property should be
- // set to the IP address of the actual server where the media proxy is listening.
- String ipAddress = JiveGlobals.getProperty("mediaproxy.externalip", server.getServerInfo().getXMPPDomain());
- mediaProxy = new MediaProxy(ipAddress);
-
- String defaultName = "rtpbridge";
- serviceName = JiveGlobals.getProperty("mediaproxy.serviceName", defaultName);
- serviceName = serviceName.isEmpty() ? defaultName : serviceName;
-
- echoPort = JiveGlobals.getIntProperty("mediaproxy.echoPort", echoPort);
-
- routingTable = server.getRoutingTable();
- router = server.getPacketRouter();
-
- initMediaProxy();
- }
-
- @Override
- public void start() {
- if (isEnabled()) {
-
- try {
- echo = new Echo(echoPort);
- Thread t = new Thread(echo);
- t.start();
- } catch (UnknownHostException | SocketException e) {
- // Ignore
- }
-
- routingTable.addComponentRoute(getAddress(), this);
- XMPPServer.getInstance().getIQDiscoItemsHandler().addServerItemsProvider(this);
- } else {
- if (echo != null) echo.cancel();
- XMPPServer.getInstance().getIQDiscoItemsHandler().removeComponentItem(getAddress().toString());
- }
- }
-
- @Override
- public void stop() {
- super.stop();
- mediaProxy.stopProxy();
- XMPPServer.getInstance().getIQDiscoItemsHandler().removeComponentItem(getAddress().toString());
- routingTable.removeComponentRoute(getAddress());
- if (echo != null) echo.cancel();
- }
-
- // Component Interface
-
- @Override
- public String getName() {
- // Get the name from the plugin.xml file.
- return serviceName;
- }
-
- @Override
- public Iterator getItems(String name, String node, JID senderJID) {
- // A proxy server has no items
- return new ArrayList().iterator();
- }
-
- @Override
- public void process(Packet packet) throws UnauthorizedException, PacketException {
- // Check if user is allowed to send packet to this service
- if (packet instanceof IQ) {
- // Handle disco packets
- IQ iq = (IQ) packet;
- // Ignore IQs of type ERROR or RESULT
- if (IQ.Type.error == iq.getType() || IQ.Type.result == iq.getType()) {
- return;
- }
- processIQ(iq);
- }
- }
-
- private void processIQ(IQ iq) {
- IQ reply = IQ.createResultIQ(iq);
- Element childElement = iq.getChildElement();
- String namespace = childElement.getNamespaceURI();
- Element childElementCopy = iq.getChildElement().createCopy();
- reply.setChildElement(childElementCopy);
-
- if ("http://jabber.org/protocol/disco#info".equals(namespace)) {
- reply = XMPPServer.getInstance().getIQDiscoInfoHandler().handleIQ(iq);
- router.route(reply);
- return;
- } else if ("http://jabber.org/protocol/disco#items".equals(namespace)) {
- // a component
- reply = XMPPServer.getInstance().getIQDiscoItemsHandler().handleIQ(iq);
- router.route(reply);
- return;
- } else if (NAMESPACE.equals(namespace) && enabled) {
-
- List candidateElements = childElementCopy.elements("candidate");
- String sid = childElementCopy.attribute("sid").getValue() + "-" + iq.getFrom();
-
- if (!candidateElements.isEmpty()) {
- for (final Element candidateElement : candidateElements) {
- childElementCopy.remove(candidateElement);
- Element candidate = childElementCopy.addElement("candidate ");
- ProxyCandidate proxyCandidate = mediaProxy.addRelayAgent(sid, iq.getFrom().toString());
- Log.debug("MediaProxyService: "+sid);
- proxyCandidate.start();
- candidate.addAttribute("name", "voicechannel");
- candidate.addAttribute("ip", mediaProxy.getPublicIP());
- candidate.addAttribute("porta", String.valueOf(proxyCandidate.getLocalPortA()));
- candidate.addAttribute("portb", String.valueOf(proxyCandidate.getLocalPortB()));
- candidate.addAttribute("pass", proxyCandidate.getPass());
- }
- } else {
- final List relayElements = childElementCopy.elements("relay");
- if (!relayElements.isEmpty()) {
- for (final Element relayElement : relayElements) {
- MediaProxySession session = mediaProxy.getSession(sid);
- Log.debug("MediaProxyService: {}", sid);
- if (session != null) {
- Attribute pass = relayElement.attribute("pass");
-
- if (pass != null && pass.getValue().trim().equals(session.getPass().trim())) {
- Attribute portA = relayElement.attribute("porta");
- Attribute portB = relayElement.attribute("portb");
- Attribute hostA = relayElement.attribute("hosta");
- Attribute hostB = relayElement.attribute("hostb");
-
- try {
- if (hostA != null && portA != null) {
- for (int i = 0; i < 2; i++) {
- session.sendFromPortA(hostB.getValue(), Integer.parseInt(portB.getValue()));
- }
- }
- } catch (Exception e) {
- Log.error(e.getMessage(), e);
- }
-
- } else {
- reply.setError(PacketError.Condition.forbidden);
- }
- }
- childElementCopy.remove(relayElement);
- }
- } else {
- final List publicips = childElementCopy.elements("publicip");
- if (!publicips.isEmpty()) {
- for (final Element publicip : publicips) {
- childElementCopy.remove(publicip);
- Element publicIp = childElementCopy.addElement("publicip");
- try {
- String ip = sessionManager.getSession(iq.getFrom()).getHostAddress();
- if (ip != null) {
- publicIp.addAttribute("ip", ip);
- }
- } catch (UnknownHostException e) {
- Log.error(e.getMessage(), e);
- }
- }
- } else {
- reply.setError(PacketError.Condition.forbidden);
- }
- }
- }
- } else {
- // Answer an error since the server can't handle the requested namespace
- Log.trace("Responding with 'service-unavailable': the server can't handle the requested namespace: {}", iq);
- reply.setError(PacketError.Condition.service_unavailable);
- }
-
- try {
- if (Log.isDebugEnabled()) {
- Log.debug("MediaProxyService: RETURNED:" + reply.toXML());
- }
- router.route(reply);
- }
- catch (Exception e) {
- Log.error(e.getMessage(), e);
- }
- }
-
- /**
- * Load config using JiveGlobals
- */
- private void initMediaProxy() {
- try {
- long idleTime =
- Long.parseLong(JiveGlobals.getProperty("mediaproxy.idleTimeout"));
- mediaProxy.setIdleTime(idleTime);
- }
- catch (NumberFormatException e) {
- // Do nothing let the default values to be used.
- }
- try {
- long lifetime =
- Long.parseLong(JiveGlobals.getProperty("mediaproxy.lifetime"));
- mediaProxy.setLifetime(lifetime);
- }
- catch (NumberFormatException e) {
- // Do nothing let the default values to be used.
- }
- try {
- int minPort = Integer.parseInt(JiveGlobals.getProperty("mediaproxy.portMin"));
- mediaProxy.setMinPort(minPort);
- }
- catch (NumberFormatException e) {
- // Do nothing let the default values to be used.
- }
- try {
- int maxPort = JiveGlobals.getIntProperty("mediaproxy.portMax", mediaProxy.getMaxPort());
- mediaProxy.setMaxPort(maxPort);
- }
- catch (NumberFormatException e) {
- // Do nothing let the default values to be used.
- }
- this.enabled = JiveGlobals.getBooleanProperty("mediaproxy.enabled");
- }
-
- /**
- * Returns the fully-qualifed domain name of this chat service.
- * The domain is composed by the service name and the
- * name of the XMPP server where the service is running.
- *
- * @return the file transfer server domain (service name + host name).
- */
- public String getServiceDomain() {
- return serviceName + "." + XMPPServer.getInstance().getServerInfo().getXMPPDomain();
- }
-
- @Override
- public JID getAddress() {
- return new JID(null, getServiceDomain(), null);
- }
-
- @Override
- public Iterator getItems()
- {
- List items = new ArrayList<>();
- if (!isEnabled())
- {
- return items.iterator();
- }
-
- final DiscoServerItem item = new DiscoServerItem(new JID(
- getServiceDomain()), "Media Proxy Service", null, null, this, this);
- items.add(item);
- return items.iterator();
- }
-
- @Override
- public Iterator getIdentities(String name, String node, JID senderJID) {
- List identities = new ArrayList<>();
- // Answer the identity of the proxy
- Element identity = DocumentHelper.createElement("identity");
- identity.addAttribute("category", "proxy");
- identity.addAttribute("name", "Media Proxy Service");
- identity.addAttribute("type", "rtpbridge");
-
- identities.add(identity);
-
- return identities.iterator();
- }
-
- @Override
- public Iterator getFeatures(String name, String node, JID senderJID) {
- return Arrays.asList(NAMESPACE,
- "http://jabber.org/protocol/disco#info").iterator();
- }
-
- @Override
- public Set getExtendedInfos(String name, String node, JID senderJID) {
- return new HashSet<>();
- }
-
- @Override
- public boolean hasInfo(String name, String node, JID senderJID) {
- return true;
- }
-
- /**
- * Return the list of active Agents
- *
- * @return list of active agents
- */
- public Collection getAgents() {
- return mediaProxy.getSessions();
- }
-
- /**
- * Set the keep alive delay of the mediaproxy agents.
- * When an agent stay more then this delay, the agent is destroyed.
- *
- * @param delay time in millis
- */
- public void setKeepAliveDelay(long delay) {
- mediaProxy.setIdleTime(delay);
- }
-
- /**
- * Returns the maximum amount of time (in milleseconds) that a session can
- * be idle before it's closed.
- *
- * @return the max idle time in millis.
- */
- public long getIdleTime() {
- return mediaProxy.getIdleTime();
- }
-
- /**
- * Set Minimal port value to listen for incoming packets.
- *
- * @param minPort port value to listen for incoming packets
- */
- public void setMinPort(int minPort) {
- mediaProxy.setMinPort(minPort);
- }
-
- /**
- * Set Maximum port value to listen for incoming packets.
- *
- * @param maxPort port value to listen for incoming packets
- */
- public void setMaxPort(int maxPort) {
- mediaProxy.setMaxPort(maxPort);
- }
-
- /**
- * Get Minimal port value to listen from incoming packets.
- *
- * @return minPort
- */
- public int getMinPort() {
- return mediaProxy.getMinPort();
- }
-
- /**
- * Get Maximum port value to listen from incoming packets.
- *
- * @return maxPort
- */
- public int getMaxPort() {
- return mediaProxy.getMaxPort();
- }
-
- /**
- * Get if the service is enabled.
- *
- * @return enabled
- */
- public boolean isEnabled() {
- return enabled;
- }
-
- /**
- * Set the service enable status.
- *
- * @param enabled boolean value setting enabled or disabled
- */
- public void setEnabled(boolean enabled) {
- this.enabled = enabled;
- if (isEnabled()) {
- start();
- } else {
- stop();
- }
- }
-
- /**
- * Stops every running agents
- */
- public void stopAgents() {
- mediaProxy.stopProxy();
- }
-
- /**
- * Get the Life Time of Sessions
- *
- * @return lifetime in seconds
- */
- public long getLifetime() {
- return mediaProxy.getLifetime();
- }
-
- /**
- * Set the Life time of Sessions
- *
- * @param lifetime lifetime in seconds
- */
- public void setLifetime(long lifetime) {
- mediaProxy.setLifetime(lifetime);
- }
-
- /**
- * Get the Port used to the UDP Echo Test
- *
- * @return port number
- */
- public int getEchoPort() {
- return echoPort;
- }
-
- /**
- * Set the Port used to the UDP Echo Test
- *
- * @param echoPort port number
- */
- public void setEchoPort(int echoPort) {
- this.echoPort = echoPort;
- }
-}
diff --git a/xmppserver/src/main/java/org/jivesoftware/openfire/mediaproxy/MediaProxySession.java b/xmppserver/src/main/java/org/jivesoftware/openfire/mediaproxy/MediaProxySession.java
deleted file mode 100644
index 89ac955cdc..0000000000
--- a/xmppserver/src/main/java/org/jivesoftware/openfire/mediaproxy/MediaProxySession.java
+++ /dev/null
@@ -1,527 +0,0 @@
-/*
- * Copyright (C) 2004-2009 Jive Software, 2017-2025 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.
- */
-
-package org.jivesoftware.openfire.mediaproxy;
-
-import java.io.IOException;
-import java.net.DatagramPacket;
-import java.net.DatagramSocket;
-import java.net.InetAddress;
-import java.net.ServerSocket;
-import java.security.SecureRandom;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Timer;
-import java.util.TimerTask;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * A media proxy session enables two clients to exchange UDP traffic. Each client connects to
- * a UDP port and then the proxy is responsible for exchanging traffic. Each session uses
- * a total of four ports: two for traffic exchange, and two control ports.
- *
- * @author Thiago Camargo
- */
-public abstract class MediaProxySession extends Thread implements ProxyCandidate, DatagramListener {
-
- private static final Logger Log = LoggerFactory.getLogger(MediaProxySession.class);
-
- private List sessionListeners = new ArrayList<>();
-
- private String id;
- private String pass;
- private String creator = "";
- private long timestamp = 0;
-
- protected InetAddress localAddress;
- protected InetAddress hostA;
- protected InetAddress hostB;
-
- protected int portA;
- protected int portB;
-
- protected int localPortA;
- protected int localPortB;
-
- protected DatagramSocket socketA;
- protected DatagramSocket socketAControl;
- protected DatagramSocket socketB;
- protected DatagramSocket socketBControl;
-
- protected Channel channelAtoB;
- protected Channel channelAtoBControl;
- protected Channel channelBtoA;
- protected Channel channelBtoAControl;
-
- protected Thread threadAtoB;
- protected Thread threadAtoBControl;
- protected Thread threadBtoA;
- protected Thread threadBtoAControl;
-
- private Timer idleTimer = null;
- private Timer lifeTimer = null;
-
- private int minPort = 10000;
- private int maxPort = 20000;
-
- /**
- * Creates a new static UDP channel between Host A and Host B.
- *
- * @param id of the Session (Could be a Jingle session ID)
- * @param creator the session creator name or description
- * @param localAddress the localhost IP that will listen for UDP packets
- * @param hostA the hostname or IP of the point A of the Channel
- * @param portA the port number point A of the Channel
- * @param hostB the hostname or IP of the point B of the Channel
- * @param portB the port number point B of the Channel
- * @param minPort the minimal port value to be used by the server
- * @param maxPort the maximun port value to be used by the server
- */
- public MediaProxySession(String id, String creator, String localAddress, String hostA, int portA, String hostB,
- int portB, int minPort, int maxPort) {
- this.id = id;
- this.creator = creator;
- this.minPort = minPort;
- this.maxPort = maxPort;
- this.pass = String.valueOf(Math.abs(new SecureRandom().nextLong()));
- try {
- this.hostA = InetAddress.getByName(hostA);
- this.hostB = InetAddress.getByName(hostB);
-
- this.portA = portA;
- this.portB = portB;
-
- this.localAddress = InetAddress.getByName(localAddress);
- this.localPortA = getFreePort();
- this.socketA = new DatagramSocket(localPortA, this.localAddress);
- this.socketAControl = new DatagramSocket(localPortA + 1, this.localAddress);
- this.localPortB = getFreePort();
- this.socketB = new DatagramSocket(localPortB, this.localAddress);
- this.socketBControl = new DatagramSocket(localPortB + 1, this.localAddress);
- if (Log.isDebugEnabled()) {
- Log.debug("MediaProxySession: Session Created at: A " + localPortA + " : B " + localPortB);
- }
- }
- catch (Exception e) {
- Log.error(e.getMessage(), e);
- }
- }
-
- /**
- * Obtain a free port with a nested control port we can use.
- *
- * @return A free port number.
- */
- protected int getFreePort() {
- ServerSocket ss;
- int freePort = 0;
- int controlPort;
-
- for (int i = 0; i < 10; i++) {
- freePort = (int) (minPort + Math.round(Math.random() * (maxPort - minPort)));
- freePort = freePort % 2 == 0 ? freePort : freePort + 1;
- try {
- ss = new ServerSocket(freePort);
- freePort = ss.getLocalPort();
- ss.close();
- ss = new ServerSocket(freePort + 1);
- controlPort = ss.getLocalPort();
- ss.close();
- if (controlPort == (freePort + 1))
- return freePort;
- }
- catch (IOException e) {
- Log.error(e.getMessage(), e);
- }
- }
- try {
- ss = new ServerSocket(0);
- freePort = ss.getLocalPort();
- ss.close();
- }
- catch (IOException e) {
- Log.error(e.getMessage(), e);
- } finally {
- ss = null;
- }
- return freePort;
- }
-
- /**
- * Get the ID of the Session
- *
- * @return the ID of the session
- */
- @Override
- public String getSID() {
- return id;
- }
-
- /**
- * Get the pass of this Session
- * A pass can be used to authorize an Session modification
- */
- @Override
- public String getPass() {
- return pass;
- }
-
- /**
- * Get the agent creator.
- * This field is open to MediaProxy users and just can be set in constructor.
- *
- * @return the session creator name or description
- */
- public String getCreator() {
- return creator;
- }
-
- /**
- * Get last packet arrived timestamp
- *
- * @return TimeStamp in Millis
- */
- public long getTimestamp() {
- return timestamp;
- }
-
- /**
- * Thread override method
- */
- @Override
- public void run() {
- // Create channels for parties
- createChannels();
-
- // Start a thread for each channel
- threadAtoB = new Thread(channelAtoB);
- threadAtoBControl = new Thread(channelAtoBControl);
- threadBtoA = new Thread(channelBtoA);
- threadBtoAControl = new Thread(channelBtoAControl);
-
- threadAtoB.start();
- threadAtoBControl.start();
- threadBtoA.start();
- threadBtoAControl.start();
-
- // Listen to channel events
- addChannelListeners();
- }
-
- /**
- * Creates 4 new channels for the two entities. We will create a channel between A and B and vice versa
- * and also a control channel betwwen A and B and vice versa.
- */
- abstract void createChannels();
-
- /**
- * Adds listener to channel events like receiving data.
- */
- void addChannelListeners() {
- channelAtoB.addListener(this);
- channelAtoBControl.addListener(this);
- channelBtoA.addListener(this);
- channelBtoAControl.addListener(this);
- }
-
- /**
- * Stop the Session
- */
- @Override
- public void stopAgent() {
-
- try {
- if (idleTimer != null) {
- idleTimer.cancel();
- idleTimer.purge();
- idleTimer = null;
- }
- } catch (Exception e) {
- Log.error(e.getMessage(), e);
- }
-
- try {
- if (lifeTimer != null) {
- lifeTimer.cancel();
- lifeTimer.purge();
- lifeTimer = null;
- }
- } catch (Exception e) {
- Log.error(e.getMessage(), e);
- }
-
- channelAtoB.removeListeners();
- channelAtoBControl.removeListeners();
- channelBtoA.removeListeners();
- channelBtoAControl.removeListeners();
-
- try {
- channelAtoB.cancel();
- channelAtoBControl.cancel();
- channelBtoA.cancel();
- channelBtoAControl.cancel();
- } catch (Exception e) {
- Log.error(e.getMessage(), e);
- }
-
- socketA.close();
- socketAControl.close();
- socketB.close();
- socketBControl.close();
-
- dispatchAgentStopped();
-
- Log.debug("MediaProxySession: Session Stopped");
- }
-
- /**
- * Get localhost of the Session
- *
- * @return the localhost of the session
- */
- @Override
- public InetAddress getLocalhost() {
- return localAddress;
- }
-
- /**
- * Get the Host A IP
- *
- * @return the host A ip
- */
- @Override
- public InetAddress getHostA() {
- return hostA;
- }
-
- /**
- * Get the Host B IP
- *
- * @return the host B ip
- */
- @Override
- public InetAddress getHostB() {
- return hostB;
- }
-
- /**
- * Set port A value
- *
- * @param portA the port number for A
- */
- @Override
- public void setPortA(int portA) {
- if (Log.isDebugEnabled()) {
- Log.debug("MediaProxySession: PORT CHANGED(A):" + portA);
- }
- this.portA = portA;
- }
-
- /**
- * Set port B value
- *
- * @param portB the port number for B
- */
- @Override
- public void setPortB(int portB) {
- if (Log.isDebugEnabled()) {
- Log.debug("MediaProxySession: PORT CHANGED(B):" + portB);
- }
- this.portB = portB;
- }
-
- /**
- * Set the Host A IP
- *
- * @param hostA the host for A
- */
- @Override
- public void setHostA(InetAddress hostA) {
- this.hostA = hostA;
- }
-
- /**
- * Set the Host B IP
- *
- * @param hostB the host for B
- */
- @Override
- public void setHostB(InetAddress hostB) {
- this.hostB = hostB;
- }
-
- /**
- * Get the Port A IP
- *
- * @return the port for A
- */
- @Override
- public int getPortA() {
- return portA;
- }
-
- /**
- * Get the Port B IP
- *
- * @return the port for B
- */
- @Override
- public int getPortB() {
- return portB;
- }
-
- /**
- * Get the localport that listen for Host A Packets
- *
- * @return the local port for A
- */
- @Override
- public int getLocalPortA() {
- return localPortA;
- }
-
- /**
- * Get the localport that listen for Host B Packets
- *
- * @return the local port for B
- */
- @Override
- public int getLocalPortB() {
- return localPortB;
- }
-
- @Override
- public void sendFromPortA(String host, int port) {
- try {
- InetAddress address = InetAddress.getByName(host);
- channelAtoB.setHost(address);
- channelAtoB.setPort(port);
- channelAtoBControl.setHost(address);
- channelAtoBControl.setPort(port + 1);
- }
- catch (Exception e) {
- Log.error(e.getMessage(), e);
- }
- }
-
- @Override
- public void sendFromPortB(String host, int port) {
- try {
- InetAddress address = InetAddress.getByName(host);
- channelBtoA.setHost(address);
- channelBtoA.setPort(port);
- channelBtoAControl.setHost(address);
- channelBtoAControl.setPort(port + 1);
- }
- catch (Exception e) {
- Log.error(e.getMessage(), e);
- }
- }
-
- /**
- * Implement DatagramListener to timestamp last packet arrived
- *
- * @param datagramPacket the datagram packet
- */
- @Override
- public boolean datagramReceived(DatagramPacket datagramPacket) {
- timestamp = System.currentTimeMillis();
- return true;
- }
-
- /**
- * Add a keep alive detector.
- * If the packet still more than the keep alive delay without receiving any packets. The Session is
- * stoped and remove from agents List.
- *
- * @param delay delay time in millis to check if the channel is inactive
- */
- void addKeepAlive(long delay) {
- if (idleTimer != null) return;
- idleTimer = new Timer();
- idleTimer.scheduleAtFixedRate(new TimerTask() {
- long lastTimeStamp = getTimestamp();
-
- @Override
- public void run() {
- if (lastTimeStamp == getTimestamp()) {
- stopAgent();
- return;
- }
- lastTimeStamp = getTimestamp();
- }
- }, delay, delay);
- }
-
- /**
- * Add a limited life time to the Session.
- * The Session is stoped and remove from agents List after a certain time.
- * Prevents that network cycles, refreshes a Session forever.
- *
- * @param lifetime time in Seconds to kill the Session
- */
- void addLifeTime(long lifetime) {
- lifetime *= 1000;
- if (lifeTimer != null) return;
- lifeTimer = new Timer();
- lifeTimer.scheduleAtFixedRate(new TimerTask() {
- @Override
- public void run() {
- stopAgent();
- }
- }, lifetime, lifetime);
- }
-
- /**
- * Adds a listener for Session events
- *
- * @param sessionListener the sessionj listener to add
- */
- public void addAgentListener(SessionListener sessionListener) {
- sessionListeners.add(sessionListener);
- }
-
- /**
- * Removes an Session events listener
- *
- * @param sessionListener the session listener to remove
- */
- public void removeAgentListener(SessionListener sessionListener) {
- sessionListeners.remove(sessionListener);
- }
-
- /**
- * Removes every Session events listeners
- */
- public void clearAgentListeners() {
- sessionListeners.clear();
- }
-
- /**
- * Dispatch Stop Event
- */
- public void dispatchAgentStopped() {
- for (SessionListener sessionListener : sessionListeners) {
- try {
- sessionListener.sessionClosed(this);
- } catch (Exception e) {
- Log.error(e.getMessage(), e);
- }
- }
- }
-}
diff --git a/xmppserver/src/main/java/org/jivesoftware/openfire/mediaproxy/ProxyCandidate.java b/xmppserver/src/main/java/org/jivesoftware/openfire/mediaproxy/ProxyCandidate.java
deleted file mode 100644
index 74ff29e62a..0000000000
--- a/xmppserver/src/main/java/org/jivesoftware/openfire/mediaproxy/ProxyCandidate.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Jive Software, 2017-2018 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.
- */
-
-package org.jivesoftware.openfire.mediaproxy;
-
-import java.net.InetAddress;
-
-/**
- * Basic interface to access a Candidate provided by a Session
- *
- * @author Thiago Camargo
- */
-public interface ProxyCandidate {
-
- String getSID();
-
- String getPass();
-
- InetAddress getLocalhost();
-
- InetAddress getHostA();
-
- InetAddress getHostB();
-
- void setHostA( InetAddress hostA );
-
- void setHostB( InetAddress hostB );
-
- void sendFromPortA( String host, int port );
-
- void sendFromPortB( String host, int port );
-
- int getPortA();
-
- int getPortB();
-
- void setPortA( int portA );
-
- void setPortB( int portB );
-
- int getLocalPortA();
-
- int getLocalPortB();
-
- void start();
-
- void stopAgent();
-}
diff --git a/xmppserver/src/main/java/org/jivesoftware/openfire/mediaproxy/RelaySession.java b/xmppserver/src/main/java/org/jivesoftware/openfire/mediaproxy/RelaySession.java
deleted file mode 100644
index 41023ef905..0000000000
--- a/xmppserver/src/main/java/org/jivesoftware/openfire/mediaproxy/RelaySession.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Jive Software, 2017-2018 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.
- */
-
-package org.jivesoftware.openfire.mediaproxy;
-
-/**
- * A Session Class will control "receive and relay" proccess.
- * It creates UDP channels from Host A to Host B and from Host B to Host A using or NOT the specified
- * hosts and ports.
- * The IP and port pairs can change depending of the Senders IP and port.
- * Which means that the IP and port values of the points can dynamic change after the Channel is opened.
- * When the agent receives a packet from Point A, the channel set the point A IP and port according to the
- * received packet sender IP and port.
- * Every packet received from Point B will be relayed to the new Point A IP and port.
- * When the agent receives a packet from Point B, the channel set the point B IP and port according to the
- * received packet sender IP and port.
- * Every packet received from Point A will be relayed to the new Point B IP and port.
- * Create a dynamic channel between two IPs. ( Dynamic Point A - Dynamic Point B )
- * It has 4 Channels. 2 for data and 2 for control.
- *
- * @author Thiago Camargo
- */
-
-public class RelaySession extends MediaProxySession {
-
- /**
- * Creates a new Smart Session to provide connectivity between Host A and Host B.
- *
- * @param id of the Session (Could be a Jingle session ID)
- * @param localhost The localhost IP that will listen for UDP packets
- * @param hostA the hostname or IP of the point A of the Channel
- * @param portA the port number point A of the Channel
- * @param hostB the hostname or IP of the point B of the Channel
- * @param portB the port number point B of the Channel
- * @param creator the created name or description of the Channel
- * @param minPort the minimal port number to be used by the proxy
- * @param maxPort the maximun port number to be used by the proxy
- */
- public RelaySession(String id, String creator, String localhost, String hostA, int portA, String hostB, int portB,
- int minPort, int maxPort) {
- super(id, creator, localhost, hostA, portA, hostB, portB, minPort, maxPort);
- }
-
- /**
- * Creates a new Smart Session to provide connectivity between Host A and Host B.
- *
- * @param id of the Session (Could be a Jingle session ID)
- * @param localhost The localhost IP that will listen for UDP packets
- * @param hostA the hostname or IP of the point A of the Channel
- * @param portA the port number point A of the Channel
- * @param hostB the hostname or IP of the point B of the Channel
- * @param portB the port number point B of the Channel
- * @param creator the created name or description of the Channel
- */
- public RelaySession(String id, String creator, String localhost, String hostA, int portA, String hostB, int portB) {
- super(id, creator, localhost, hostA, portA, hostB, portB, 10000, 20000);
- }
-
- @Override
- void createChannels() {
- channelAtoB = new DynamicAddressChannel(socketA, hostB, portB);
- channelAtoBControl = new DynamicAddressChannel(socketAControl, hostB, portB + 1);
- channelBtoA = new DynamicAddressChannel(socketB, hostA, portA);
- channelBtoAControl = new DynamicAddressChannel(socketBControl, hostA, portA + 1);
- }
-
-
- @Override
- void addChannelListeners() {
- super.addChannelListeners();
- // Add channel as listeners
- channelAtoB.addListener((DynamicAddressChannel) channelBtoA);
- channelAtoBControl.addListener((DynamicAddressChannel) channelBtoAControl);
- channelBtoA.addListener((DynamicAddressChannel) channelAtoB);
- channelBtoAControl.addListener((DynamicAddressChannel) channelAtoBControl);
- }
-}
diff --git a/xmppserver/src/main/java/org/jivesoftware/openfire/mediaproxy/SessionListener.java b/xmppserver/src/main/java/org/jivesoftware/openfire/mediaproxy/SessionListener.java
deleted file mode 100644
index 3db0e902e2..0000000000
--- a/xmppserver/src/main/java/org/jivesoftware/openfire/mediaproxy/SessionListener.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Jive Software, 2017-2018 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.
- */
-
-package org.jivesoftware.openfire.mediaproxy;
-
-/**
- * Listener for media proxy session events.
- *
- * @author Thiago Camargo
- */
-public interface SessionListener {
-
- /**
- * A media proxy session was closed as a result of normal termination or because
- * the max idle time elapsed.
- *
- * @param session the session that closed.
- */
- void sessionClosed( MediaProxySession session );
-
-}
diff --git a/xmppserver/src/main/resources/admin-sidebar.xml b/xmppserver/src/main/resources/admin-sidebar.xml
index 2adcde8da2..a97c5316a1 100644
--- a/xmppserver/src/main/resources/admin-sidebar.xml
+++ b/xmppserver/src/main/resources/admin-sidebar.xml
@@ -293,10 +293,7 @@
diff --git a/xmppserver/src/main/webapp/index.jsp b/xmppserver/src/main/webapp/index.jsp
index 82bb5cff3e..ee2391993f 100644
--- a/xmppserver/src/main/webapp/index.jsp
+++ b/xmppserver/src/main/webapp/index.jsp
@@ -22,7 +22,6 @@
<%@ page import="org.jivesoftware.openfire.XMPPServer" %>
<%@ page import="org.jivesoftware.openfire.filetransfer.proxy.FileTransferProxy" %>
<%@ page import="org.jivesoftware.openfire.keystore.IdentityStore" %>
-<%@ page import="org.jivesoftware.openfire.mediaproxy.MediaProxyService" %>
<%@ page import="org.jivesoftware.openfire.spi.ConnectionListener" %>
<%@ page import="org.jivesoftware.openfire.spi.ConnectionType" %>
<%@ page import="org.jivesoftware.openfire.update.Update" %>
@@ -64,7 +63,6 @@
ConnectionManager connectionManager = XMPPServer.getInstance().getConnectionManager();
FileTransferProxy fileTransferProxy = XMPPServer.getInstance().getFileTransferProxy();
- MediaProxyService mediaProxyService = XMPPServer.getInstance().getMediaProxyService();
boolean rssEnabled = BlogPostServlet.ENABLED.getValue();;
@@ -610,17 +608,6 @@
|
<% } %>
- <%
- if (mediaProxyService.isEnabled()) {
- %>
-
- | <%= interfaceName %> |
- <%= mediaProxyService.getMinPort() %> - <%= mediaProxyService.getMaxPort() %> |
-  |
- |
- |
-
- <% } %>
<%
if (JMXManager.isEnabled()) {
%>
diff --git a/xmppserver/src/main/webapp/media-proxy.jsp b/xmppserver/src/main/webapp/media-proxy.jsp
deleted file mode 100644
index b98fc23d09..0000000000
--- a/xmppserver/src/main/webapp/media-proxy.jsp
+++ /dev/null
@@ -1,323 +0,0 @@
-<%--
- -
- - Copyright (C) 2005-2008 Jive Software, 2017-2022 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.util.JiveGlobals" %>
-<%@ page import="org.jivesoftware.util.ParamUtils" %>
-<%@ page import="org.jivesoftware.util.CookieUtils" %>
-<%@ page import="org.jivesoftware.util.StringUtils" %>
-<%@ page import="org.jivesoftware.openfire.XMPPServer" %>
-<%@ page import="org.jivesoftware.openfire.mediaproxy.MediaProxyService" %>
-<%@ page import="org.jivesoftware.openfire.mediaproxy.MediaProxySession" %>
-<%@ page import="org.jivesoftware.openfire.mediaproxy.RelaySession" %>
-<%@ page import="java.util.Collection" %>
-
-<%@ page contentType="text/html;charset=UTF-8" %>
-<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
-<%@ taglib prefix="admin" uri="admin" %>
-
-<% webManager.init(request, response, session, application, out ); %>
-
-<%
-
- MediaProxyService mediaProxyService = XMPPServer.getInstance().getMediaProxyService();
-
- boolean stop = request.getParameter("stop") != null;
- boolean save = request.getParameter("update") != null;
- boolean success = false;
-
- long keepAliveDelay = mediaProxyService.getIdleTime();
- long lifetime = mediaProxyService.getLifetime();
- int minPort = mediaProxyService.getMinPort();
- int maxPort = mediaProxyService.getMaxPort();
- int echoPort = mediaProxyService.getEchoPort();
- boolean enabled = mediaProxyService.isEnabled();
- Cookie csrfCookie = CookieUtils.getCookie(request, "csrf");
- String csrfParam = ParamUtils.getParameter(request, "csrf");
-
- if (save || stop) {
- if (csrfCookie == null || csrfParam == null || !csrfCookie.getValue().equals(csrfParam)) {
- save = false;
- stop = false;
- }
- }
- csrfParam = StringUtils.randomString(15);
- CookieUtils.setCookie(request, response, "csrf", csrfParam, -1);
- pageContext.setAttribute("csrf", csrfParam);
-
- if (stop) {
- mediaProxyService.stopAgents();
- }
-
- if (save) {
- keepAliveDelay = ParamUtils.getLongParameter(request, "idleTimeout", keepAliveDelay);
- if (keepAliveDelay > 1) {
- mediaProxyService.setKeepAliveDelay(keepAliveDelay * 1000);
- JiveGlobals
- .setProperty("mediaproxy.idleTimeout", String.valueOf(keepAliveDelay * 1000));
- }
-
- lifetime = ParamUtils.getLongParameter(request, "lifetime", lifetime);
- if (lifetime > 0) {
- mediaProxyService.setLifetime(lifetime);
- JiveGlobals
- .setProperty("mediaproxy.lifetime", String.valueOf(lifetime));
- }
-
- minPort = ParamUtils.getIntParameter(request, "minport", minPort);
- maxPort = ParamUtils.getIntParameter(request, "maxport", maxPort);
- echoPort = ParamUtils.getIntParameter(request, "echoport", echoPort);
- enabled = ParamUtils.getBooleanParameter(request, "enabled", enabled);
-
- JiveGlobals.setProperty("mediaproxy.enabled", String.valueOf(enabled));
-
- if (minPort > 0 && maxPort > 0) {
- if (maxPort - minPort > 1000) {
- mediaProxyService.setMinPort(minPort);
- mediaProxyService.setMaxPort(maxPort);
- JiveGlobals.setProperty("mediaproxy.portMin", String.valueOf(minPort));
- JiveGlobals.setProperty("mediaproxy.portMax", String.valueOf(maxPort));
- }
- }
-
- if (echoPort > 0){
- mediaProxyService.setEchoPort(echoPort);
- JiveGlobals.setProperty("mediaproxy.echoPort", String.valueOf(echoPort));
- }
-
- mediaProxyService.setEnabled(enabled);
-
- // Log the event
- webManager.logEvent("edited media proxy settings", "minport = "+minPort+"\nmaxport = "+maxPort+"\nechoport = "+echoPort+"\nenabled = "+enabled+"\nlifetime = "+lifetime+"\nkeepalivedelay = "+keepAliveDelay);
-
- success = true;
- }
-
-%>
-
-
- Media Proxy
-
-
-
-
-
-
-
-
-
-<% if (success) { %>
-
-
-
-
-
-<% } %>
-
-
-
-<% if (mediaProxyService.isEnabled()) { %>
-
-
-
-
-
-
-
-
-
-
-
-
- | |
-
-
- |
-
-
- A
- |
-
-
- B
- |
-
-
- |
-
-
- |
-
-
- |
-
-
-
-
- <% // Print the list of agents
- Collection sessions = mediaProxyService.getAgents();
- if (sessions.isEmpty()) {
- %>
-
- |
-
- |
-
-
- <%
- }
- int i = 0;
- for (MediaProxySession proxySession : sessions) {
- i++;
- %>
-
- |
- <%= i %>
- |
-
- <%= StringUtils.escapeHTMLTags(proxySession.getCreator())%>
- |
-
- <%=proxySession.getHostA()%>:<%=proxySession.getLocalPortA()%>
- |
-
- <%=proxySession.getHostB()%>:<%=proxySession.getLocalPortB()%>
- |
-
- <%=proxySession.getLocalhost()%>
- |
-
- <%=(System.currentTimeMillis() - proxySession.getTimestamp()) / 1000%>
- |
-
- <% if (proxySession instanceof RelaySession) { %>
- Smart Session
- <% } else { %>
- Fixed Session
- <% } %>
- |
-
-
- <%
- }
- %>
-
-
-
-
-
-<% } // end enabled check %>
-
-
-