1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-10 18:15:58 +01:00
Commit graph

937 commits

Author SHA1 Message Date
Aditya Borikar
9fcc97836b Introduce AbstractStreamOpen and AbstractStreamClose
- Inherit StreamOpen and StreamClose from AbstractStream classes
2020-08-18 10:35:22 +05:30
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
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
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
dd631048a3
NoEndpointDiscoveredException: s/Not/No 2020-07-28 19:00:04 +02:00
Florian Schmaus
ec80d5287b [core] Add String-based StateDescriptor precedence/inferiority declaration methods 2020-07-25 14:27:45 +02:00
Florian Schmaus
64fb47c98b Fix typo in StateDescriptor method: s/Inferiorty/Inferiority/ 2020-07-25 13:55:35 +02:00
Florian Schmaus
1bd097ed9b
Merge pull request #411 from Flowdalic/sasl
SASL / getFeature()
2020-07-23 16:09:57 +02:00
Florian Schmaus
329948b442 Add XMPP.(get|has)Feature(Class|QName) and deprecate (String, String) 2020-07-23 14:32:14 +02:00
Florian Schmaus
f1e10bc6bc
Merge pull request #409 from vanitasvitae/connectionListenerConnecting
ConnectionListener: Add connecting(XMPPConnection) method.
2020-07-23 14:19:14 +02:00
Florian Schmaus
2b423b911e Merge branch 'master' of github.com:igniterealtime/Smack 2020-07-18 21:47:06 +02:00
bc599a6dd6
Add callback method for when Smack is connecting 2020-07-18 12:50:08 +02:00
bb3c491e0c
StringUtils: Fix typo and expose unambiguous alphabet as string 2020-07-15 22:15:38 +02:00
Florian Schmaus
d3a99a133a [core] Fix log/exception message of XmppElementUtil
The Class.toString() already prefixes the resulting string with "class
", no need to state it explicitly in the log message that this is a
class.
2020-07-13 08:50:10 +02:00
Florian Schmaus
91337150e7 [sasl] Rename getChannelBindingName() to getGs2CbindFlag()
As this returns the value of the SCRAM gs2-cbind-flag.
2020-07-02 13:07:17 +02:00
Aditya Borikar
dcb66eef59 Add support for HTTP lookup method through xep-0156 2020-06-25 21:10:43 +05:30
Florian Schmaus
ddc39030d7 Rename waitForCondition() to waitForConditionOrConnectionException()
To make it clear that this will either return if the condition is
true *or* if a connection exception happened.

