mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-12-12 05:51:08 +01:00
Merge branch '4.2' into master-paul-merged
This commit is contained in:
commit
431e5b3c67
434 changed files with 1770 additions and 1517 deletions
|
|
@ -45,6 +45,6 @@ public interface BytestreamListener {
|
|||
*
|
||||
* @param request the incoming bytestream request
|
||||
*/
|
||||
public void incomingBytestreamRequest(BytestreamRequest request);
|
||||
void incomingBytestreamRequest(BytestreamRequest request);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,14 +41,14 @@ public interface BytestreamRequest {
|
|||
*
|
||||
* @return the sender of the bytestream open request
|
||||
*/
|
||||
public Jid getFrom();
|
||||
Jid getFrom();
|
||||
|
||||
/**
|
||||
* Returns the session ID of the bytestream open request.
|
||||
*
|
||||
* @return the session ID of the bytestream open request
|
||||
*/
|
||||
public String getSessionID();
|
||||
String getSessionID();
|
||||
|
||||
/**
|
||||
* Accepts the bytestream open request and returns the session to send/receive data.
|
||||
|
|
@ -60,13 +60,13 @@ public interface BytestreamRequest {
|
|||
* @throws NoResponseException
|
||||
* @throws SmackException
|
||||
*/
|
||||
public BytestreamSession accept() throws InterruptedException, NoResponseException, XMPPErrorException, SmackException;
|
||||
BytestreamSession accept() throws InterruptedException, XMPPErrorException, SmackException;
|
||||
|
||||
/**
|
||||
* Rejects the bytestream request by sending a reject error to the initiator.
|
||||
* @throws NotConnectedException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
public void reject() throws NotConnectedException, InterruptedException;
|
||||
void reject() throws NotConnectedException, InterruptedException;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ public interface BytestreamSession {
|
|||
* @return the InputStream associated with this session to send data
|
||||
* @throws IOException if an error occurs while retrieving the input stream
|
||||
*/
|
||||
public InputStream getInputStream() throws IOException;
|
||||
InputStream getInputStream() throws IOException;
|
||||
|
||||
/**
|
||||
* Returns the OutputStream associated with this session to receive data.
|
||||
|
|
@ -47,7 +47,7 @@ public interface BytestreamSession {
|
|||
* @return the OutputStream associated with this session to receive data
|
||||
* @throws IOException if an error occurs while retrieving the output stream
|
||||
*/
|
||||
public OutputStream getOutputStream() throws IOException;
|
||||
OutputStream getOutputStream() throws IOException;
|
||||
|
||||
/**
|
||||
* Closes the bytestream session.
|
||||
|
|
@ -57,7 +57,7 @@ public interface BytestreamSession {
|
|||
*
|
||||
* @throws IOException if an error occurs while closing the session
|
||||
*/
|
||||
public void close() throws IOException;
|
||||
void close() throws IOException;
|
||||
|
||||
/**
|
||||
* Returns the timeout for read operations of the input stream associated with this session. 0
|
||||
|
|
@ -66,7 +66,7 @@ public interface BytestreamSession {
|
|||
* @return the timeout for read operations
|
||||
* @throws IOException if there is an error in the underlying protocol
|
||||
*/
|
||||
public int getReadTimeout() throws IOException;
|
||||
int getReadTimeout() throws IOException;
|
||||
|
||||
/**
|
||||
* Sets the specified timeout, in milliseconds. With this option set to a non-zero timeout, a
|
||||
|
|
@ -79,6 +79,6 @@ public interface BytestreamSession {
|
|||
* @param timeout the specified timeout, in milliseconds
|
||||
* @throws IOException if there is an error in the underlying protocol
|
||||
*/
|
||||
public void setReadTimeout(int timeout) throws IOException;
|
||||
void setReadTimeout(int timeout) throws IOException;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@ public final class InBandBytestreamManager extends Manager implements Bytestream
|
|||
* list containing session IDs of In-Band Bytestream open packets that should be ignored by the
|
||||
* InitiationListener
|
||||
*/
|
||||
private List<String> ignoredBytestreamRequests = Collections.synchronizedList(new LinkedList<String>());
|
||||
private final List<String> ignoredBytestreamRequests = Collections.synchronizedList(new LinkedList<String>());
|
||||
|
||||
/**
|
||||
* Returns the InBandBytestreamManager to handle In-Band Bytestreams for a given
|
||||
|
|
|
|||
|
|
@ -532,7 +532,7 @@ public class InBandBytestreamSession implements BytestreamSession {
|
|||
@Override
|
||||
public void processStanza(Stanza packet) {
|
||||
// get data packet extension
|
||||
DataPacketExtension data = (DataPacketExtension) packet.getExtension(
|
||||
DataPacketExtension data = packet.getExtension(
|
||||
DataPacketExtension.ELEMENT,
|
||||
DataPacketExtension.NAMESPACE);
|
||||
|
||||
|
|
|
|||
|
|
@ -40,8 +40,7 @@ public class DataPacketProvider {
|
|||
public Data parse(XmlPullParser parser, int initialDepth)
|
||||
throws Exception {
|
||||
DataPacketExtension data = packetExtensionProvider.parse(parser);
|
||||
Data iq = new Data(data);
|
||||
return iq;
|
||||
return new Data(data);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ public class OpenIQProvider extends IQProvider<Open> {
|
|||
int blockSize = Integer.parseInt(parser.getAttributeValue("", "block-size"));
|
||||
|
||||
String stanzaValue = parser.getAttributeValue("", "stanza");
|
||||
StanzaType stanza = null;
|
||||
StanzaType stanza;
|
||||
if (stanzaValue == null) {
|
||||
stanza = StanzaType.IQ;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ public final class Socks5BytestreamManager extends Manager implements Bytestream
|
|||
* list containing session IDs of SOCKS5 Bytestream initialization packets that should be
|
||||
* ignored by the InitiationListener
|
||||
*/
|
||||
private List<String> ignoredBytestreamRequests = Collections.synchronizedList(new LinkedList<String>());
|
||||
private final List<String> ignoredBytestreamRequests = Collections.synchronizedList(new LinkedList<String>());
|
||||
|
||||
/**
|
||||
* Returns the Socks5BytestreamManager to handle SOCKS5 Bytestreams for a given
|
||||
|
|
@ -409,13 +409,12 @@ public final class Socks5BytestreamManager extends Manager implements Bytestream
|
|||
* @return the Socket to send/receive data to/from the user
|
||||
* @throws IOException if the bytestream could not be established
|
||||
* @throws InterruptedException if the current thread was interrupted while waiting
|
||||
* @throws NoResponseException
|
||||
* @throws SmackException if the target does not support SOCKS5.
|
||||
* @throws XMPPException
|
||||
*/
|
||||
@Override
|
||||
public Socks5BytestreamSession establishSession(Jid targetJID, String sessionID)
|
||||
throws IOException, InterruptedException, NoResponseException, SmackException, XMPPException {
|
||||
throws IOException, InterruptedException, SmackException, XMPPException {
|
||||
XMPPConnection connection = connection();
|
||||
XMPPErrorException discoveryException = null;
|
||||
// check if target supports SOCKS5 Bytestream
|
||||
|
|
@ -587,7 +586,7 @@ public final class Socks5BytestreamManager extends Manager implements Bytestream
|
|||
*/
|
||||
private List<StreamHost> determineStreamHostInfos(List<Jid> proxies) {
|
||||
XMPPConnection connection = connection();
|
||||
List<StreamHost> streamHosts = new ArrayList<StreamHost>();
|
||||
List<StreamHost> streamHosts = new ArrayList<>();
|
||||
|
||||
// add local proxy on first position if exists
|
||||
List<StreamHost> localProxies = getLocalStreamHost();
|
||||
|
|
@ -599,7 +598,7 @@ public final class Socks5BytestreamManager extends Manager implements Bytestream
|
|||
for (Jid proxy : proxies) {
|
||||
Bytestream streamHostRequest = createStreamHostRequest(proxy);
|
||||
try {
|
||||
Bytestream response = (Bytestream) connection.createStanzaCollectorAndSend(
|
||||
Bytestream response = connection.createStanzaCollectorAndSend(
|
||||
streamHostRequest).nextResultOrThrow();
|
||||
streamHosts.addAll(response.getStreamHosts());
|
||||
}
|
||||
|
|
@ -648,7 +647,7 @@ public final class Socks5BytestreamManager extends Manager implements Bytestream
|
|||
}
|
||||
final int port = socks5Server.getPort();
|
||||
|
||||
List<StreamHost> streamHosts = new ArrayList<StreamHost>();
|
||||
List<StreamHost> streamHosts = new ArrayList<>();
|
||||
outerloop: for (String address : addresses) {
|
||||
// Prevent loopback addresses from appearing as streamhost
|
||||
final String[] loopbackAddresses = { "127.0.0.1", "0:0:0:0:0:0:0:1", "::1" };
|
||||
|
|
|
|||
|
|
@ -34,9 +34,7 @@ import java.util.logging.Logger;
|
|||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
|
||||
import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream.StreamHost;
|
||||
|
||||
/**
|
||||
|
|
@ -74,16 +72,15 @@ public class Socks5Client {
|
|||
* @param timeout timeout to connect to SOCKS5 proxy in milliseconds
|
||||
* @return socket the initialized socket
|
||||
* @throws IOException if initializing the socket failed due to a network error
|
||||
* @throws XMPPErrorException if establishing connection to SOCKS5 proxy failed
|
||||
* @throws TimeoutException if connecting to SOCKS5 proxy timed out
|
||||
* @throws InterruptedException if the current thread was interrupted while waiting
|
||||
* @throws SmackException if the connection to the SOC
|
||||
* @throws SmackException if the connection to the SOCKS5 proxy failed
|
||||
* @throws XMPPException
|
||||
*/
|
||||
public Socket getSocket(int timeout) throws IOException, XMPPErrorException, InterruptedException,
|
||||
public Socket getSocket(int timeout) throws IOException, InterruptedException,
|
||||
TimeoutException, SmackException, XMPPException {
|
||||
// wrap connecting in future for timeout
|
||||
FutureTask<Socket> futureTask = new FutureTask<Socket>(new Callable<Socket>() {
|
||||
FutureTask<Socket> futureTask = new FutureTask<>(new Callable<Socket>() {
|
||||
|
||||
@Override
|
||||
public Socket call() throws IOException, SmackException {
|
||||
|
|
@ -173,7 +170,7 @@ public class Socks5Client {
|
|||
|
||||
// check if server responded with correct version and no-authentication method
|
||||
if (response[0] != (byte) 0x05 || response[1] != (byte) 0x00) {
|
||||
throw new SmackException("Remote SOCKS5 server responsed with unexpected version: " + response[0] + ' ' + response[1] + ". Should be 0x05 0x00.");
|
||||
throw new SmackException("Remote SOCKS5 server responded with unexpected version: " + response[0] + ' ' + response[1] + ". Should be 0x05 0x00.");
|
||||
}
|
||||
|
||||
// request SOCKS5 connection with given address/digest
|
||||
|
|
@ -188,7 +185,7 @@ public class Socks5Client {
|
|||
connectionRequest[1] = (byte) 0x00; // set expected return status to 0
|
||||
if (!Arrays.equals(connectionRequest, connectionResponse)) {
|
||||
throw new SmackException(
|
||||
"Connection request does not equal connection reponse. Response: "
|
||||
"Connection request does not equal connection response. Response: "
|
||||
+ Arrays.toString(connectionResponse) + ". Request: "
|
||||
+ Arrays.toString(connectionRequest));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ public class Socks5ClientForInitiator extends Socks5Client {
|
|||
@Override
|
||||
public Socket getSocket(int timeout) throws IOException, InterruptedException,
|
||||
TimeoutException, XMPPException, SmackException {
|
||||
Socket socket = null;
|
||||
Socket socket;
|
||||
|
||||
// check if stream host is the local SOCKS5 proxy
|
||||
if (this.streamHost.getJID().equals(this.connection.get().getUser())) {
|
||||
|
|
|
|||
|
|
@ -93,12 +93,12 @@ public final class Socks5Proxy {
|
|||
private ServerSocket serverSocket;
|
||||
|
||||
/* assigns a connection to a digest */
|
||||
private final Map<String, Socket> connectionMap = new ConcurrentHashMap<String, Socket>();
|
||||
private final Map<String, Socket> connectionMap = new ConcurrentHashMap<>();
|
||||
|
||||
/* list of digests connections should be stored */
|
||||
private final List<String> allowedConnections = Collections.synchronizedList(new LinkedList<String>());
|
||||
|
||||
private final Set<String> localAddresses = new LinkedHashSet<String>(4);
|
||||
private final Set<String> localAddresses = new LinkedHashSet<>(4);
|
||||
|
||||
/**
|
||||
* Private constructor.
|
||||
|
|
@ -112,7 +112,7 @@ public final class Socks5Proxy {
|
|||
} catch (SocketException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
Set<String> localHostAddresses = new HashSet<String>();
|
||||
Set<String> localHostAddresses = new HashSet<>();
|
||||
for (NetworkInterface networkInterface : Collections.list(networkInterfaces)) {
|
||||
// We can't use NetworkInterface.getInterfaceAddresses here, which
|
||||
// would return a List instead the deprecated Enumeration, because
|
||||
|
|
@ -293,7 +293,7 @@ public final class Socks5Proxy {
|
|||
*/
|
||||
public List<String> getLocalAddresses() {
|
||||
synchronized (localAddresses) {
|
||||
return new LinkedList<String>(localAddresses);
|
||||
return new LinkedList<>(localAddresses);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ public class Bytestream extends IQ {
|
|||
|
||||
private Mode mode = Mode.tcp;
|
||||
|
||||
private final List<StreamHost> streamHosts = new ArrayList<StreamHost>();
|
||||
private final List<StreamHost> streamHosts = new ArrayList<>();
|
||||
|
||||
private StreamHostUsed usedHost;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue