Skip to content

Commit

Permalink
Use JitsiXmppStringprep, update smack (#1151)
Browse files Browse the repository at this point in the history
* ref: Use org.jitsi.xmpp.Smack.

* ref: Remove JidTest (moved to xmpp-extensions).

* chore: Update smack to 4.4.8

https://github.com/igniterealtime/Smack/blob/4.4.8/CHANGELOG.md

* chore: Update jitsi-xmpp-extensions (JitsiXmppStringprep).

* Add a config flag to allow disabling JitsiXmppStringprep.
  • Loading branch information
bgrozev authored Apr 29, 2024
1 parent fde481c commit 62b126f
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 141 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ class XmppConfig private constructor() {
.convertFrom<List<String>> { l -> l.map { JidCreate.domainBareFrom(it) } }
}

val useJitsiJidValidation: Boolean by config {
"jicofo.xmpp.use-jitsi-jid-validation".from(newConfig)
}

companion object {
@JvmField
val service = XmppServiceConnectionConfig()
Expand Down
3 changes: 3 additions & 0 deletions jicofo-selector/src/main/resources/reference.conf
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,9 @@ jicofo {
}

xmpp {
// Whether to use JitsiXmppStringprep to validate JIDs. If set to false uses the default validation in Smack.
use-jitsi-jid-validation = true

// The separate XMPP connection used for communication with clients (endpoints).
client {
enabled = true
Expand Down
19 changes: 1 addition & 18 deletions jicofo/src/main/kotlin/org/jitsi/jicofo/xmpp/Smack.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,29 +51,12 @@ import org.jitsi.xmpp.extensions.jitsimeet.UserInfoPacketExt
import org.jitsi.xmpp.extensions.jitsimeet.VideoMutedExtension
import org.jitsi.xmpp.extensions.rayo.RayoIqProvider
import org.jivesoftware.smack.SmackConfiguration
import org.jivesoftware.smack.parsing.ExceptionLoggingCallback
import org.jivesoftware.smack.provider.ProviderManager
import org.jivesoftware.smackx.bytestreams.socks5.Socks5Proxy
import org.jxmpp.JxmppContext
import org.jxmpp.stringprep.rocksxmppprecis.RocksXmppPrecisStringprep

fun initializeSmack() {
System.setProperty("jdk.xml.entityExpansionLimit", "0")
System.setProperty("jdk.xml.maxOccurLimit", "0")
System.setProperty("jdk.xml.elementAttributeLimit", "524288")
System.setProperty("jdk.xml.totalEntitySizeLimit", "0")
System.setProperty("jdk.xml.maxXMLNameLimit", "524288")
System.setProperty("jdk.xml.entityReplacementLimit", "0")

// The default SimpleXmppStringrep is very permissive and allows some invalid JIDs that we don't want to allow.
JxmppContext.setDefaultXmppStringprep(RocksXmppPrecisStringprep.INSTANCE)
org.jitsi.xmpp.Smack.initialize(XmppConfig.config.useJitsiJidValidation)

SmackConfiguration.setDefaultReplyTimeout(15000)
// if there is a parsing error, do not break the connection to the server(the default behaviour) as we need it for
// the other conferences.
SmackConfiguration.setDefaultParsingExceptionCallback(ExceptionLoggingCallback())

Socks5Proxy.setLocalSocks5ProxyEnabled(false)

registerXmppExtensions()
}
Expand Down
121 changes: 0 additions & 121 deletions jicofo/src/test/kotlin/org/jitsi/jicofo/xmpp/JidTest.kt

This file was deleted.

4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- Make sure this matches the version of the jxmpp artifacts inheriteb from smack. -->
<jxmpp.version>1.0.3</jxmpp.version>
<smack.version>4.4.6</smack.version>
<smack.version>4.4.8</smack.version>
<kotlin.version>1.9.10</kotlin.version>
<kotest.version>5.7.2</kotest.version>
<slf4j.version>1.7.32</slf4j.version>
Expand Down Expand Up @@ -175,7 +175,7 @@
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jitsi-xmpp-extensions</artifactId>
<version>1.0-79-gdc9285e</version>
<version>1.0-80-g0ce9883</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
Expand Down

0 comments on commit 62b126f

Please sign in to comment.