Also introduce waitFor(), which is deliberately not named
waitForCondition() because it carries a different semantic.
2020-06-17 21:56:45 +02:00
Florian Schmaus
3f9ca68134 Delete TypedCloneable 2020-06-14 17:38:51 +02:00
Florian Schmaus
c689bef7ec Add static QNAME field to Compressed, Failure and Tls(Failure|Proceed) 2020-06-14 16:51:28 +02:00
Florian Schmaus
f1319d1c8b Move getters from Message to MessageView 2020-06-12 09:17:54 +02:00
Florian Schmaus
6a617af158 Merge branch 'master' of github.com:igniterealtime/Smack 2020-06-04 22:51:17 +02:00
Florian Schmaus
afbe833a97
Merge pull request #395 from adiaholic/docFix
Correct documentation
2020-06-02 22:07:35 +02:00
Florian Schmaus
ccbc0922ad [core] Fix comment 2020-06-02 10:05:56 +02:00
Florian Schmaus
81f10b0c5b [core] Synchronize notifyConnectionError()
Synchronize notifyConnectionError() so that only one exception is
handled and remove the ASYNC_BUT_ORDERED usage here. The
ASYNC_BUT_ORDERED was added with 7d2c3ac9f ("Do not call synchronized
methods in reader/writer thread"), but is no longer necessary, since
the Semaphores where replaced with conditions in the previous commit.
2020-05-31 19:49:40 +02:00
Florian Schmaus
57961a8cc1 Remove SynchronizationPoint
This continues the design started with e98d42790 ("SmackReactor/NIO,
Java8/Android19, Pretty print XML, FSM connections"), where the
exceptions that caused an operation to fail, are not recorded within
SynchronizationPoint but within the connection instance itself.
2020-05-31 19:48:47 +02:00
Aditya Borikar
d639e0bc4c Some more docFix es 2020-05-31 01:10:29 +05:30
Florian Schmaus
b1a4ccfae8 [core] Do not weakly reference "channel selected" callback
Since d65f2c932 ("Bump Error Prone version to 2.3.4 and fix new bug
patterns") the channel selected callback is no longer a final field of
the connection instance, hence it may be come null even if the
connection instance is still strongly referenced. Also the
ConnectionAttemptState class uses simply a lambda as callback, which
is also not strongly referenced otherwise.

The "channel selected" callback was wrapped in weak reference, so that
connection instances could get gc'ed if they are still connected but
the user lost all references to them. In this case, the weak reference
to the connection instance would become 'null' and
selectionKey.cancel() would be called.

This change means that a socket and its selection key of a "leaked"
connected connection instance continues to be part of the reactor. But
this may not be that bad: first, users are expected to manager their
connection instances, and disconnect them before they are
discarded. And secondly, at some point the connection likely will get
disconnected, and in this case, the socket and its selection key will
be removed from the reactor.
2020-05-30 19:45:59 +02:00
Florian Schmaus
f5448c5faa [core] Rework TLS logic
This moves the logic in AbstractXMPPConnection.getSmackTlsContext()
into the ConnectionConfiguration constructor.

Also introduce SslContextFactory and use it in
ConnectionConfiguration.
2020-05-25 15:41:57 +02:00
Florian Schmaus
7156849c77 [core] Set default SecurityMode to 'required' in ConnectionConfiguration 2020-05-25 14:44:35 +02:00
Florian Schmaus
d65f2c932e Bump Error Prone version to 2.3.4 and fix new bug patterns 2020-05-24 21:10:01 +02:00
Florian Schmaus
cac874bdc7 [core] Use UInt16 for ConnectionConfiguration 'port' 2020-05-24 13:08:03 +02:00
Florian Schmaus
9a8ee3c8e3 [core] Improve NumberUtil's exception message and fix javadoc 2020-05-24 13:08:03 +02:00
Florian Schmaus
a137944e50 [disco/caps] Fix DiscoverInfo.asBuilder()
The method would not copy the extensions elements, which would lead to
a false calculation of the caps hash by EntityCapsManager.
2020-05-22 15:38:16 +02:00
Florian Schmaus
68a453d3b3 [core] Fix deprecation javadoc in Presence
It should hint towards the StanzaFactory not SocketFactory.
2020-05-22 09:25:20 +02:00
Florian Schmaus
054fd9ae44 [core] Replace 'packet' with 'stanza' in Presence's javadoc 2020-05-22 09:25:15 +02:00
Florian Schmaus
962071762a [core] Optimize Presence.toXML() for empty element 2020-05-22 09:20:02 +02:00
Florian Schmaus
33720e8d97 [core] Fix potential NPE in Java7ZlibInputOutputStream
The field XMPPInputOutputStream.flushMethod was not initialized, which
could cause an NPE in the "switch (flushMethod)" found in
Java7ZlibInputOutputStream.getOutputStream().
2020-05-21 12:47:55 +02:00
Florian Schmaus
87591655ad [core] Add StanzaFilter.asPredicate(Class) 2020-05-18 09:15:14 +02:00
Florian Schmaus
72c5dc5886 [core] Introduce ScheduledAction.Kind for blocking and non-blocking actions 2020-05-18 09:15:14 +02:00
Florian Schmaus
4e5536e227 [core] Make ScheduledAction.cancel() return boolean and add javadoc 2020-05-18 09:15:14 +02:00
Florian Schmaus
6daf19dbd3 [core] Add javadoc to SmackReactor.cancel(ScheduledAction) 2020-05-18 09:15:14 +02:00
Florian Schmaus
dfdd0acf91 Introduce AbstractStats 2020-05-18 09:15:14 +02:00
dc64a43f12
Prevent NPE when closing trust store stream 2020-05-17 17:01:42 +02:00
d903184ee2
Quick typo fix: s/isntead/instead/g 2020-05-13 22:32:18 +02:00
Florian Schmaus
ab2d3a2b79 [core] Deprecate AbstractConnectionListener 2020-05-13 22:14:43 +02:00
Florian Schmaus
498dde2d86 Merge branch 'master' of github.com:igniterealtime/Smack 2020-05-13 20:20:01 +02:00
Florian Schmaus
77e26fc575 Re-work data form API
Apply builder pattern to form fields and replace getVariable() with
getFieldName(). Refer to the field name as "field name" instead of
"variable" everyone, just as XEP-0004 does.

Improve the high-level form API: introduce FilledForm and FillableForm
which perform stronger validation and consistency checks.

Also add FormFieldRegistry to enable processing of 'submit' forms
where the form field types are omitted.

Smack also now does omit the form field type declaration on 'submit'
type forms, as it is allowed by XEP-0004.
2020-05-13 20:14:41 +02:00
Guus der Kinderen
577c59484b pep: notification type can be normal or headline 2020-05-12 19:57:56 +02:00
Florian Schmaus
5e921e6393 core: add javadoc for StanzaView.getExtensions(Class) 2020-04-18 22:56:10 +02:00