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

JingleIBBAdapter test + getSid -> getStreamId (S5B)

This commit is contained in:
vanitasvitae 2017-08-09 19:54:09 +02:00
parent 8263a759b3
commit 9fe247b1dc
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
7 changed files with 19 additions and 15 deletions

View file

@ -102,7 +102,7 @@ public class JingleS5BTransport extends JingleTransport<JingleS5BTransportElemen
* @param other transport of the other party. * @param other transport of the other party.
*/ */
JingleS5BTransport(FullJid initiator, FullJid responder, List<JingleTransportCandidate<?>> ourCandidates, JingleS5BTransport other) { JingleS5BTransport(FullJid initiator, FullJid responder, List<JingleTransportCandidate<?>> ourCandidates, JingleS5BTransport other) {
this.sid = other.getSid(); this.sid = other.getStreamId();
this.mode = other.mode; this.mode = other.mode;
this.ourDstAddr = Socks5Utils.createDigest(sid, responder, initiator); this.ourDstAddr = Socks5Utils.createDigest(sid, responder, initiator);
Socks5Proxy.getSocks5Proxy().addTransfer(ourDstAddr); Socks5Proxy.getSocks5Proxy().addTransfer(ourDstAddr);
@ -177,7 +177,7 @@ public class JingleS5BTransport extends JingleTransport<JingleS5BTransportElemen
return builder.build(); return builder.build();
} }
public String getSid() { public String getStreamId() {
return sid; return sid;
} }
@ -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(getSid(), session.getOurJid(), session.getPeer()); ourDstAddr = Socks5Utils.createDigest(getStreamId(), session.getOurJid(), session.getPeer());
Socks5Proxy.getSocks5Proxy().addTransfer(ourDstAddr); Socks5Proxy.getSocks5Proxy().addTransfer(ourDstAddr);
} }
@ -378,7 +378,7 @@ public class JingleS5BTransport extends JingleTransport<JingleS5BTransportElemen
private void activateProxy(JingleS5BTransportCandidate candidate) throws SmackException.NotConnectedException, InterruptedException, XMPPException.XMPPErrorException, SmackException.NoResponseException { private void activateProxy(JingleS5BTransportCandidate candidate) throws SmackException.NotConnectedException, InterruptedException, XMPPException.XMPPErrorException, SmackException.NoResponseException {
LOGGER.log(Level.INFO, "Activate proxy: " + candidate.getCandidateId() + " " + candidate.getStreamHost().getAddress() + ":" + candidate.getStreamHost().getPort() + " " + candidate.getStreamHost().getJID() + " for " + getParent().getParent().getPeer()); LOGGER.log(Level.INFO, "Activate proxy: " + candidate.getCandidateId() + " " + candidate.getStreamHost().getAddress() + ":" + candidate.getStreamHost().getPort() + " " + candidate.getStreamHost().getJID() + " for " + getParent().getParent().getPeer());
Bytestream activate = new Bytestream(getSid()); Bytestream activate = new Bytestream(getStreamId());
activate.setMode(null); activate.setMode(null);
activate.setType(IQ.Type.set); activate.setType(IQ.Type.set);
activate.setTo(candidate.getStreamHost().getJID()); activate.setTo(candidate.getStreamHost().getJID());

View file

@ -39,7 +39,7 @@ public class JingleS5BTransportAdapter implements JingleTransportAdapter<JingleS
candidates.add(JingleS5BTransportCandidate.fromElement((JingleS5BTransportCandidateElement) e)); candidates.add(JingleS5BTransportCandidate.fromElement((JingleS5BTransportCandidateElement) e));
} }
return new JingleS5BTransport(s5b.getSid(), s5b.getMode(), null, s5b.getDestinationAddress(), null, candidates); return new JingleS5BTransport(s5b.getStreamId(), s5b.getMode(), null, s5b.getDestinationAddress(), null, candidates);
} }
@Override @Override

View file

