1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-19 10:32:05 +01:00
Commit graph

4929 commits

Author SHA1 Message Date
Florian Schmaus
488d01796a [tcp] Fix TlsState by aborting the channel selected callback
Instead of breaking in case the SSLEngine signals NEED_WRAP, which
leads to an endless loop while holding the
channelSelectedCallbackLock, we have to return, so that the
asynchronously invoked callback can aquire it, and do its work.
2020-09-17 22:15:30 +02:00
Florian Schmaus
b7824f008d Introduce and use XmlStringBuilder.text()
Smack currently does unnecessary escaping of XML text, where it
escapes e.g. '"' to '"'. This bloats the stanza size, especially
if JSON payloads are involved.

Fixes SMACK-892 (although there are probably still places where
XmlStringBuilder.escape() is used when XmlStringBuild.text() could
have been used).
2020-09-17 14:20:11 +02:00
Florian Schmaus
9e4153435a
Merge pull request #434 from Fishbowler/building_on_a_mac
Mac & Windows build instructions
2020-09-14 21:46:59 +02:00
Dan Caseley
8c33f56047 Mac & Windows build instructions 2020-09-14 17:04:21 +01:00
Florian Schmaus
0a6c21982b
Merge pull request #430 from Flowdalic/websocket
Introduce smack-websocket-okhttp
2020-09-02 11:13:06 +02:00
Florian Schmaus
9002be8e7a s/Websocket/WebSocket/
Java SE as well as OkHttp use 'WebSocket' (not 'Websocket'). Let us do
the same.

SMACK-835.
2020-09-01 21:47:36 +02:00
Florian Schmaus
6533cb7ed1 Introduce smack-websocket-okhttp
This uses Java's Service Provider Interface (SPI) to abstract
different WebSocket implementations.

SMACK-835
2020-09-01 21:36:13 +02:00
Florian Schmaus
9e9d30074c
Merge pull request #428 from vanitasvitae/pgpainlessalpha12
Bump pgpainless version to 0.1.0
2020-08-31 09:47:15 +02:00
4cc0f1d129
Bump pgpainless version to 0.1.0 2020-08-30 23:08:26 +02:00
Florian Schmaus
525f27abf1 Merge branch '4.4' 2020-08-29 16:39:15 +02:00
Florian Schmaus
64d3e804a7
Merge pull request #427 from Flowdalic/elements
Add XmppElementUtil.castOrThrow()
2020-08-29 16:38:54 +02:00
Florian Schmaus
e78ef2b668
Merge pull request #399 from adiaholic/websocket
Websocket support through RFC 7395
2020-08-29 16:34:32 +02:00
Florian Schmaus
1ebe8b0309
Merge pull request #422 from Flowdalic/drop-sm-state-on-clean-shutdown
[tcp] Drop Stream Management state on clean shutdown
2020-08-29 16:33:50 +02:00
Florian Schmaus
b09cd06053 [core] Use XmppElementUtil.castOrThrow() in StanzaView.getExtension(Class)
This means that users get now exceptions with helpful error messages
instead of the dreaded ClassCastException, like

java.lang.ClassCastException: org.jivesoftware.smack.packet.StandardExtensionElement cannot be cast to org.jivesoftware.smackx.mam.element.MamElements$MamResultExtension
at

