/** * @brief Initiates a SOCKS 5 proxy session. * * Performs basic checks on host to verify that it is a valid address. Opens the control channel * and then negotiates the proxy connection with the server. Closes any existing SOCKS * connection before proceeding. Also disables an HTTP proxy if it is using SOCKS as the proxy. * * * @param host Socks server to connect to. * @return SOCKS_OK if successful, otherwise a SOCKS error code defined in llproxy.h. */ S32 LLProxy::startSOCKSProxy(LLHost host) { if (host.isOk()) { mTCPProxy = host; } else { return SOCKS_INVALID_HOST; } // Close any running SOCKS connection. stopSOCKSProxy(); mProxyControlChannel = tcp_open_channel(mTCPProxy); if (!mProxyControlChannel) { return SOCKS_HOST_CONNECT_FAILED; } S32 status = proxyHandshake(mTCPProxy); if (status != SOCKS_OK) { // Shut down the proxy if any of the above steps failed. stopSOCKSProxy(); } else { // Connection was successful. sUDPProxyEnabled = true; } return status; }
/** * @brief Enable the HTTP proxy for either SOCKS or HTTP. * * Check the supplied host to see if it is a valid IP and port. * * @param httpHost Proxy server to connect to. * @param type Is the host a SOCKS or HTTP proxy. * @return Return true if applying the setting was successful. No changes are made if false. */ bool LLProxy::enableHTTPProxy(LLHost httpHost, LLHttpProxyType type) { if (!httpHost.isOk()) { LL_WARNS("Proxy") << "Invalid SOCKS 5 Server" << LL_ENDL; return false; } LLMutexLock lock(&mProxyMutex); mHTTPProxy = httpHost; mProxyType = type; mHTTPProxyEnabled = true; return true; }
void LLAssetStorage::getInvItemAsset(const LLHost &object_sim, const LLUUID &agent_id, const LLUUID &session_id, const LLUUID &owner_id, const LLUUID &task_id, const LLUUID &item_id, const LLUUID &asset_id, LLAssetType::EType atype, LLGetAssetCallback callback, void *user_data, BOOL is_priority) { lldebugs << "LLAssetStorage::getInvItemAsset() - " << asset_id << "," << LLAssetType::lookup(atype) << llendl; // // Probably will get rid of this early out? // //if (asset_id.isNull()) //{ // // Special case early out for NULL uuid // if (callback) // { // callback(mVFS, asset_id, atype, user_data, LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE); // } // return; //} bool exists = false; U32 size = 0; if(asset_id.notNull()) { exists = mVFS->getExists(asset_id, atype); LLVFile file(mVFS, asset_id, atype); size = exists ? file.getSize() : 0; if(exists && size < 1) { llwarns << "Asset vfile " << asset_id << ":" << atype << " found with bad size " << file.getSize() << ", removing" << llendl; file.remove(); } } if (size < 1) { // See whether we should talk to the object's originating sim, // or the upstream provider. LLHost source_host; if (object_sim.isOk()) { source_host = object_sim; } else { source_host = mUpstreamHost; } if (source_host.isOk()) { // stash the callback info so we can find it after we get the response message LLInvItemRequest *req = new LLInvItemRequest(asset_id, atype); req->mDownCallback = callback; req->mUserData = user_data; req->mIsPriority = is_priority; // send request message to our upstream data provider // Create a new asset transfer. LLTransferSourceParamsInvItem spi; spi.setAgentSession(agent_id, session_id); spi.setInvItem(owner_id, task_id, item_id); spi.setAsset(asset_id, atype); // Set our destination file, and the completion callback. LLTransferTargetParamsVFile tpvf; tpvf.setAsset(asset_id, atype); tpvf.setCallback(downloadInvItemCompleteCallback, req); llinfos << "Starting transfer for inventory asset " << item_id << " owned by " << owner_id << "," << task_id << llendl; LLTransferTargetChannel *ttcp = gTransferManager.getTargetChannel(source_host, LLTCT_ASSET); ttcp->requestTransfer(spi, tpvf, 100.f + (is_priority ? 1.f : 0.f)); } else { // uh-oh, we shouldn't have gotten here llwarns << "Attempt to move asset data request upstream w/o valid upstream provider" << llendl; if (callback) { callback(mVFS, asset_id, atype, user_data, LL_ERR_CIRCUIT_GONE, LL_EXSTAT_NO_UPSTREAM); } } } else { // we've already got the file // theoretically, partial files w/o a pending request shouldn't happen // unless there's a weird error if (callback) { callback(mVFS, asset_id, atype, user_data, LL_ERR_NOERR, LL_EXSTAT_VFS_CACHED); } } }
void host_object::test<1>() { LLHost host; ensure("IP address is not NULL", (0 == host.getAddress()) && (0 == host.getPort()) && !host.isOk()); }
void LLAssetStorage::getEstateAsset(const LLHost &object_sim, const LLUUID &agent_id, const LLUUID &session_id, const LLUUID &asset_id, LLAssetType::EType atype, EstateAssetType etype, LLGetAssetCallback callback, void *user_data, BOOL is_priority) { LL_DEBUGS() << "LLAssetStorage::getEstateAsset() - " << asset_id << "," << LLAssetType::lookup(atype) << ", estatetype " << etype << LL_ENDL; // // Probably will get rid of this early out? // if (asset_id.isNull()) { // Special case early out for NULL uuid if (callback) { callback(mVFS, asset_id, atype, user_data, LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE, LL_EXSTAT_NULL_UUID); } return; } // Try static VFS first. if (findInStaticVFSAndInvokeCallback(asset_id,atype,callback,user_data)) { return; } BOOL exists = mVFS->getExists(asset_id, atype); LLVFile file(mVFS, asset_id, atype); U32 size = exists ? file.getSize() : 0; if (size > 0) { // we've already got the file // theoretically, partial files w/o a pending request shouldn't happen // unless there's a weird error if (callback) { callback(mVFS, asset_id, atype, user_data, LL_ERR_NOERR, LL_EXSTAT_VFS_CACHED); } } else { if (exists) { LL_WARNS() << "Asset vfile " << asset_id << ":" << atype << " found with bad size " << file.getSize() << ", removing" << LL_ENDL; file.remove(); } // See whether we should talk to the object's originating sim, or the upstream provider. LLHost source_host; if (object_sim.isOk()) { source_host = object_sim; } else { source_host = mUpstreamHost; } if (source_host.isOk()) { // stash the callback info so we can find it after we get the response message LLEstateAssetRequest *req = new LLEstateAssetRequest(asset_id, atype, etype); req->mDownCallback = callback; req->mUserData = user_data; req->mIsPriority = is_priority; // send request message to our upstream data provider // Create a new asset transfer. LLTransferSourceParamsEstate spe; spe.setAgentSession(agent_id, session_id); spe.setEstateAssetType(etype); // Set our destination file, and the completion callback. LLTransferTargetParamsVFile tpvf; tpvf.setAsset(asset_id, atype); tpvf.setCallback(downloadEstateAssetCompleteCallback, req); LL_DEBUGS("AssetStorage") << "Starting transfer for " << asset_id << LL_ENDL; LLTransferTargetChannel *ttcp = gTransferManager.getTargetChannel(source_host, LLTCT_ASSET); ttcp->requestTransfer(spe, tpvf, 100.f + (is_priority ? 1.f : 0.f)); } else { // uh-oh, we shouldn't have gotten here LL_WARNS() << "Attempt to move asset data request upstream w/o valid upstream provider" << LL_ENDL; if (callback) { callback(mVFS, asset_id, atype, user_data, LL_ERR_CIRCUIT_GONE, LL_EXSTAT_NO_UPSTREAM); } } } }