1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-23 20:42:06 +01:00

FIX F%?§@N SOCKS5

This commit is contained in:
vanitasvitae 2017-08-07 23:55:32 +02:00
parent 034b7f3844
commit 792a9a348b
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
6 changed files with 14 additions and 8 deletions

View file

@ -101,7 +101,7 @@ public final class JetManager extends Manager implements JingleDescriptionManage
JetSecurity security = new JetSecurity(method, recipient, content.getName(), Aes256GcmNoPadding.NAMESPACE); JetSecurity security = new JetSecurity(method, recipient, content.getName(), Aes256GcmNoPadding.NAMESPACE);
content.setSecurity(security); content.setSecurity(security);
session.initiate(connection()); session.sendInitiate(connection());
return offer; return offer;
} }

View file

@ -46,6 +46,7 @@ import org.jivesoftware.smackx.jingle.JingleManager;
import org.jivesoftware.smackx.jingle.JingleTransportManager; import org.jivesoftware.smackx.jingle.JingleTransportManager;
import org.jivesoftware.smackx.jingle.component.JingleContent; import org.jivesoftware.smackx.jingle.component.JingleContent;
import org.jivesoftware.smackx.jingle.component.JingleSession; import org.jivesoftware.smackx.jingle.component.JingleSession;
import org.jivesoftware.smackx.jingle.component.JingleTransport;
import org.jivesoftware.smackx.jingle.element.JingleContentElement; import org.jivesoftware.smackx.jingle.element.JingleContentElement;
import org.jivesoftware.smackx.jingle.util.Role; import org.jivesoftware.smackx.jingle.util.Role;
@ -109,9 +110,10 @@ public final class JingleFileTransferManager extends Manager implements JingleDe
content.setDescription(offer); content.setDescription(offer);
JingleTransportManager transportManager = jingleManager.getBestAvailableTransportManager(to); JingleTransportManager transportManager = jingleManager.getBestAvailableTransportManager(to);
content.setTransport(transportManager.createTransportForInitiator(content)); JingleTransport<?> transport = transportManager.createTransportForInitiator(content);
content.setTransport(transport);
session.initiate(connection()); session.sendInitiate(connection());
return offer; return offer;
} }

View file

@ -125,7 +125,7 @@ public class JingleIncomingFileOffer extends AbstractJingleFileOffer<RemoteFile>
this.target = target; this.target = target;
JingleSession session = getParent().getParent(); JingleSession session = getParent().getParent();
if (session.getSessionState() == JingleSession.SessionState.pending) { if (session.getSessionState() == JingleSession.SessionState.pending) {
session.accept(connection); session.sendAccept(connection);
} }
return null; return null;

View file

@ -92,7 +92,7 @@ public class JingleSession {
return session; return session;
} }
public void initiate(XMPPConnection connection) throws SmackException.NotConnectedException, InterruptedException, XMPPException.XMPPErrorException, SmackException.NoResponseException { public void sendInitiate(XMPPConnection connection) throws SmackException.NotConnectedException, InterruptedException, XMPPException.XMPPErrorException, SmackException.NoResponseException {
if (this.sessionState != SessionState.fresh) { if (this.sessionState != SessionState.fresh) {
throw new IllegalStateException("Session is not in fresh state."); throw new IllegalStateException("Session is not in fresh state.");
} }
@ -101,7 +101,7 @@ public class JingleSession {
this.sessionState = SessionState.pending; this.sessionState = SessionState.pending;
} }
public void accept(XMPPConnection connection) throws SmackException.NotConnectedException, InterruptedException, XMPPException.XMPPErrorException, SmackException.NoResponseException { public void sendAccept(XMPPConnection connection) throws SmackException.NotConnectedException, InterruptedException, XMPPException.XMPPErrorException, SmackException.NoResponseException {
LOGGER.log(Level.INFO, "Accepted session."); LOGGER.log(Level.INFO, "Accepted session.");
if (this.sessionState != SessionState.pending) { if (this.sessionState != SessionState.pending) {
throw new IllegalStateException("Session is not in pending state."); throw new IllegalStateException("Session is not in pending state.");
@ -379,6 +379,9 @@ public class JingleSession {
} }
public void addContent(JingleContent content) { public void addContent(JingleContent content) {
if (contents.get(content.getName()) != null) {
throw new IllegalArgumentException("Session already contains a content with the name " + content.getName());
}
contents.put(content.getName(), content); contents.put(content.getName(), content);
content.setParent(this); content.setParent(this);
} }

View file

@ -202,7 +202,7 @@ public class JingleS5BTransport extends JingleTransport<JingleS5BTransportElemen
public void prepare(XMPPConnection connection) { public void prepare(XMPPConnection connection) {
JingleSession session = getParent().getParent(); JingleSession session = getParent().getParent();
if (getOurDstAddr() == null) { if (getOurDstAddr() == null) {
ourDstAddr = Socks5Utils.createDigest(session.getSessionId(), session.getOurJid(), session.getPeer()); ourDstAddr = Socks5Utils.createDigest(getSid(), session.getOurJid(), session.getPeer());
Socks5Proxy.getSocks5Proxy().addTransfer(ourDstAddr); Socks5Proxy.getSocks5Proxy().addTransfer(ourDstAddr);
} }

View file

@ -99,8 +99,9 @@ public final class JingleS5BTransportManager extends Manager implements JingleTr
@Override @Override
public JingleTransport<?> createTransportForInitiator(JingleContent content) { public JingleTransport<?> createTransportForInitiator(JingleContent content) {
JingleSession session = content.getParent(); JingleSession session = content.getParent();
String sid = StringUtils.randomString(24);
List<JingleTransportCandidate<?>> candidates = collectCandidates(); List<JingleTransportCandidate<?>> candidates = collectCandidates();
return new JingleS5BTransport(session.getInitiator(), session.getResponder(), StringUtils.randomString(24), Bytestream.Mode.tcp, candidates); return new JingleS5BTransport(session.getInitiator(), session.getResponder(), sid, Bytestream.Mode.tcp, candidates);
} }
@Override @Override