when StanzaView.getExtension(Class) is used to retrieve the extension.
2020-08-29 16:29:22 +02:00
Florian Schmaus
d06e9499e8 [core] Add XmppElementUtil.castOrThrow(ExtensionElement, Class)
This method throws an IllegalStateException if the provided extension
element is not of the expected type and hints users towards potential
causes.
2020-08-29 16:29:22 +02:00
adiaholic
7ed29b9d5f Introduce websocket module into smack 2020-08-28 23:40:40 +05:30
Florian Schmaus
99297e5a76 [mam] Improve MamResultExtension: use MessageView in from() and add QNAME 2020-08-28 09:47:54 +02:00
Florian Schmaus
1aab0b8aac [core] Add cache to XmppElementUtil.getQNameFor(Class) 2020-08-28 09:47:09 +02:00
Florian Schmaus
cf4c9725b7 [core] Add ProviderManager.getExtensionProvider(QName) 2020-08-28 09:37:29 +02:00
Florian Schmaus
5d32735ad7
Merge pull request #426 from Flowdalic/getstreamopen
Get stream-open-like element from transport
2020-08-26 12:52:01 +02:00
Florian Schmaus
f892ba1369 [core] Get stream-open-like element from transport
When sending a stream-open-like element, it depends on the actual used
transport which element is send. For example, RFC6120-style TCP uses
<stream>, whereas the Websocket binding for XMPP uses <open/>.
2020-08-26 11:38:24 +02:00
Florian Schmaus
e6a60213b6 [core] Add convenience constructor to AbstractStreamOpen
Most of the times when we construct a stream-open-like element, we
want the jabber:client namespace. Hence add a constructor that does
select the namespace implicitly.
2020-08-26 11:36:55 +02:00
Florian Schmaus
2a9671ca93 [core] Change type of XmlStringBuilder cosntructor to FullyQualifiedElement
There is no reason we should do this only for ExtensionElements, this
behavior is sane for every FulllyQualifiedElement.
2020-08-26 11:35:22 +02:00
Florian Schmaus
d00656493a [jingle] Use correct XmlStringBuilder constructor in JingleReason 2020-08-26 11:34:57 +02:00
Florian Schmaus
7f10a82fd9
Merge pull request #425 from adiaholic/docFix
XMPPTCPConnection: Add missing `to` in comment
2020-08-25 14:52:54 +02:00
Aditya Borikar
0bb0884512 XMPPTCPConnection: Add missing to in comment 2020-08-23 13:25:18 +05:30
Florian Schmaus
53d66261af
Merge pull request #423 from adiaholic/streamFactory
Use AbstractStreamOpen instead of StreamOpen to open stream
2020-08-19 13:40:21 +02:00
Florian Schmaus
61799c5951
Merge pull request #424 from adiaholic/plugModule
Make ModularXmppClientToServerConnectionConfiguration.addModule() public
2020-08-19 13:39:39 +02:00
Aditya Borikar
648a1cfab1 Use AbstractStreamOpen instead of StreamOpen to open stream
Before the existence of AbstractStreamOpen, StreamOpen sufficed our need
during sending an open stream element. Since the intention behind
introducing AbstractStreamOpen is to allow underlying transports provide
transport specific opening streams, these changes will further support
the cause.

This commit will allow us to send transport specific open element
which should be inherited from AbstractStreamOpen.
2020-08-19 11:48:00 +05:30
Aditya Borikar
db385e6595 Make ModularXmppClientToServerConnectionConfiguration.addModule() public
This commit will allow users to plug their module descriptors inside
modular architecture.
2020-08-19 11:32:50 +05:30
Florian Schmaus
9cec02b5e3
Merge pull request #420 from adiaholic/streamFactory
Introduce StreamOpenFactory for modular architecture
2020-08-18 16:22:27 +02:00
Aditya Borikar
0e49adff1d Introduce StreamOpenAndCloseFactory for modular architecture 2020-08-18 19:04:34 +05:30
Aditya Borikar
9fcc97836b Introduce AbstractStreamOpen and AbstractStreamClose
- Inherit StreamOpen and StreamClose from AbstractStream classes
2020-08-18 10:35:22 +05:30
Florian Schmaus
49ebe8c587 [tcp] Drop Stream Management state on clean shutdown
We previously only set the SM session ID to zero, but that is not
enough. On a clean shutdown, i.e. where we send a </stream> close tag,
we also have to nullify the unacknowledgedStanzas queue.
2020-08-17 22:11:50 +02:00
Florian Schmaus
9fe1fc6689 Merge branch '4.4' 2020-08-17 17:25:26 +02:00
Florian Schmaus
3f3590b42b
Merge pull request #421 from Flowdalic/smack-streammanagement
Add smack-streammanagement project
2020-08-17 15:55:37 +02:00
Florian Schmaus
317e391da5 Create smack-streammanagement project and move o.j.smack.sm code there 2020-08-15 14:03:57 +02:00
Florian Schmaus
45e865757a [gradle] Use 'projectDirFile' File instance in getGitCommit()
The previous construct

def projectDir = dotGit.getParentFile()

