Пример #1
0
int HotlinkCtrl::config(const XmlNode *pNode)
{
    if (setSuffixes(pNode->getChildValue("suffixes")) <= 0)
    {
        LS_ERROR(ConfigCtx::getCurConfigCtx(),
                 "no suffix is configured, disable hotlink protection.");
        return LS_FAIL;
    }

    setDirectAccess(ConfigCtx::getCurConfigCtx()->getLongValue(pNode,
                    "allowDirectAccess", 0, 1, 0));
    const char *pRedirect = pNode->getChildValue("redirectUri");

    if (pRedirect)
        setRedirect(pRedirect);

    int self = ConfigCtx::getCurConfigCtx()->getLongValue(pNode, "onlySelf", 0,
               1, 0);

    if (!self)
    {
        char achBuf[4096];
        const char *pValue = pNode->getChildValue("allowedHosts");

        if (pValue)
        {
            ConfigCtx::getCurConfigCtx()->expandDomainNames(pValue, achBuf, 4096, ',');
            pValue = achBuf;
        }

        int ret = setHosts(pValue);
        int ret2 = setRegex(pNode->getChildValue("matchedHosts"));

        if ((ret <= 0) &&
            (ret2 < 0))
        {
            LS_WARN(ConfigCtx::getCurConfigCtx(),
                    "no valid host is configured, only self"
                    " reference is allowed.");
            self = 1;
        }
    }
    setOnlySelf(self);
    return 0;
}
Пример #2
0
static bool buildOptions(FetchRequest::InternalRequest& request, ScriptExecutionContext& context, const Dictionary& init)
{
    JSC::JSValue window;
    if (init.get("window", window)) {
        if (!window.isNull())
            return false;
    }

    if (!setReferrer(request, context, init))
        return false;

    String value;
    if (init.get("referrerPolicy", value) && !setReferrerPolicy(request.options, value))
        return false;

    if (init.get("mode", value) && !setMode(request.options, value))
        return false;
    if (request.options.mode() == FetchOptions::Mode::Navigate)
        return false;

    if (init.get("credentials", value) && !setCredentials(request.options, value))
        return false;

    if (init.get("cache", value) && !setCache(request.options, value))
        return false;

    if (init.get("redirect", value) && !setRedirect(request.options, value))
        return false;

    init.get("integrity", request.integrity);

    if (init.get("method", value) && !setMethod(request.request, value))
        return false;

    return true;
}