@ -106,7 +106,7 @@ public class JingleS5BTransportCandidate extends JingleTransportCandidate<Jingle
LOGGER.log(Level.INFO, getStreamHost().getAddress() + ":" + getStreamHost().getPort() + " " + getStreamHost().getJID().toString() + " " + getType()); LOGGER.log(Level.INFO, getStreamHost().getAddress() + ":" + getStreamHost().getPort() + " " + getStreamHost().getJID().toString() + " " + getType());
JingleContent content = transport.getParent(); JingleContent content = transport.getParent();
JingleSession session = content.getParent(); JingleSession session = content.getParent();
client = new Socks5ClientForInitiator(getStreamHost(), transport.getOurDstAddr(), session.getJingleManager().getConnection(), transport.getSid(), session.getPeer()); client = new Socks5ClientForInitiator(getStreamHost(), transport.getOurDstAddr(), session.getJingleManager().getConnection(), transport.getStreamId(), session.getPeer());
} }
this.socket = client.getSocket(timeout); this.socket = client.getSocket(timeout);
break; break;

View file

@ -213,7 +213,7 @@ public final class JingleS5BTransportManager extends Manager implements JingleTr
JingleS5BTransportElement.Builder tb = JingleS5BTransportElement.getBuilder() JingleS5BTransportElement.Builder tb = JingleS5BTransportElement.getBuilder()
.setTransportInfo(info) .setTransportInfo(info)
.setStreamId(transport.getSid()); .setStreamId(transport.getStreamId());
JingleElement jingle = jb.addJingleContent(cb.setTransport(tb.build()).build()).build(); JingleElement jingle = jb.addJingleContent(cb.setTransport(tb.build()).build()).build();
jingle.setFrom(session.getOurJid()); jingle.setFrom(session.getOurJid());

View file

@ -47,7 +47,7 @@ public class JingleS5BTransportElement extends JingleContentTransportElement {
this.mode = mode; this.mode = mode;
} }
public String getSid() { public String getStreamId() {
return sid; return sid;
} }

View file

@ -63,6 +63,10 @@ public class JingleIBBTransportTest extends SmackTestSuite {
transport1.handleSessionAccept(transport2.getElement(), null); transport1.handleSessionAccept(transport2.getElement(), null);
assertEquals(transport2.getBlockSize(), transport1.getBlockSize()); assertEquals(transport2.getBlockSize(), transport1.getBlockSize());
JingleIBBTransport transport3 = new JingleIBBTransportAdapter().transportFromElement(transport2.getElement());
assertEquals(transport2.getBlockSize(), transport3.getBlockSize());
assertEquals(transport2.getStreamId(), transport3.getStreamId());
} }
@Test @Test

View file