was a little bit strange (and its declaration shadows the projectDir
String property).
2020-08-15 10:08:43 +02:00
Florian Schmaus
f00804ef72
Merge pull request #419 from adiaholic/bugFix
XmlEnvironment: Use correct method to obatain effective namespace.
2020-08-11 14:19:03 +02:00
Aditya Borikar
c9cf4f1541 XmlEnvironment: Use correct method to obatain effective namespace. 2020-08-08 20:14:39 +05:30
Florian Schmaus
11e38f9ba5 Smack 4.5.0-alpha1-SNAPSHOT 2020-08-07 22:07:00 +02:00
Florian Schmaus
89c5895ab3 Smack 4.4.0-beta2-SNAPSHOT 2020-08-07 22:06:32 +02:00
Florian Schmaus
b61426c8d0 Smack 4.4.0-beta1 2020-08-07 21:25:20 +02:00
Florian Schmaus
cf92566e26
Merge pull request #416 from Flowdalic/connected-boolean
Set 'connected' to 'true' as early as possible
2020-08-07 12:43:53 +02:00
Florian Schmaus
36d61d9e52
Merge pull request #413 from adiaholic/xep-0156
HttpLookupMethod: Position parser at START_ELEMENT before parsing
2020-08-07 12:37:04 +02:00
Aditya Borikar
7796b367cc Position parser at START_ELEMENT before parsing
This PR aims to provide parseXrdLinkReferencesFor() method the ability
to parse forward to the first START_ELEMENT tag.The HttpLookupMethodTest
tests the HttpLookupMethod class by parsing String. This makes use of
PacketParserUtils.getParserFor(String), which already does forward
winding to reach START_ELEMENT. However when fetching endpoints from a
remote host meta data, PacketParserUtils.getParserFor(InputStream) is
used which doesn't do winding in any form. And thus, even though
HttpLookupMethodTest tests pass, this implementation would crash while
parsing remote host-meta.
2020-08-07 15:01:53 +05:30
Florian Schmaus
e35175a3d5
Merge pull request #417 from Flowdalic/gradle-dynamic-versions
[build] Use ranged version [1.0.0, 1.0.999] for jXMPP and MiniDNS
2020-08-06 19:58:35 +02:00
Florian Schmaus
92ed777dba
Merge pull request #418 from Flowdalic/rename-waitForCondition
waitForCondition() → waitForConditionOrThrowConnectionException()
2020-08-06 19:58:22 +02:00
Florian Schmaus
ac788592a6 waitForCondition() → waitForConditionOrThrowConnectionException()
The method was already renamed, but not in
ModularXmppClientToServerConnectionInternal.
2020-08-06 18:17:04 +02:00
Florian Schmaus
1a2a613112 Set 'connected' to 'true' as early as possible
We previously only set 'connected' after connectInternal()
returned. This could lead to notifyConnectionError() ignoring stream
error exceptions, e.g. when establishing TLS which happens also in
connectInternal(), because 'connected' was still 'false'.

2020-08-06 13:08:06.265 19830-20423/org.atalk.android D/SMACK: SENT (0):
    <stream:stream xmlns='jabber:client' to='atalk.sytes.net' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' xml:lang='en'>
2020-08-06 13:08:06.333 19830-20424/org.atalk.android D/SMACK: RECV (0): ?xml version='1.0'?>
    <stream:stream id='16420577292739412012' version='1.0' xml:lang='en' xmlns:stream='http://etherx.jabber.org/streams' from='atalk.sytes.net' xmlns='jabber:client'>
    <stream:error>
      <policy-violation xmlns='urn:ietf:params:xml:ns:xmpp-streams'/>
      <text xml:lang='en' xmlns='urn:ietf:params:xml:ns:xmpp-streams'>
        Too many (20) failed authentications from this IP address (::ffff:42.60.7.13). The address will be unblocked at 05:15:34 06.08.2020 UTC
      </text>
    </stream:error>
    </stream:stream>
2020-08-06 13:08:06.346 19830-20424/org.atalk.android I/aTalk: [241896] org.jivesoftware.smack.AbstractXMPPConnection.notifyConnectionError() Connection was already disconnected when attempting to handle org.jivesoftware.smack.XMPPException$StreamErrorException: policy-violation You can read more about the meaning of this stream error at http://xmpp.org/rfcs/rfc6120.html#streams-error-conditions
    <stream:error><policy-violation xmlns='urn:ietf:params:xml:ns:xmpp-streams'/><text xml:lang='en'>Too many (20) failed authentications from this IP address (::ffff:42.60.7.13). The address will be unblocked at 05:15:34 06.08.2020 UTC</text></stream:error>
    org.jivesoftware.smack.XMPPException$StreamErrorException: policy-violation You can read more about the meaning of this stream error at http://xmpp.org/rfcs/rfc6120.html#streams-error-conditions
    <stream:error><policy-violation xmlns='urn:ietf:params:xml:ns:xmpp-streams'/><text xml:lang='en'>Too many (20) failed authentications from this IP address (::ffff:42.60.7.13). The address will be unblocked at 05:15:34 06.08.2020 UTC</text></stream:error>
        at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:966)
        at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$700(XMPPTCPConnection.java:898)
        at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:921)
        at java.lang.Thread.run(Thread.java:919)

Which eventually leads to a NoResponseException

org.jivesoftware.smack.SmackException$NoResponseException: No response
received within reply timeout. Timeout was 30000ms (~30s). While
waiting for establishing TLS
[XMPPTCPConnection[not-authenticated] (4)]

We now set 'connected' to 'true' as soon as the transport (e.g. TCP,
BOSH, …) is connected. While this is in other ways also sensible, it
also allows notifyConnectionError() to handle exceptions in the early
connection stage.

Thanks to Eng Chong Meng for reporting this.
2020-08-06 16:32:26 +02:00