Revert "Merge pull request #22 from scriptjunkie/multithread"
This reverts commitunstable4f76f3bbb8
, reversing changes made toe72dad4e81
.
parent
d49fe71579
commit
1db9177583
|
@ -63,8 +63,7 @@ class Service
|
|||
self.options[:ssl],
|
||||
self.options[:context],
|
||||
self.options[:comm],
|
||||
self.options[:cert],
|
||||
true
|
||||
self.options[:cert]
|
||||
)
|
||||
|
||||
self.service.add_resource(self.uri, {
|
||||
|
|
|
@ -68,13 +68,9 @@ module StreamServer
|
|||
self.listener_thread = Rex::ThreadFactory.spawn("StreamServerListener", false) {
|
||||
monitor_listener
|
||||
}
|
||||
if self.threaded
|
||||
self.clients_thread = []
|
||||
else
|
||||
self.clients_thread = Rex::ThreadFactory.spawn("StreamServerClientMonitor", false) {
|
||||
monitor_clients
|
||||
}
|
||||
end
|
||||
self.clients_thread = Rex::ThreadFactory.spawn("StreamServerClientMonitor", false) {
|
||||
monitor_clients
|
||||
}
|
||||
end
|
||||
|
||||
#
|
||||
|
@ -82,7 +78,7 @@ module StreamServer
|
|||
#
|
||||
def stop
|
||||
self.listener_thread.kill
|
||||
self.clients_thread.kill unless self.threaded
|
||||
self.clients_thread.kill
|
||||
|
||||
self.clients.each { |cli|
|
||||
close_client(cli)
|
||||
|
@ -95,7 +91,6 @@ module StreamServer
|
|||
#
|
||||
def close_client(client)
|
||||
if (client)
|
||||
clients_thread.delete_at(clients.index(client)) if self.threaded
|
||||
clients.delete(client)
|
||||
|
||||
begin
|
||||
|
@ -135,7 +130,7 @@ module StreamServer
|
|||
attr_accessor :on_client_close_proc
|
||||
|
||||
attr_accessor :clients # :nodoc:
|
||||
attr_accessor :listener_thread, :clients_thread, :threaded # :nodoc:
|
||||
attr_accessor :listener_thread, :clients_thread # :nodoc:
|
||||
attr_accessor :client_waiter
|
||||
|
||||
protected
|
||||
|
@ -161,12 +156,6 @@ protected
|
|||
# Initialize the connection processing
|
||||
on_client_connect(cli)
|
||||
|
||||
if self.threaded # Start thread
|
||||
self.clients_thread << Rex::ThreadFactory.spawn("StreamServerClientMonitor#{cli.to_s}", false, cli) {
|
||||
monitor_clients(cli)
|
||||
}
|
||||
end
|
||||
|
||||
# Notify the client monitor
|
||||
self.client_waiter.push(cli)
|
||||
|
||||
|
@ -186,20 +175,16 @@ protected
|
|||
# This method monitors client connections for data and calls the
|
||||
# +on_client_data+ routine when new data arrives.
|
||||
#
|
||||
def monitor_clients(cli = nil)
|
||||
def monitor_clients
|
||||
begin
|
||||
|
||||
# Wait for a notify if our client list is empty
|
||||
if (not self.threaded and clients.length == 0)
|
||||
if (clients.length == 0)
|
||||
self.client_waiter.pop
|
||||
next
|
||||
end
|
||||
|
||||
if self.threaded
|
||||
sd = Rex::ThreadSafe.select([cli])
|
||||
else
|
||||
sd = Rex::ThreadSafe.select(clients, nil, nil, nil)
|
||||
end
|
||||
sd = Rex::ThreadSafe.select(clients, nil, nil, nil)
|
||||
|
||||
sd[0].each { |cfd|
|
||||
begin
|
||||
|
@ -218,8 +203,6 @@ protected
|
|||
}
|
||||
|
||||
rescue ::Rex::StreamClosedError => e
|
||||
# Remove thread from the list if threaded
|
||||
clients_thread.delete_at(clients.index(client)) if self.threaded
|
||||
# Remove the closed stream from the list
|
||||
clients.delete(e.stream)
|
||||
rescue ::Interrupt
|
||||
|
|
|
@ -99,14 +99,13 @@ class Server
|
|||
# Initializes an HTTP server as listening on the provided port and
|
||||
# hostname.
|
||||
#
|
||||
def initialize(port = 80, listen_host = '0.0.0.0', ssl = false, context = {}, comm = nil, ssl_cert = nil, threaded = false)
|
||||
def initialize(port = 80, listen_host = '0.0.0.0', ssl = false, context = {}, comm = nil, ssl_cert = nil)
|
||||
self.listen_host = listen_host
|
||||
self.listen_port = port
|
||||
self.ssl = ssl
|
||||
self.context = context
|
||||
self.comm = comm
|
||||
self.ssl_cert = ssl_cert
|
||||
self.threaded = threaded
|
||||
|
||||
self.listener = nil
|
||||
self.resources = {}
|
||||
|
@ -138,8 +137,7 @@ class Server
|
|||
'Context' => self.context,
|
||||
'SSL' => self.ssl,
|
||||
'SSLCert' => self.ssl_cert,
|
||||
'Comm' => self.comm,
|
||||
'Threaded' => self.threaded
|
||||
'Comm' => self.comm
|
||||
)
|
||||
|
||||
# Register callbacks
|
||||
|
@ -262,7 +260,7 @@ class Server
|
|||
end
|
||||
|
||||
attr_accessor :listen_port, :listen_host, :server_name, :context, :ssl, :comm, :ssl_cert
|
||||
attr_accessor :listener, :resources, :threaded
|
||||
attr_accessor :listener, :resources
|
||||
|
||||
protected
|
||||
|
||||
|
|
|
@ -673,9 +673,6 @@ module Socket
|
|||
self.localport = params.localport
|
||||
self.context = params.context || {}
|
||||
self.ipv = params.v6 ? 6 : 4
|
||||
if (self.respond_to?('threaded'))
|
||||
self.threaded = params.threaded?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -97,11 +97,6 @@ class Rex::Socket::Parameters
|
|||
#
|
||||
# The number of seconds before a connection should time out
|
||||
#
|
||||
# Threaded
|
||||
#
|
||||
# Whether the server is to spin off a new thread for each client.
|
||||
#
|
||||
|
||||
|
||||
def initialize(hash)
|
||||
if (hash['PeerHost'])
|
||||
|
@ -143,13 +138,7 @@ class Rex::Socket::Parameters
|
|||
else
|
||||
self.ssl = false
|
||||
end
|
||||
|
||||
if (hash['Threaded'] and hash['Threaded'].to_s =~ /^(t|y|1)/i)
|
||||
self.threaded = true
|
||||
else
|
||||
self.threaded = false
|
||||
end
|
||||
|
||||
|
||||
if (hash['SSLVersion'] and hash['SSLVersion'].to_s =~ /^(SSL2|SSL3|TLS1)$/i)
|
||||
self.ssl_version = hash['SSLVersion']
|
||||
end
|
||||
|
@ -284,12 +273,6 @@ class Rex::Socket::Parameters
|
|||
return v6
|
||||
end
|
||||
|
||||
#
|
||||
# Returns true if Multithreading has been enabled
|
||||
#
|
||||
def threaded?
|
||||
return threaded
|
||||
end
|
||||
|
||||
##
|
||||
#
|
||||
|
@ -361,10 +344,6 @@ class Rex::Socket::Parameters
|
|||
# Whether we should use IPv6
|
||||
#
|
||||
attr_accessor :v6
|
||||
#
|
||||
# Whether we should be multithreaded
|
||||
#
|
||||
attr_accessor :threaded
|
||||
|
||||
|
||||
attr_accessor :proxies
|
||||
|
|
Loading…
Reference in New Issue