Roxen.git
/
server
/
plugins
/
protocols
/
prot_https.pike
version
»
Context lines:
10
20
40
80
file
none
3
Roxen.git/server/plugins/protocols/prot_https.pike:1:
// This is a ChiliMoon protocol module. // Copyright © 2001, Roxen IS.
-
// $Id: prot_https.pike,v 2.
10
2004/
04
/
04
14
:
24
:
53
mani Exp $
+
// $Id: prot_https.pike,v 2.
11
2004/
05
/
17
12
:
58
:
16
mani Exp $
// --- Debug defines --- #ifdef SSL3_DEBUG
-
# define SSL3_WERR(X) werror("SSL3: "
+X+"\n"
)
+
# define SSL3_WERR(X
...
) werror("SSL3: "
X
)
#else
-
# define SSL3_WERR(X)
+
# define SSL3_WERR(X
...
)
#endif inherit SSLProtocol; constant supports_ipless = 0; constant name = "https"; constant prot_name = "https"; constant requesthandlerfile = "plugins/protocols/http.pike"; constant default_port = 443;
Roxen.git/server/plugins/protocols/prot_https.pike:23:
class fallback_redirect_request { string in = ""; string out; string default_prefix; int port; Stdio.File f; void die() {
-
SSL3_WERR(
sprintf(
"fallback_redirect_request::die()")
)
;
+
SSL3_WERR("fallback_redirect_request::die()
\n
");
f->set_blocking(); f->close(); } void write_callback() {
-
SSL3_WERR(
sprintf(
"fallback_redirect_request::write_callback()")
)
;
+
SSL3_WERR("fallback_redirect_request::write_callback()
\n
");
int written = f->write(out); if (written <= 0) die(); else { out = out[written..]; if (!strlen(out)) die(); } } void read_callback(mixed ignored, string s) {
-
SSL3_WERR(
sprintf(
"fallback_redirect_request::read_callback(X, %O)\n", s)
)
;
+
SSL3_WERR("fallback_redirect_request::read_callback(X, %O)\n", s);
in += s; string name; string prefix; if (has_value(in, "\r\n\r\n")) { // werror("request = '%s'\n", in); array(string) lines = in / "\r\n"; array(string) req = replace(lines[0], "\t", " ") / " "; if (sizeof(req) < 2)
Roxen.git/server/plugins/protocols/prot_https.pike:102:
out = sprintf("HTTP/1.0 301 Redirect to secure server\r\n" "Location: %s%s\r\n\r\n", prefix, name); } f->set_read_callback(0); f->set_write_callback(write_callback); } } void create(Stdio.File socket, string s, string l, int p) {
-
SSL3_WERR(
sprintf(
"fallback_redirect_request(X, %O, %O, %O)", s, l||"CONFIG PORT", p)
)
;
+
SSL3_WERR("fallback_redirect_request(X, %O, %O, %O)
\n
", s, l||"CONFIG PORT", p);
f = socket; default_prefix = l; port = p; f->set_nonblocking(read_callback, 0, die); read_callback(f, s); } string _sprintf(int t) { return t=='O' && sprintf("fallback_redirect_request(%O)", f); } } class http_fallback { SSL.sslfile my_fd; void ssl_alert_callback(object alert, object|int n, string data) {
-
SSL3_WERR(
sprintf(
"http_fallback(X, %O, %O)", n, data)
)
;
+
SSL3_WERR("http_fallback(X, %O, %O)
\n
", n, data);
// trace(1); if ( (my_fd->query_connection()->current_write_state->seq_num == 0) && has_value(lower_case(data), "http")) { Stdio.File raw_fd = my_fd->shutdown(); /* Redirect to a https-url */ fallback_redirect_request(raw_fd, data, my_fd->config && my_fd->config->query("MyWorldLocation"), port); } } void ssl_accept_callback(mixed ignored) {
-
SSL3_WERR(
sprintf(
"ssl_accept_callback(X)")
)
;
+
SSL3_WERR("ssl_accept_callback(X)
\n
");
my_fd->set_alert_callback(0); /* Forget about http_fallback */ my_fd->set_accept_callback(0); my_fd = 0; /* Not needed any more */ } void create(SSL.sslfile fd) { my_fd = fd; fd->set_alert_callback(ssl_alert_callback); fd->set_accept_callback(ssl_accept_callback);