Skip to content

Commit

Permalink
ref: Move smack configuration to Smack.kt. (jitsi#1194)
Browse files Browse the repository at this point in the history
  • Loading branch information
bgrozev authored Dec 3, 2024
1 parent dbcacfb commit 437b30f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import org.jivesoftware.smack.ConnectionConfiguration
import org.jivesoftware.smack.ConnectionListener
import org.jivesoftware.smack.ReconnectionListener
import org.jivesoftware.smack.ReconnectionManager
import org.jivesoftware.smack.SASLAuthentication
import org.jivesoftware.smack.SmackException
import org.jivesoftware.smack.XMPPConnection
import org.jivesoftware.smack.tcp.XMPPTCPConnection
Expand Down Expand Up @@ -287,21 +286,6 @@ class XmppProvider(val config: XmppConnectionConfig, parentLogger: Logger) {
this.components = components
}

companion object {
init {
EntityCapsManager.setDefaultEntityNode("http://jitsi.org/jicofo")
ReconnectionManager.setEnabledPerDefault(true)
// Jicofo handles at most two connections and most of the time that is localhost and the number
// of jicofo instances is small so we can afford to retry quickly.
ReconnectionManager.setDefaultFixedDelay(2)
// Smack uses SASL Mechanisms ANONYMOUS and PLAIN, but tries to authenticate with GSSAPI when it's offered
// by the server. Disable GSSAPI.
SASLAuthentication.unregisterSASLMechanism("org.jivesoftware.smack.sasl.javax.SASLGSSAPIMechanism")
XMPPTCPConnection.setUseStreamManagementResumptionDefault(true)
XMPPTCPConnection.setUseStreamManagementDefault(true)
}
}

class RoomExistsException(message: String) : Exception(message)
interface Listener {
fun registrationChanged(registered: Boolean) { }
Expand Down
22 changes: 21 additions & 1 deletion jicofo/src/main/kotlin/org/jitsi/jicofo/xmpp/Smack.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,34 @@ import org.jitsi.xmpp.extensions.jitsimeet.TranscriptionStatusExtension
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.ReconnectionManager
import org.jivesoftware.smack.SASLAuthentication
import org.jivesoftware.smack.SmackConfiguration
import org.jivesoftware.smack.provider.ProviderManager
import org.jivesoftware.smack.tcp.XMPPTCPConnection
import org.jivesoftware.smackx.caps.EntityCapsManager

fun initializeSmack() {
org.jitsi.xmpp.Smack.initialize(XmppConfig.config.useJitsiJidValidation)
org.jitsi.xmpp.Smack.initialize(useJitsiXmppStringprep = XmppConfig.config.useJitsiJidValidation)

EntityCapsManager.setDefaultEntityNode("http://jitsi.org/jicofo")

// Default to 15 seconds, may be overriden by the different connections.
SmackConfiguration.setDefaultReplyTimeout(15000)

ReconnectionManager.setEnabledPerDefault(true)
// Jicofo handles at most two connections and most of the time that is localhost and the number
// of jicofo instances is small so we can afford to retry quickly.
ReconnectionManager.setDefaultFixedDelay(2)

// Smack uses SASL Mechanisms ANONYMOUS and PLAIN, but tries to authenticate with GSSAPI when it's offered
// by the server. Disable GSSAPI.
SASLAuthentication.unregisterSASLMechanism("org.jivesoftware.smack.sasl.javax.SASLGSSAPIMechanism")

// Enable Stream Management
XMPPTCPConnection.setUseStreamManagementResumptionDefault(true)
XMPPTCPConnection.setUseStreamManagementDefault(true)

registerXmppExtensions()
}

Expand Down

0 comments on commit 437b30f

Please sign in to comment.