@@ -77,8 +77,7 @@ def login(user, pass)
77
77
begin
78
78
response = sock . timed_read ( 1024 , self . login_timeout )
79
79
rescue Timeout ::Error
80
- #vprint_error("AFP #{rhost}:#{rport} Login timeout (AFP server delay response for 20 - 22 seconds after 7 incorrect logins)")
81
- return :connection_error
80
+ raise RuntimeError , "AFP Login timeout (AFP server delay response for 20 - 22 seconds after 7 incorrect logins)"
82
81
end
83
82
84
83
flags , command , request_id , error_code , length , reserved = parse_header ( response )
@@ -87,8 +86,7 @@ def login(user, pass)
87
86
when -5001 #kFPAuthContinue
88
87
return parse_login_response_add_send_login_count ( response , { :p => p , :g => g , :ra => ra , :ma => ma ,
89
88
:password => pass , :user => user } )
90
- when -5023 #kFPUserNotAuth (User dosen't exists)
91
- #print_status("AFP #{rhost}:#{rport} User #{user} dosen't exists")
89
+ when -5023 #kFPUserNotAuth (User dosen't exists)
92
90
return :skip_user
93
91
else
94
92
return :connection_error
@@ -123,8 +121,7 @@ def no_user_authent_login
123
121
begin
124
122
response = sock . timed_read ( 1024 , self . login_timeout )
125
123
rescue Timeout ::Error
126
- vprint_error ( "AFP #{ rhost } :#{ rport } Login timeout (AFP server delay response for 20 - 22 seconds after 7 incorrect logins)" )
127
- return :connection_error
124
+ raise RuntimeError , "AFP Login timeout (AFP server delay response for 20 - 22 seconds after 7 incorrect logins)"
128
125
end
129
126
130
127
flags , command , request_id , error_code , length , reserved = parse_header ( response )
@@ -180,8 +177,7 @@ def parse_login_response_add_send_login_count(response, data)
180
177
begin
181
178
response = sock . timed_read ( 1024 , self . login_timeout )
182
179
rescue Timeout ::Error
183
- vprint_error ( "AFP #{ rhost } :#{ rport } Login timeout (AFP server delay response for 20 - 22 seconds after 7 incorrect logins)" )
184
- return :connection_error
180
+ raise RuntimeError , "AFP Login timeout (AFP server delay response for 20 - 22 seconds after 7 incorrect logins)"
185
181
end
186
182
187
183
flags , command , request_id , error_code , length , reserved = parse_header ( response )
@@ -201,7 +197,7 @@ def parse_info_response(response)
201
197
parsed_data = { }
202
198
203
199
flags , command , request_id , error_code , length , reserved = parse_header ( response )
204
- raise "AFP #{ rhost } : #{ rport } Server response with error" if error_code != 0
200
+ raise RuntimeError , "AFP Server response with error" if error_code != 0
205
201
body = get_body ( response , length )
206
202
machine_type_offset , afp_versions_offset , uam_count_offset , icon_offset , server_flags =
207
203
body . unpack ( 'nnnnn' )
@@ -243,7 +239,7 @@ def parse_header(packet)
243
239
244
240
def get_body ( packet , body_length )
245
241
body = packet [ 16 ..body_length + 15 ]
246
- raise "AFP #{ rhost } : #{ rport } Invalid body length" if body . length != body_length
242
+ raise RuntimeError , "AFP Invalid body length" if body . length != body_length
247
243
return body
248
244
end
249
245
@@ -291,7 +287,7 @@ def parse_network_addresses(network_addresses)
291
287
when 7 # IPv6 address (16 bytes) followed by a two-byte port number
292
288
parsed_addreses << "[#{ IPAddr . ntop ( address [ 1 ..16 ] ) } ]:#{ address [ 17 ..18 ] . unpack ( "n" ) . first } "
293
289
else # Something wrong?
294
- raise "Error parsing network addresses"
290
+ raise RuntimeError , "Error parsing network addresses"
295
291
end
296
292
end
297
293
return parsed_addreses
0 commit comments