@ -83,7 +83,7 @@ public class JingleS5BTransportTest extends SmackTestSuite {
"</transport>"; "</transport>";
JingleS5BTransportElement transportElement = new JingleS5BTransportProvider().parse(TestUtils.getParser(xml)); JingleS5BTransportElement transportElement = new JingleS5BTransportProvider().parse(TestUtils.getParser(xml));
assertEquals("972b7bf47291ca609517f67f86b5081086052dad", transportElement.getDestinationAddress()); assertEquals("972b7bf47291ca609517f67f86b5081086052dad", transportElement.getDestinationAddress());
assertEquals("vj3hs98y", transportElement.getSid()); assertEquals("vj3hs98y", transportElement.getStreamId());
assertEquals(Bytestream.Mode.tcp, transportElement.getMode()); assertEquals(Bytestream.Mode.tcp, transportElement.getMode());
assertEquals(3, transportElement.getCandidates().size()); assertEquals(3, transportElement.getCandidates().size());
@ -123,7 +123,7 @@ public class JingleS5BTransportTest extends SmackTestSuite {
JingleS5BTransport transport = new JingleS5BTransportAdapter().transportFromElement(transportElement); JingleS5BTransport transport = new JingleS5BTransportAdapter().transportFromElement(transportElement);
assertNotNull(transport); assertNotNull(transport);
assertEquals(transportElement.getSid(), transport.getSid()); assertEquals(transportElement.getStreamId(), transport.getStreamId());
assertEquals(transportElement.getMode(), transport.getMode()); assertEquals(transportElement.getMode(), transport.getMode());
assertEquals(transportElement.getDestinationAddress(), transport.getTheirDstAddr()); assertEquals(transportElement.getDestinationAddress(), transport.getTheirDstAddr());
assertNull(transport.getOurDstAddr()); assertNull(transport.getOurDstAddr());
@ -162,7 +162,7 @@ public class JingleS5BTransportTest extends SmackTestSuite {
.parse(TestUtils.getParser(candidateError)); .parse(TestUtils.getParser(candidateError));
assertNull(candidateErrorTransport.getDestinationAddress()); assertNull(candidateErrorTransport.getDestinationAddress());
assertNotNull(candidateErrorTransport.getInfo()); assertNotNull(candidateErrorTransport.getInfo());
assertEquals("vj3hs98y", candidateErrorTransport.getSid()); assertEquals("vj3hs98y", candidateErrorTransport.getStreamId());
assertEquals(JingleS5BTransportInfoElement.CandidateError.INSTANCE, assertEquals(JingleS5BTransportInfoElement.CandidateError.INSTANCE,
candidateErrorTransport.getInfo()); candidateErrorTransport.getInfo());
assertEquals(candidateError, candidateErrorTransport.toXML().toString()); assertEquals(candidateError, candidateErrorTransport.toXML().toString());
@ -176,7 +176,7 @@ public class JingleS5BTransportTest extends SmackTestSuite {
assertNull(proxyErrorTransport.getDestinationAddress()); assertNull(proxyErrorTransport.getDestinationAddress());
assertNotNull(proxyErrorTransport.getInfo()); assertNotNull(proxyErrorTransport.getInfo());
assertNotNull(candidateErrorTransport.getInfo()); assertNotNull(candidateErrorTransport.getInfo());
assertEquals("vj3hs98y", proxyErrorTransport.getSid()); assertEquals("vj3hs98y", proxyErrorTransport.getStreamId());
assertEquals(JingleS5BTransportInfoElement.ProxyError.INSTANCE, assertEquals(JingleS5BTransportInfoElement.ProxyError.INSTANCE,
proxyErrorTransport.getInfo()); proxyErrorTransport.getInfo());
assertEquals(proxyError, proxyErrorTransport.toXML().toString()); assertEquals(proxyError, proxyErrorTransport.toXML().toString());
@ -271,7 +271,7 @@ public class JingleS5BTransportTest extends SmackTestSuite {
JingleS5BTransport t1 = new JingleS5BTransport(initiator, responder, "tSes", Bytestream.Mode.tcp, c1); JingleS5BTransport t1 = new JingleS5BTransport(initiator, responder, "tSes", Bytestream.Mode.tcp, c1);
assertEquals("tSes", t1.getSid()); assertEquals("tSes", t1.getStreamId());
assertEquals(Bytestream.Mode.tcp, t1.getMode()); assertEquals(Bytestream.Mode.tcp, t1.getMode());
assertEquals(Socks5Utils.createDigest("tSes", initiator, responder), t1.getOurDstAddr()); assertEquals(Socks5Utils.createDigest("tSes", initiator, responder), t1.getOurDstAddr());
@ -287,13 +287,13 @@ public class JingleS5BTransportTest extends SmackTestSuite {
assertEquals(t1.getOurDstAddr(), t1parsed.getTheirDstAddr()); assertEquals(t1.getOurDstAddr(), t1parsed.getTheirDstAddr());
assertNull(t1parsed.getOurDstAddr()); assertNull(t1parsed.getOurDstAddr());
assertEquals(0, t1parsed.getOurCandidates().size()); assertEquals(0, t1parsed.getOurCandidates().size());
assertEquals(t1.getSid(), t1parsed.getSid()); assertEquals(t1.getStreamId(), t1parsed.getStreamId());
assertEquals(t1.getMode(), t1parsed.getMode()); assertEquals(t1.getMode(), t1parsed.getMode());
assertEquals(t1.getOurCandidates().size(), t1parsed.getTheirCandidates().size()); assertEquals(t1.getOurCandidates().size(), t1parsed.getTheirCandidates().size());
JingleS5BTransport t2 = new JingleS5BTransport(initiator, responder, c2, t1parsed); JingleS5BTransport t2 = new JingleS5BTransport(initiator, responder, c2, t1parsed);
assertEquals("tSes", t2.getSid()); assertEquals("tSes", t2.getStreamId());
assertEquals(Bytestream.Mode.tcp, t2.getMode()); assertEquals(Bytestream.Mode.tcp, t2.getMode());
assertEquals(Socks5Utils.createDigest("tSes", responder, initiator), t2.getOurDstAddr()); assertEquals(Socks5Utils.createDigest("tSes", responder, initiator), t2.getOurDstAddr());