From 6cff8a3636b3316ca0589b68e8cc9d8ac6a6ee11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= <nisse@lysator.liu.se> Date: Fri, 1 Aug 1997 09:34:17 +0200 Subject: [PATCH] Added a callback to be called when a bad packet is received. Rev: lib/modules/SSL.pmod/connection.pike:1.6 --- lib/modules/SSL.pmod/connection.pike | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/modules/SSL.pmod/connection.pike b/lib/modules/SSL.pmod/connection.pike index 26b062f117..f2ba0b1d39 100644 --- a/lib/modules/SSL.pmod/connection.pike +++ b/lib/modules/SSL.pmod/connection.pike @@ -1,4 +1,4 @@ -/* $Id: connection.pike,v 1.5 1997/05/31 22:03:53 grubba Exp $ +/* $Id: connection.pike,v 1.6 1997/08/01 07:34:17 nisse Exp $ * * SSL packet layer */ @@ -12,6 +12,8 @@ object packet; int dying; int closing; +function(object,int|object,string:void) alert_callback; + inherit "constants"; inherit "handshake"; @@ -36,6 +38,16 @@ void create(int is_server) current_write_state = State(this_object()); } +/* Called with alert object, sequence number of bad packet, + * and raw data as arguments, if a bad packet is received. + * + * Can be used to support a fallback redirect https->http + */ +void set_alert_callback(function(object,int|object,string:void) callback) +{ + alert_callback = callback; +} + object recv_packet(string data) { mixed res; @@ -190,6 +202,9 @@ int handshake_finished = 0; * -1 if a fatal error occured */ string|int got_data(string s) { + /* If alert_callback is called, this data is passed as an argument */ + string alert_context = (left_over || "") + s; + string res = ""; object packet; while (packet = recv_packet(s)) @@ -202,6 +217,8 @@ string|int got_data(string s) werror("SSL.connection: Bad received packet\n"); #endif send_packet(packet); + if (alert_callback) + alert_callback(packet, current_read_state->seq_num, alert_context); if (packet->level == ALERT_fatal) return -1; } -- GitLab