From f8811b82ed6aa4d9f96fd3f93fcf126b13b38a72 Mon Sep 17 00:00:00 2001 From: Ingo Bauersachs Date: Sat, 7 Jan 2017 13:26:23 +0100 Subject: Ignore any routes in the SIP header when an outbound proxy is used If this isn't done, the next Hop will be DNS resolved to - a foreign address - another address than to which the account is currently connected - not resolved at all (e.g. an internal name behind the proxy) --- .../impl/protocol/sip/ProxyRouter.java | 26 ++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/net/java/sip/communicator/impl/protocol/sip/ProxyRouter.java b/src/net/java/sip/communicator/impl/protocol/sip/ProxyRouter.java index 5d60612..b6bf997 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/ProxyRouter.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/ProxyRouter.java @@ -19,6 +19,7 @@ package net.java.sip.communicator.impl.protocol.sip; import gov.nist.javax.sip.stack.*; +import java.net.*; import java.util.*; import javax.sip.*; @@ -26,6 +27,7 @@ import javax.sip.address.*; import javax.sip.header.*; import javax.sip.message.*; +import net.java.sip.communicator.impl.protocol.sip.net.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.util.*; @@ -137,7 +139,9 @@ public class ProxyRouter ProtocolProviderServiceSipImpl sipProvider = ((ProtocolProviderServiceSipImpl) service); - String proxy = sipProvider.getConnection().getOutboundProxyString(); + final ProxyConnection connection = sipProvider.getConnection(); + final String proxy = connection.getOutboundProxyString(); + logger.trace("Router for proxy: " + proxy); boolean forceLooseRouting = sipProvider.getAccountID() @@ -146,13 +150,30 @@ public class ProxyRouter // P2P case if (proxy == null || forceLooseRouting ) + { + logger.info("Returning default SIP router, P2P/loose routing"); return this.getDefaultRouter(); + } // outbound proxy case Router router = routerCache.get(proxy); if (router == null) { - router = new DefaultRouter(stack, proxy); + router = new DefaultRouter(stack, proxy) + { + @Override + public Hop getNextHop(Request request) throws SipException + { + logger.info("Outbound proxy mode, using proxy " + + proxy + " as hop instead of an address resolved" + + " by the SIP router"); + InetSocketAddress sa = connection.getAddress(); + return new HopImpl( + sa.getAddress().getHostAddress(), + sa.getPort(), + connection.getTransport()); + } + }; routerCache.put(proxy, router); } return router; @@ -164,6 +185,7 @@ public class ProxyRouter logger.error("unable to identify the service which created this " + "out-of-dialog request"); + logger.info("Returning default router"); return this.getDefaultRouter(); } -- cgit v1.1