1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
var rfc = function() {
var ports = [];
var step = 0;
var steps = {
/* Grab list of servers */
1: function() {
$.jsonp({
url: "servers?callback=?",
success: function(data) {
ports = data.servers;
for (var i = 0; i < ports.length; i++) {
var el = $("#ports")
if (i > 0) el.append(", ");
$("<a href='https://"
+ location.hostname +":"
+ ports[i] + "'>"
+ ports[i] + "</a>").appendTo(el);
}
/* Setup the start button */
$("#start").click(function() {
nextstep();
});
nextstep();
},
error: error
});
},
/* Get cipher */
3: function() {
$.jsonp({
url: "session?callback=?",
success: function(data) {
var cipher = data.cipher;
var version = data.version
$("#cipher").text(cipher);
$("#version").text(version);
nextstep();
},
error: error
});
},
/* Session ID without cache nor tickets */
4: function() {
checksessionid(ports[0], function(same) {
var wotickets = same;
$("#resume1").text(wotickets?"does":"does not");
nextstep();
});
},
/* Session ID without tickets */
5: function() {
checksessionid(ports[1], function(same) {
var wotickets = same;
$("#resume2").text(wotickets?"does":"does not");
nextstep();
});
},
/* Session ID with tickets */
6: function() {
checksessionid(ports[3], function(same) {
var wtickets = same;
$("#resume3").text(wtickets?"does":"does not");
nextstep();
});
},
/* Session ID with both cache and tickets */
7: function() {
checksessionid(ports[2], function(same) {
var wtickets = same;
$("#resume4").text(wtickets?"does":"does not");
nextstep();
});
}
};
function nextstep() {
$(".step" + step)
.filter(".running")
.removeClass("current")
.hide();
$(".step" + step)
.filter(".done").fadeIn();
step = step + 1;
$(".step" + step)
.filter(".running")
.addClass("current")
.fadeIn(200, function() {
$('html, body')
.stop()
.animate({scrollTop: $('body').height()},
800);
});
if (steps[step] !== undefined)
setTimeout(steps[step], 200);
}
function error() {
$(".error").fadeIn(200);
}
function checksessionid(port, cb) {
/* Ask for /session several time and check that session ID are
* still the same */
var tries = 4; var errtries = 2;
var sessions = [];
var url = "https://"
+ location.hostname
+ ":" + port
+ "/session";
var dotry = function() {
$.jsonp({
url: url + "?callback=?",
success: function(data) {
sessions.push(data.sessionid);
tries = tries - 1;
if (tries === 0) {
/* Check if session ID are the same */
/* Skip the first result. This may be empty or
* an old session. */
for (var i=2; i < sessions.length; i++) {
if (sessions[i] !== sessions[1]) {
cb(false);
return;
}
}
/* Maybe there is no session at all */
cb(sessions[1] !== '');
} else dotry();
},
error: function() {
/* Because of some obscure bug in Internet
Explorer SSL handshake may fail the first time
we request something on server without cache
and with tickets. */
errtries -= 1;
if (errtries > 0) dotry()
else error();
}
});
};
dotry();
}
$(function() {
/* Fill navigator name */
$("#ua").text(navigator.userAgent);
nextstep();
});
}();
|