mirror of https://github.com/ipxe/ipxe.git
[peerdist] Allow PeerDist to be globally enabled or disabled
Allow the use of PeerDist content encoding to be enabled or disabled via the ${peerdist} setting, e.g.: # Disable PeerDist set peerdist 0 Signed-off-by: Michael Brown <mcb30@ipxe.org>pull/99/head
parent
3fe683ebab
commit
53af9905e0
|
@ -25,6 +25,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
|||
|
||||
#include <stdio.h>
|
||||
#include <ipxe/http.h>
|
||||
#include <ipxe/settings.h>
|
||||
#include <ipxe/peermux.h>
|
||||
|
||||
/** @file
|
||||
|
@ -35,6 +36,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
|||
* misfortune to encounter, and I've encountered multicast TFTP.
|
||||
*/
|
||||
|
||||
/** PeerDist is globally enabled */
|
||||
static long peerdist_enabled = 1;
|
||||
|
||||
/**
|
||||
* Check whether or not to support PeerDist encoding for this request
|
||||
*
|
||||
|
@ -43,6 +47,10 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
|||
*/
|
||||
static int http_peerdist_supported ( struct http_transaction *http ) {
|
||||
|
||||
/* Allow PeerDist to be globally enabled/disabled */
|
||||
if ( ! peerdist_enabled )
|
||||
return 0;
|
||||
|
||||
/* Support PeerDist encoding only if we can directly access an
|
||||
* underlying data transfer buffer. Direct access is required
|
||||
* in order to support decryption of data received via the
|
||||
|
@ -143,3 +151,33 @@ struct http_content_encoding peerdist_encoding __http_content_encoding = {
|
|||
.supported = http_peerdist_supported,
|
||||
.init = http_peerdist_init,
|
||||
};
|
||||
|
||||
/** PeerDist enabled setting */
|
||||
const struct setting peerdist_setting __setting ( SETTING_MISC, peerdist ) = {
|
||||
.name = "peerdist",
|
||||
.description = "PeerDist enabled",
|
||||
.type = &setting_type_int8,
|
||||
};
|
||||
|
||||
/**
|
||||
* Apply PeerDist settings
|
||||
*
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
static int apply_peerdist_settings ( void ) {
|
||||
|
||||
/* Fetch global PeerDist enabled setting */
|
||||
if ( fetch_int_setting ( NULL, &peerdist_setting,
|
||||
&peerdist_enabled ) < 0 ) {
|
||||
peerdist_enabled = 1;
|
||||
}
|
||||
DBGC ( &peerdist_enabled, "PEERDIST is %s\n",
|
||||
( peerdist_enabled ? "enabled" : "disabled" ) );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** PeerDist settings applicator */
|
||||
struct settings_applicator peerdist_applicator __settings_applicator = {
|
||||
.apply = apply_peerdist_settings,
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue