P2p: add error for invalid authentification
This commit is contained in:
parent
ce986c4a9c
commit
52fab9528c
@ -32,6 +32,7 @@ type error += Rejected
|
|||||||
type error += Decoding_error
|
type error += Decoding_error
|
||||||
type error += Myself of Id_point.t
|
type error += Myself of Id_point.t
|
||||||
type error += Not_enough_proof_of_work of Gid.t
|
type error += Not_enough_proof_of_work of Gid.t
|
||||||
|
type error += Invalid_auth
|
||||||
|
|
||||||
module Crypto = struct
|
module Crypto = struct
|
||||||
|
|
||||||
@ -336,9 +337,12 @@ let accept
|
|||||||
Lwt_utils.protect begin fun () ->
|
Lwt_utils.protect begin fun () ->
|
||||||
Ack.write fd cryptobox_data Ack >>=? fun () ->
|
Ack.write fd cryptobox_data Ack >>=? fun () ->
|
||||||
Ack.read fd cryptobox_data
|
Ack.read fd cryptobox_data
|
||||||
end ~on_error:begin fun _ ->
|
end ~on_error:begin fun err ->
|
||||||
P2p_io_scheduler.close fd >>= fun _ ->
|
P2p_io_scheduler.close fd >>= fun _ ->
|
||||||
fail Rejected
|
match err with
|
||||||
|
| [ P2p_io_scheduler.Connection_closed ] -> fail Rejected
|
||||||
|
| [ Decipher_error ] -> fail Invalid_auth
|
||||||
|
| err -> Lwt.return (Error err)
|
||||||
end >>=? fun accepted ->
|
end >>=? fun accepted ->
|
||||||
fail_unless accepted Rejected >>=? fun () ->
|
fail_unless accepted Rejected >>=? fun () ->
|
||||||
let canceler = Canceler.create () in
|
let canceler = Canceler.create () in
|
||||||
|
@ -26,6 +26,7 @@ type error += Decoding_error
|
|||||||
type error += Rejected
|
type error += Rejected
|
||||||
type error += Myself of Id_point.t
|
type error += Myself of Id_point.t
|
||||||
type error += Not_enough_proof_of_work of Gid.t
|
type error += Not_enough_proof_of_work of Gid.t
|
||||||
|
type error += Invalid_auth
|
||||||
|
|
||||||
type authenticated_fd
|
type authenticated_fd
|
||||||
(** Type of a connection that successfully passed the authentication
|
(** Type of a connection that successfully passed the authentication
|
||||||
|
Loading…
Reference in New Issue
Block a user