Adds support for use of IPv6 STUN servers
This commit is contained in:
parent
0b0e5da5b5
commit
514708bec7
@ -9,6 +9,7 @@ package org.ice4j.attribute;
|
|||||||
import java.net.*;
|
import java.net.*;
|
||||||
|
|
||||||
import org.ice4j.*;
|
import org.ice4j.*;
|
||||||
|
import org.ice4j.message.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The XOR-MAPPED-ADDRESS attribute is only present in Binding
|
* The XOR-MAPPED-ADDRESS attribute is only present in Binding
|
||||||
@ -51,8 +52,14 @@ import org.ice4j.*;
|
|||||||
public class XorMappedAddressAttribute
|
public class XorMappedAddressAttribute
|
||||||
extends AddressAttribute
|
extends AddressAttribute
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* The name of this attribute
|
||||||
|
*/
|
||||||
public static final String NAME = "XOR-MAPPED-ADDRESS";
|
public static final String NAME = "XOR-MAPPED-ADDRESS";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an instance of this attribute
|
||||||
|
*/
|
||||||
XorMappedAddressAttribute()
|
XorMappedAddressAttribute()
|
||||||
{
|
{
|
||||||
super(XOR_MAPPED_ADDRESS);
|
super(XOR_MAPPED_ADDRESS);
|
||||||
@ -106,15 +113,21 @@ public class XorMappedAddressAttribute
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the result of applying XOR on this attribute's address, using the
|
* Returns the result of applying XOR on this attribute's address, using the
|
||||||
* specified operand. The method may be used for both
|
* specified transaction ID when converting IPv6 addresses. The method may
|
||||||
* encoding and decoding <tt>XorMappedAddresses</tt>.
|
* be used for both encoding and decoding <tt>XorMappedAddresses</tt>.
|
||||||
*
|
*
|
||||||
* @param operand the transaction id to use for the XOR
|
* @param transactionID the transaction ID to use in case this attribute is
|
||||||
|
* encapsulating an IPv6 address.
|
||||||
*
|
*
|
||||||
* @return the XOR-ed address.
|
* @return the XOR-ed address.
|
||||||
*/
|
*/
|
||||||
public TransportAddress applyXor(byte[] operand)
|
public TransportAddress getAddress(byte[] transactionID)
|
||||||
{
|
{
|
||||||
return applyXor(getAddress(), operand);
|
byte[] xorMask = new byte[16];
|
||||||
|
|
||||||
|
System.arraycopy(Message.MAGIC_COOKIE, 0, xorMask, 0, 4);
|
||||||
|
System.arraycopy(transactionID, 0, xorMask, 4, 12);
|
||||||
|
|
||||||
|
return applyXor(getAddress(), xorMask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -255,7 +255,7 @@ public class StunCandidateHarvester
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
TransportAddress addr = ((XorMappedAddressAttribute)attribute)
|
TransportAddress addr = ((XorMappedAddressAttribute)attribute)
|
||||||
.applyXor(Message.MAGIC_COOKIE);
|
.getAddress(response.getTransactionID());
|
||||||
|
|
||||||
ServerReflexiveCandidate srvrRflxCand
|
ServerReflexiveCandidate srvrRflxCand
|
||||||
= new ServerReflexiveCandidate(addr, base, stunServer);
|
= new ServerReflexiveCandidate(addr, base, stunServer);
|
||||||
|
|||||||
@ -149,7 +149,7 @@ public class SimpleAddressDetector
|
|||||||
System.arraycopy(Message.MAGIC_COOKIE, 0, xoring, 0, 4);
|
System.arraycopy(Message.MAGIC_COOKIE, 0, xoring, 0, 4);
|
||||||
System.arraycopy(res.getTransactionID(), 0, xoring, 4, 12);
|
System.arraycopy(res.getTransactionID(), 0, xoring, 4, 12);
|
||||||
|
|
||||||
return xorAtt.applyXor(xoring);
|
return xorAtt.getAddress(xoring);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user