예제 #1
0
파일: app.cpp 프로젝트: sunwill/pushpin
    void doProxy(RequestSession *rs, const InspectData *idata = 0)
    {
        ProxySession *ps = 0;
        if(idata && !idata->sharingKey.isEmpty())
        {
            log_info("need to proxy with sharing key: %s", idata->sharingKey.data());

            ProxyItem *i = proxyItemsByKey.value(idata->sharingKey);
            if(i)
                ps = i->ps;
        }

        if(!ps)
        {
            log_info("creating proxysession");

            ps = new ProxySession(zurl, domainMap, this);
            connect(ps, SIGNAL(addNotAllowed()), SLOT(ps_addNotAllowed()));
            connect(ps, SIGNAL(finishedByPassthrough()), SLOT(ps_finishedByPassthrough()));
            connect(ps, SIGNAL(finishedForAccept(const AcceptData &)), SLOT(ps_finishedForAccept(const AcceptData &)));
            connect(ps, SIGNAL(requestSessionDestroyed(RequestSession *)), SLOT(ps_requestSessionDestroyed(RequestSession *)));

            if(idata)
                ps->setInspectData(*idata);

            ProxyItem *i = new ProxyItem;
            i->ps = ps;
            proxyItemsBySession.insert(i->ps, i);

            if(idata && !idata->sharingKey.isEmpty())
            {
                i->shared = true;
                i->key = idata->sharingKey;
                proxyItemsByKey.insert(i->key, i);
            }
        }
        else
            log_info("reusing proxysession");

        // proxysession will take it from here
        rs->disconnect(this);

        ps->add(rs);
    }
예제 #2
0
파일: engine.cpp 프로젝트: nicklv/pushpin
	void doProxy(RequestSession *rs, const InspectData *idata = 0, bool isRetry = false)
	{
		DomainMap::Entry route = rs->route();

		// we'll always have a route
		assert(!route.isNull());

		bool sharable = (idata && !idata->sharingKey.isEmpty() && rs->haveCompleteRequestBody());

		ProxySession *ps = 0;
		if(sharable)
		{
			log_debug("need to proxy with sharing key: %s", idata->sharingKey.data());

			ProxyItem *i = proxyItemsByKey.value(idata->sharingKey);
			if(i)
				ps = i->ps;
		}

		if(!ps)
		{
			log_debug("creating proxysession for id=%s", rs->rid().second.data());

			ps = new ProxySession(zroutes, accept, this);
			connect(ps, SIGNAL(addNotAllowed()), SLOT(ps_addNotAllowed()));
			connect(ps, SIGNAL(finished()), SLOT(ps_finished()));
			connect(ps, SIGNAL(requestSessionDestroyed(RequestSession *, bool)), SLOT(ps_requestSessionDestroyed(RequestSession *, bool)));

			ps->setRoute(route);
			ps->setDefaultSigKey(config.sigIss, config.sigKey);
			ps->setDefaultUpstreamKey(config.upstreamKey);
			ps->setUseXForwardedProtocol(config.useXForwardedProtocol);
			ps->setXffRules(config.xffUntrustedRule, config.xffTrustedRule);
			ps->setOrigHeadersNeedMark(config.origHeadersNeedMark);

			if(idata)
				ps->setInspectData(*idata);

			ProxyItem *i = new ProxyItem;
			i->ps = ps;
			proxyItemsBySession.insert(i->ps, i);

			if(sharable)
			{
				i->shared = true;
				i->key = idata->sharingKey;
				proxyItemsByKey.insert(i->key, i);
			}
		}
		else
			log_debug("reusing proxysession");

		// proxysession will take it from here
		rs->disconnect(this);

		ps->add(rs);

		if(stats)
		{
			stats->addConnection(ridToString(rs->rid()), route.id, StatsManager::Http, rs->peerAddress(), rs->isHttps(), isRetry);
			stats->addActivity(route.id);
		}
	}