Corrects logged addresses for relayed packets.
This commit is contained in:
parent
f36c7609a8
commit
632d53ac67
@ -11,6 +11,8 @@ import java.io.*;
|
|||||||
import java.net.*;
|
import java.net.*;
|
||||||
import java.nio.channels.*;
|
import java.nio.channels.*;
|
||||||
|
|
||||||
|
import org.ice4j.stack.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements a <tt>DatagramSocket</tt> which delegates its calls to a specific
|
* Implements a <tt>DatagramSocket</tt> which delegates its calls to a specific
|
||||||
* <tt>DatagramSocket</tt>.
|
* <tt>DatagramSocket</tt>.
|
||||||
@ -558,10 +560,28 @@ public class DelegatingDatagramSocket
|
|||||||
public void send(DatagramPacket p)
|
public void send(DatagramPacket p)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
|
// Sends the packet to the final DatagramSocket
|
||||||
if (delegate == null)
|
if (delegate == null)
|
||||||
|
{
|
||||||
super.send(p);
|
super.send(p);
|
||||||
|
|
||||||
|
// no exception packet is successfully sent, log it
|
||||||
|
if(StunStack.isPacketLoggerEnabled())
|
||||||
|
{
|
||||||
|
StunStack.getPacketLogger().logPacket(
|
||||||
|
super.getLocalAddress().getAddress(),
|
||||||
|
super.getLocalPort(),
|
||||||
|
p.getAddress().getAddress(),
|
||||||
|
p.getPort(),
|
||||||
|
p.getData(),
|
||||||
|
true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Else, the delegate socket will encapsulate the packet.
|
||||||
else
|
else
|
||||||
|
{
|
||||||
delegate.send(p);
|
delegate.send(p);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -10,6 +10,8 @@ import java.io.*;
|
|||||||
import java.nio.channels.*;
|
import java.nio.channels.*;
|
||||||
import java.net.*;
|
import java.net.*;
|
||||||
|
|
||||||
|
import org.ice4j.stack.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements a <tt>Socket</tt> which delegates its calls to a specific
|
* Implements a <tt>Socket</tt> which delegates its calls to a specific
|
||||||
* <tt>Socket</tt>.
|
* <tt>Socket</tt>.
|
||||||
@ -745,6 +747,7 @@ public class DelegatingSocket
|
|||||||
*/
|
*/
|
||||||
public void send(DatagramPacket p) throws IOException
|
public void send(DatagramPacket p) throws IOException
|
||||||
{
|
{
|
||||||
|
// The delegate socket will encapsulate the packet.
|
||||||
if (delegate != null && delegate instanceof DelegatingSocket)
|
if (delegate != null && delegate instanceof DelegatingSocket)
|
||||||
{
|
{
|
||||||
((DelegatingSocket) delegate).send(p);
|
((DelegatingSocket) delegate).send(p);
|
||||||
@ -756,7 +759,22 @@ public class DelegatingSocket
|
|||||||
outputStream = getOutputStream();
|
outputStream = getOutputStream();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Else, sends the packet to the final socket (outputStream).
|
||||||
outputStream.write(p.getData(), p.getOffset(), p.getLength());
|
outputStream.write(p.getData(), p.getOffset(), p.getLength());
|
||||||
|
|
||||||
|
// no exception packet is successfully sent, log it
|
||||||
|
if(StunStack.isPacketLoggerEnabled())
|
||||||
|
{
|
||||||
|
InetSocketAddress localAddress
|
||||||
|
= (InetSocketAddress) super.getLocalSocketAddress();
|
||||||
|
StunStack.getPacketLogger().logPacket(
|
||||||
|
localAddress.getAddress().getAddress(),
|
||||||
|
localAddress.getPort(),
|
||||||
|
p.getAddress().getAddress(),
|
||||||
|
p.getPort(),
|
||||||
|
p.getData(),
|
||||||
|
true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -265,18 +265,6 @@ class Connector
|
|||||||
message, 0, message.length, address);
|
message, 0, message.length, address);
|
||||||
|
|
||||||
sock.send(datagramPacket);
|
sock.send(datagramPacket);
|
||||||
|
|
||||||
// no exception packet is successfully sent, log it
|
|
||||||
if(StunStack.isPacketLoggerEnabled())
|
|
||||||
{
|
|
||||||
StunStack.getPacketLogger().logPacket(
|
|
||||||
sock.getLocalAddress().getAddress(),
|
|
||||||
sock.getLocalPort(),
|
|
||||||
address.getAddressBytes(),
|
|
||||||
address.getPort(),
|
|
||||||
message,
|
|
||||||
true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1113,7 +1113,7 @@ public class StunStack
|
|||||||
* Returns the currently set packet logger.
|
* Returns the currently set packet logger.
|
||||||
* @return the currently available packet logger.
|
* @return the currently available packet logger.
|
||||||
*/
|
*/
|
||||||
static PacketLogger getPacketLogger()
|
public static PacketLogger getPacketLogger()
|
||||||
{
|
{
|
||||||
return packetLogger;
|
return packetLogger;
|
||||||
}
|
}
|
||||||
@ -1132,7 +1132,7 @@ public class StunStack
|
|||||||
* @return <tt>true</tt> if we have a packet logger instance and
|
* @return <tt>true</tt> if we have a packet logger instance and
|
||||||
* it is enabled.
|
* it is enabled.
|
||||||
*/
|
*/
|
||||||
static boolean isPacketLoggerEnabled()
|
public static boolean isPacketLoggerEnabled()
|
||||||
{
|
{
|
||||||
return packetLogger != null && packetLogger.isEnabled();
|
return packetLogger != null && packetLogger.isEnabled();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user