Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pike
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pikelang
pike
Commits
6cff8a36
Commit
6cff8a36
authored
27 years ago
by
Niels Möller
Browse files
Options
Downloads
Patches
Plain Diff
Added a callback to be called when a bad packet is received.
Rev: lib/modules/SSL.pmod/connection.pike:1.6
parent
bd65a5f6
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/modules/SSL.pmod/connection.pike
+18
-1
18 additions, 1 deletion
lib/modules/SSL.pmod/connection.pike
with
18 additions
and
1 deletion
lib/modules/SSL.pmod/connection.pike
+
18
−
1
View file @
6cff8a36
/* $Id: connection.pike,v 1.
5
1997/0
5/31 22:03:53 grubba
Exp $
/* $Id: connection.pike,v 1.
6
1997/0
8/01 07:34:17 nisse
Exp $
*
*
* SSL packet layer
* SSL packet layer
*/
*/
...
@@ -12,6 +12,8 @@ object packet;
...
@@ -12,6 +12,8 @@ object packet;
int dying;
int dying;
int closing;
int closing;
function(object,int|object,string:void) alert_callback;
inherit "constants";
inherit "constants";
inherit "handshake";
inherit "handshake";
...
@@ -36,6 +38,16 @@ void create(int is_server)
...
@@ -36,6 +38,16 @@ void create(int is_server)
current_write_state = State(this_object());
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)
object recv_packet(string data)
{
{
mixed res;
mixed res;
...
@@ -190,6 +202,9 @@ int handshake_finished = 0;
...
@@ -190,6 +202,9 @@ int handshake_finished = 0;
* -1 if a fatal error occured */
* -1 if a fatal error occured */
string|int got_data(string s)
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 = "";
string res = "";
object packet;
object packet;
while (packet = recv_packet(s))
while (packet = recv_packet(s))
...
@@ -202,6 +217,8 @@ string|int got_data(string s)
...
@@ -202,6 +217,8 @@ string|int got_data(string s)
werror("SSL.connection: Bad received packet\n");
werror("SSL.connection: Bad received packet\n");
#endif
#endif
send_packet(packet);
send_packet(packet);
if (alert_callback)
alert_callback(packet, current_read_state->seq_num, alert_context);
if (packet->level == ALERT_fatal)
if (packet->level == ALERT_fatal)
return -1;
return -1;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment