Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
Openfire
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Openfire
Commits
1b22ea34
Commit
1b22ea34
authored
Dec 01, 2015
by
Guus der Kinderen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Restore S2S inbound port by creating ConnectionListiner for legacy/nonMINA socket handling.
parent
f0e6e04d
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
139 additions
and
71 deletions
+139
-71
ConnectionManager.java
src/java/org/jivesoftware/openfire/ConnectionManager.java
+0
-17
BlockingAcceptingMode.java
.../org/jivesoftware/openfire/net/BlockingAcceptingMode.java
+5
-6
SocketAcceptThread.java
...ava/org/jivesoftware/openfire/net/SocketAcceptThread.java
+10
-19
SocketAcceptingMode.java
...va/org/jivesoftware/openfire/net/SocketAcceptingMode.java
+13
-12
ConnectionListener.java
...ava/org/jivesoftware/openfire/spi/ConnectionListener.java
+9
-2
ConnectionManagerImpl.java
.../org/jivesoftware/openfire/spi/ConnectionManagerImpl.java
+0
-15
LegacyConnectionAcceptor.java
...g/jivesoftware/openfire/spi/LegacyConnectionAcceptor.java
+94
-0
MINAConnectionAcceptor.java
...org/jivesoftware/openfire/spi/MINAConnectionAcceptor.java
+8
-0
No files found.
src/java/org/jivesoftware/openfire/ConnectionManager.java
View file @
1b22ea34
...
@@ -77,23 +77,6 @@ public interface ConnectionManager {
...
@@ -77,23 +77,6 @@ public interface ConnectionManager {
*/
*/
public
Collection
<
ServerPort
>
getPorts
();
public
Collection
<
ServerPort
>
getPorts
();
/**
* Creates a new socket reader for the new accepted socket to be managed
* by the connection manager.
*
* @param socket the new accepted socket by this manager.
* @param isSecure true if the connection is secure.
* @param serverPort holds information about the port on which the server is listening for
* connections.
* @param useBlockingMode true means that the server will use a thread per connection.
* @return the created socket reader.
* @throws java.io.IOException when there is an error creating the socket reader.
* @deprecated This is part of the legacy blocking IO implementation. It should no longer be used in favor of NIO.
*/
@Deprecated
public
SocketReader
createSocketReader
(
Socket
socket
,
boolean
isSecure
,
ServerPort
serverPort
,
boolean
useBlockingMode
)
throws
IOException
;
/**
/**
* Sets if the port listener for unsecured clients will be available or not. When disabled
* Sets if the port listener for unsecured clients will be available or not. When disabled
* there won't be a port listener active. Therefore, new clients won't be able to connect to
* there won't be a port listener active. Therefore, new clients won't be able to connect to
...
...
src/java/org/jivesoftware/openfire/net/BlockingAcceptingMode.java
View file @
1b22ea34
...
@@ -42,10 +42,9 @@ class BlockingAcceptingMode extends SocketAcceptingMode {
...
@@ -42,10 +42,9 @@ class BlockingAcceptingMode extends SocketAcceptingMode {
private
static
final
Logger
Log
=
LoggerFactory
.
getLogger
(
BlockingAcceptingMode
.
class
);
private
static
final
Logger
Log
=
LoggerFactory
.
getLogger
(
BlockingAcceptingMode
.
class
);
protected
BlockingAcceptingMode
(
ConnectionManager
connManager
,
ServerPort
serverPort
,
protected
BlockingAcceptingMode
(
int
tcpPort
,
InetAddress
bindInterface
)
throws
IOException
{
InetAddress
bindInterface
)
throws
IOException
{
super
();
super
(
connManager
,
serverPort
);
serverSocket
=
new
ServerSocket
(
tcpPort
,
-
1
,
bindInterface
);
serverSocket
=
new
ServerSocket
(
serverPort
.
getPort
(),
-
1
,
bindInterface
);
}
}
/**
/**
...
@@ -59,8 +58,8 @@ class BlockingAcceptingMode extends SocketAcceptingMode {
...
@@ -59,8 +58,8 @@ class BlockingAcceptingMode extends SocketAcceptingMode {
Socket
sock
=
serverSocket
.
accept
();
Socket
sock
=
serverSocket
.
accept
();
if
(
sock
!=
null
)
{
if
(
sock
!=
null
)
{
Log
.
debug
(
"Connect "
+
sock
.
toString
());
Log
.
debug
(
"Connect "
+
sock
.
toString
());
SocketReader
reader
=
connManager
.
createSocketReader
(
sock
,
false
,
serverPort
,
true
);
SocketReader
reader
=
createServerSocketReader
(
sock
,
false
,
true
);
Thread
thread
=
new
Thread
(
reader
,
reader
.
getName
());
Thread
thread
=
new
Thread
(
reader
,
reader
.
getName
());
thread
.
setDaemon
(
true
);
thread
.
setDaemon
(
true
);
thread
.
setPriority
(
Thread
.
NORM_PRIORITY
);
thread
.
setPriority
(
Thread
.
NORM_PRIORITY
);
...
...
src/java/org/jivesoftware/openfire/net/SocketAcceptThread.java
View file @
1b22ea34
...
@@ -43,28 +43,19 @@ public class SocketAcceptThread extends Thread {
...
@@ -43,28 +43,19 @@ public class SocketAcceptThread extends Thread {
/**
/**
* Holds information about the port on which the server will listen for connections.
* Holds information about the port on which the server will listen for connections.
*/
*/
private
ServerPort
serverPort
;
private
final
int
tcpPort
;
private
InetAddress
bindInterface
;
private
SocketAcceptingMode
acceptingMode
;
private
SocketAcceptingMode
acceptingMode
;
public
SocketAcceptThread
(
ConnectionManager
connManager
,
ServerPort
serverPort
)
public
SocketAcceptThread
(
int
tcpPort
,
InetAddress
bindInterface
)
throws
IOException
{
throws
IOException
{
super
(
"Socket Listener at port "
+
serverPort
.
getPort
());
super
(
"Socket Listener at port "
+
tcpPort
);
// Listen on a specific network interface if it has been set.
this
.
tcpPort
=
tcpPort
;
String
interfaceName
=
JiveGlobals
.
getXMLProperty
(
"network.interface"
);
this
.
bindInterface
=
bindInterface
;
InetAddress
bindInterface
=
null
;
if
(
interfaceName
!=
null
)
{
if
(
interfaceName
.
trim
().
length
()
>
0
)
{
bindInterface
=
InetAddress
.
getByName
(
interfaceName
);
// Create the new server port based on the new bind address
serverPort
=
new
ServerPort
(
serverPort
.
getPort
(),
serverPort
.
getDomainNames
().
get
(
0
),
interfaceName
,
serverPort
.
isSecure
(),
serverPort
.
getSecurityType
(),
serverPort
.
getType
());
}
}
this
.
serverPort
=
serverPort
;
// Set the blocking reading mode to use
// Set the blocking reading mode to use
acceptingMode
=
new
BlockingAcceptingMode
(
connManager
,
server
Port
,
bindInterface
);
acceptingMode
=
new
BlockingAcceptingMode
(
tcp
Port
,
bindInterface
);
}
}
/**
/**
...
@@ -73,7 +64,7 @@ public class SocketAcceptThread extends Thread {
...
@@ -73,7 +64,7 @@ public class SocketAcceptThread extends Thread {
* @return the port the socket is bound to.
* @return the port the socket is bound to.
*/
*/
public
int
getPort
()
{
public
int
getPort
()
{
return
serverPort
.
getPort
()
;
return
tcpPort
;
}
}
/**
/**
...
@@ -82,7 +73,7 @@ public class SocketAcceptThread extends Thread {
...
@@ -82,7 +73,7 @@ public class SocketAcceptThread extends Thread {
* @return information about the port on which the server is listening for connections.
* @return information about the port on which the server is listening for connections.
*/
*/
public
ServerPort
getServerPort
()
{
public
ServerPort
getServerPort
()
{
return
serverPort
;
return
new
ServerPort
(
tcpPort
,
null
,
bindInterface
.
getHostName
(),
false
,
null
,
ServerPort
.
Type
.
server
)
;
}
}
/**
/**
...
...
src/java/org/jivesoftware/openfire/net/SocketAcceptingMode.java
View file @
1b22ea34
...
@@ -20,11 +20,11 @@
...
@@ -20,11 +20,11 @@
package
org
.
jivesoftware
.
openfire
.
net
;
package
org
.
jivesoftware
.
openfire
.
net
;
import
org.jivesoftware.openfire.ConnectionManager
;
import
org.jivesoftware.openfire.*
;
import
org.jivesoftware.openfire.ServerPort
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.net.ServerSocket
;
import
java.net.ServerSocket
;
import
java.net.Socket
;
/**
/**
* Abstract class for {@link BlockingAcceptingMode}.
* Abstract class for {@link BlockingAcceptingMode}.
...
@@ -40,21 +40,12 @@ abstract class SocketAcceptingMode {
...
@@ -40,21 +40,12 @@ abstract class SocketAcceptingMode {
*/
*/
protected
boolean
notTerminated
=
true
;
protected
boolean
notTerminated
=
true
;
/**
* Holds information about the port on which the server will listen for connections.
*/
protected
ServerPort
serverPort
;
/**
/**
* socket that listens for connections.
* socket that listens for connections.
*/
*/
protected
ServerSocket
serverSocket
;
protected
ServerSocket
serverSocket
;
protected
ConnectionManager
connManager
;
protected
SocketAcceptingMode
()
{
protected
SocketAcceptingMode
(
ConnectionManager
connManager
,
ServerPort
serverPort
)
{
this
.
connManager
=
connManager
;
this
.
serverPort
=
serverPort
;
}
}
public
abstract
void
run
();
public
abstract
void
run
();
...
@@ -72,4 +63,14 @@ abstract class SocketAcceptingMode {
...
@@ -72,4 +63,14 @@ abstract class SocketAcceptingMode {
// we don't care, no matter what, the socket should be dead
// we don't care, no matter what, the socket should be dead
}
}
}
}
public
SocketReader
createServerSocketReader
(
Socket
sock
,
boolean
isSecure
,
boolean
useBlockingMode
)
throws
IOException
{
final
XMPPServer
server
=
XMPPServer
.
getInstance
();
final
String
serverName
=
server
.
getServerInfo
().
getXMPPDomain
();
final
PacketRouter
router
=
server
.
getPacketRouter
();
final
RoutingTable
routingTable
=
server
.
getRoutingTable
();
final
PacketDeliverer
deliverer
=
server
.
getPacketDeliverer
();
final
SocketConnection
conn
=
new
SocketConnection
(
deliverer
,
sock
,
isSecure
);
return
new
ServerSocketReader
(
router
,
routingTable
,
serverName
,
sock
,
conn
,
useBlockingMode
);
}
}
}
src/java/org/jivesoftware/openfire/spi/ConnectionListener.java
View file @
1b22ea34
...
@@ -174,7 +174,6 @@ public class ConnectionListener
...
@@ -174,7 +174,6 @@ public class ConnectionListener
// TODO Start all connection types here, by supplying more connection acceptors other than a MINA-based one.
// TODO Start all connection types here, by supplying more connection acceptors other than a MINA-based one.
switch
(
getType
()
)
switch
(
getType
()
)
{
{
case
SOCKET_S2S:
case
BOSH_C2S:
case
BOSH_C2S:
case
WEBADMIN:
case
WEBADMIN:
Log
.
debug
(
"Not starting a (MINA-based) connection acceptor, as connections of type "
+
getType
()
+
" depend on another IO technology."
);
Log
.
debug
(
"Not starting a (MINA-based) connection acceptor, as connections of type "
+
getType
()
+
" depend on another IO technology."
);
...
@@ -205,7 +204,15 @@ public class ConnectionListener
...
@@ -205,7 +204,15 @@ public class ConnectionListener
}
}
Log
.
debug
(
"Starting..."
);
Log
.
debug
(
"Starting..."
);
connectionAcceptor
=
new
MINAConnectionAcceptor
(
generateConnectionConfiguration
()
);
if
(
getType
()
==
ConnectionType
.
SOCKET_S2S
)
{
connectionAcceptor
=
new
LegacyConnectionAcceptor
(
generateConnectionConfiguration
()
);
}
else
{
connectionAcceptor
=
new
MINAConnectionAcceptor
(
generateConnectionConfiguration
()
);
}
connectionAcceptor
.
start
();
connectionAcceptor
.
start
();
Log
.
info
(
"Started."
);
Log
.
info
(
"Started."
);
}
}
...
...
src/java/org/jivesoftware/openfire/spi/ConnectionManagerImpl.java
View file @
1b22ea34
...
@@ -895,19 +895,4 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana
...
@@ -895,19 +895,4 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana
}
}
return
result
;
return
result
;
}
}
// Old, pre NIO / MINA code. Should not be used as NIO offers better performance
@Deprecated
public
SocketReader
createSocketReader
(
Socket
sock
,
boolean
isSecure
,
ServerPort
serverPort
,
boolean
useBlockingMode
)
throws
IOException
{
if
(
serverPort
.
isServerPort
())
{
final
XMPPServer
server
=
XMPPServer
.
getInstance
();
final
String
serverName
=
server
.
getServerInfo
().
getXMPPDomain
();
final
PacketRouter
router
=
server
.
getPacketRouter
();
final
RoutingTable
routingTable
=
server
.
getRoutingTable
();
final
PacketDeliverer
deliverer
=
server
.
getPacketDeliverer
();
final
SocketConnection
conn
=
new
SocketConnection
(
deliverer
,
sock
,
isSecure
);
return
new
ServerSocketReader
(
router
,
routingTable
,
serverName
,
sock
,
conn
,
useBlockingMode
);
}
return
null
;
}
}
}
src/java/org/jivesoftware/openfire/spi/LegacyConnectionAcceptor.java
0 → 100644
View file @
1b22ea34
package
org
.
jivesoftware
.
openfire
.
spi
;
import
org.jivesoftware.openfire.net.SocketAcceptThread
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* A connection acceptor that employs the legacy, pre-MINA/NIO socket implementation of Openfire.
*
* @author Guus der Kinderen, guus.der.kinderen@gmail.com
* @deprecated Used only for S2S, which should be be ported to NIO.
*/
@Deprecated
public
class
LegacyConnectionAcceptor
extends
ConnectionAcceptor
{
private
final
Logger
Log
=
LoggerFactory
.
getLogger
(
LegacyConnectionAcceptor
.
class
);
private
SocketAcceptThread
socketAcceptThread
;
/**
* Constructs a new instance which will accept new connections based on the provided configuration.
* <p/>
* The provided configuration is expected to be immutable. ConnectionAcceptor instances are not expected to handle
* changes in configuration. When such changes are to be applied, an instance is expected to be replaced.
* <p/>
* Newly instantiated ConnectionAcceptors will not accept any connections before {@link #start()} is invoked.
*
* @param configuration The configuration for connections to be accepted (cannot be null).
*/
public
LegacyConnectionAcceptor
(
ConnectionConfiguration
configuration
)
{
super
(
configuration
);
}
/**
* Starts this acceptor by binding the socket acceptor. When the acceptor is already started, a warning will be
* logged and the method invocation is otherwise ignored.
*/
@Override
public
synchronized
void
start
()
{
if
(
socketAcceptThread
!=
null
)
{
Log
.
warn
(
"Unable to start acceptor (it is already started!)"
);
return
;
}
if
(
configuration
.
getMaxThreadPoolSize
()
>
1
)
{
Log
.
warn
(
"Configuration allows for up to "
+
configuration
.
getMaxThreadPoolSize
()
+
" threads, although implementation is limited to exactly one."
);
}
try
{
socketAcceptThread
=
new
SocketAcceptThread
(
configuration
.
getPort
(),
configuration
.
getBindAddress
());
socketAcceptThread
.
setDaemon
(
true
);
socketAcceptThread
.
setPriority
(
Thread
.
MAX_PRIORITY
);
socketAcceptThread
.
start
();
}
catch
(
Exception
e
)
{
System
.
err
.
println
(
"Error starting "
+
configuration
.
getPort
()
+
": "
+
e
.
getMessage
()
);
Log
.
error
(
"Error starting: "
+
configuration
.
getPort
(),
e
);
// Reset for future use.
if
(
socketAcceptThread
!=
null
)
{
try
{
socketAcceptThread
.
shutdown
();
}
finally
{
socketAcceptThread
=
null
;
}
}
}
}
/**
* Stops this acceptor by unbinding the socket acceptor. Does nothing when the instance is not started.
*/
@Override
public
synchronized
void
stop
()
{
if
(
socketAcceptThread
!=
null
)
{
try
{
socketAcceptThread
.
shutdown
();
}
finally
{
socketAcceptThread
=
null
;
}
}
}
@Override
boolean
isIdle
()
{
return
socketAcceptThread
!=
null
;
// We're not tracking actual sessions. This is a best effort response.
}
}
src/java/org/jivesoftware/openfire/spi/MINAConnectionAcceptor.java
View file @
1b22ea34
...
@@ -139,6 +139,14 @@ class MINAConnectionAcceptor extends ConnectionAcceptor
...
@@ -139,6 +139,14 @@ class MINAConnectionAcceptor extends ConnectionAcceptor
{
{
System
.
err
.
println
(
"Error starting "
+
configuration
.
getPort
()
+
": "
+
e
.
getMessage
()
);
System
.
err
.
println
(
"Error starting "
+
configuration
.
getPort
()
+
": "
+
e
.
getMessage
()
);
Log
.
error
(
"Error starting: "
+
configuration
.
getPort
(),
e
);
Log
.
error
(
"Error starting: "
+
configuration
.
getPort
(),
e
);
// Reset for future use.
if
(
socketAcceptor
!=
null
)
{
try
{
socketAcceptor
.
unbind
();
}
finally
{
socketAcceptor
=
null
;
}
}
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment