Revision cc684758
Added by Marc Dequènes over 14 years ago
- ID cc684758116f5fa0e304cb375caf0337bd1d2e44
lib/cyborghood/cyborg/conversation.rb | ||
---|---|---|
|
||
EOD = "\033[0J"
|
||
COMMAND_PATTERN = "^#{CyborgServerInterfaceBase::NODE_PATTERN}(?: ([+?]+))?$"
|
||
MAXIMUM_ERROR_COUNT = 3
|
||
|
||
def initialize(interface)
|
||
@interface = interface
|
||
... | ... | |
@split_data_cmd = nil
|
||
@split_data = []
|
||
@session = Session.new
|
||
@error_count = 0
|
||
end
|
||
|
||
def send_line(msg)
|
||
... | ... | |
|
||
unless data =~ Regexp.new(COMMAND_PATTERN)
|
||
logger.error "Error [#{identifier}]: syntax error"
|
||
send_line "552 syntax error in command"
|
||
@error_count += 1
|
||
|
||
if @error_count >= MAXIMUM_ERROR_COUNT
|
||
send_line "503 too much errors, terminating"
|
||
close_connection_after_writing
|
||
else
|
||
send_line "552 syntax error in command"
|
||
end
|
||
return
|
||
end
|
||
cmd = $1
|
||
flags = $2 || ""
|
||
@error_count = 0
|
||
|
||
if flags.index '?'
|
||
send_line "250+ ok"
|
Also available in: Unified diff
[evol] Cyborg server interface: terminate connection after too much protocol errors