lib/ldap/server/connection.rb in ruby-ldapserver-0.5.3 vs lib/ldap/server/connection.rb in ruby-ldapserver-0.7.0
- old
+ new
@@ -29,15 +29,15 @@
end
def log(msg, severity = Logger::INFO)
@logger.add(severity, msg, @io.peeraddr[3])
end
-
+
def debug msg
log msg, Logger::DEBUG
end
-
+
def log_exception(e)
log "#{e}: #{e.backtrace.join("\n\tfrom ")}", Logger::ERROR
end
def startssl # :yields:
@@ -91,12 +91,10 @@
# or if we wanted to keep the partial decoding we've done:
# return blk, [blk[0] >> 6, tag], offset
end
def handle_requests
- operationClass = @opt[:operation_class]
- ocArgs = @opt[:operation_args] || []
catch(:close) do
while true
begin
blk = ber_read(@io)
asn1 = OpenSSL::ASN1::decode(blk)
@@ -118,13 +116,18 @@
end
case protocolOp.tag
when 0 # BindRequest
abandon_all
- @binddn, @version = operationClass.new(self,messageId,*ocArgs).
- do_bind(protocolOp, controls)
-
+ if @opt[:router]
+ @binddn, @version = @opt[:router].do_bind(self, messageId, protocolOp, controls)
+ else
+ operationClass = @opt[:operation_class]
+ ocArgs = @opt[:operation_args] || []
+ @binddn, @version = operationClass.new(self,messageId,*ocArgs).
+ do_bind(protocolOp, controls)
+ end
when 2 # UnbindRequest
throw(:close)
when 3 # SearchRequest
start_op(messageId,protocolOp,controls,:do_search)
@@ -169,17 +172,20 @@
#
# Note: RFC 2251 4.4.4.1 says behaviour is undefined if
# client sends an overlapping request with same message ID,
# so we don't have to worry about the case where there is
# already a thread with this messageId in @threadgroup.
-
def start_op(messageId,protocolOp,controls,meth)
operationClass = @opt[:operation_class]
ocArgs = @opt[:operation_args] || []
thr = Thread.new do
begin
- operationClass.new(self,messageId,*ocArgs).
- send(meth,protocolOp,controls)
+ if @opt[:router]
+ @opt[:router].send meth, self, messageId, protocolOp, controls
+ else
+ operationClass.new(self,messageId,*ocArgs).
+ send(meth,protocolOp,controls)
+ end
rescue Exception => e
log_exception e
end
end
thr[:messageId] = messageId