|
@@ -25,6 +25,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
25
|
25
|
|
26
|
26
|
#include <stdio.h>
|
27
|
27
|
#include <ipxe/http.h>
|
|
28
|
+#include <ipxe/settings.h>
|
28
|
29
|
#include <ipxe/peermux.h>
|
29
|
30
|
|
30
|
31
|
/** @file
|
|
@@ -35,6 +36,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
35
|
36
|
* misfortune to encounter, and I've encountered multicast TFTP.
|
36
|
37
|
*/
|
37
|
38
|
|
|
39
|
+/** PeerDist is globally enabled */
|
|
40
|
+static long peerdist_enabled = 1;
|
|
41
|
+
|
38
|
42
|
/**
|
39
|
43
|
* Check whether or not to support PeerDist encoding for this request
|
40
|
44
|
*
|
|
@@ -43,6 +47,10 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
43
|
47
|
*/
|
44
|
48
|
static int http_peerdist_supported ( struct http_transaction *http ) {
|
45
|
49
|
|
|
50
|
+ /* Allow PeerDist to be globally enabled/disabled */
|
|
51
|
+ if ( ! peerdist_enabled )
|
|
52
|
+ return 0;
|
|
53
|
+
|
46
|
54
|
/* Support PeerDist encoding only if we can directly access an
|
47
|
55
|
* underlying data transfer buffer. Direct access is required
|
48
|
56
|
* in order to support decryption of data received via the
|
|
@@ -143,3 +151,33 @@ struct http_content_encoding peerdist_encoding __http_content_encoding = {
|
143
|
151
|
.supported = http_peerdist_supported,
|
144
|
152
|
.init = http_peerdist_init,
|
145
|
153
|
};
|
|
154
|
+
|
|
155
|
+/** PeerDist enabled setting */
|
|
156
|
+const struct setting peerdist_setting __setting ( SETTING_MISC, peerdist ) = {
|
|
157
|
+ .name = "peerdist",
|
|
158
|
+ .description = "PeerDist enabled",
|
|
159
|
+ .type = &setting_type_int8,
|
|
160
|
+};
|
|
161
|
+
|
|
162
|
+/**
|
|
163
|
+ * Apply PeerDist settings
|
|
164
|
+ *
|
|
165
|
+ * @ret rc Return status code
|
|
166
|
+ */
|
|
167
|
+static int apply_peerdist_settings ( void ) {
|
|
168
|
+
|
|
169
|
+ /* Fetch global PeerDist enabled setting */
|
|
170
|
+ if ( fetch_int_setting ( NULL, &peerdist_setting,
|
|
171
|
+ &peerdist_enabled ) < 0 ) {
|
|
172
|
+ peerdist_enabled = 1;
|
|
173
|
+ }
|
|
174
|
+ DBGC ( &peerdist_enabled, "PEERDIST is %s\n",
|
|
175
|
+ ( peerdist_enabled ? "enabled" : "disabled" ) );
|
|
176
|
+
|
|
177
|
+ return 0;
|
|
178
|
+}
|
|
179
|
+
|
|
180
|
+/** PeerDist settings applicator */
|
|
181
|
+struct settings_applicator peerdist_applicator __settings_applicator = {
|
|
182
|
+ .apply = apply_peerdist_settings,
|
|
183
|
+};
|