/indra/newview/llsrv.cpp
C++ | 64 lines | 27 code | 8 blank | 29 comment | 2 complexity | 31f978bd9a1103b35ff42016a2a20136 MD5 | raw file
Possible License(s): LGPL-2.1
1/** 2 * @file llsrv.cpp 3 * @brief Wrapper for DNS SRV record lookups 4 * 5 * $LicenseInfo:firstyear=2007&license=viewerlgpl$ 6 * Second Life Viewer Source Code 7 * Copyright (C) 2010, Linden Research, Inc. 8 * 9 * This library is free software; you can redistribute it and/or 10 * modify it under the terms of the GNU Lesser General Public 11 * License as published by the Free Software Foundation; 12 * version 2.1 of the License only. 13 * 14 * This library is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * Lesser General Public License for more details. 18 * 19 * You should have received a copy of the GNU Lesser General Public 20 * License along with this library; if not, write to the Free Software 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 22 * 23 * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA 24 * $/LicenseInfo$ 25 */ 26 27#include "llviewerprecompiledheaders.h" 28 29#include "llsrv.h" 30#include "llares.h" 31 32struct Responder : public LLAres::UriRewriteResponder 33{ 34 std::vector<std::string> mUris; 35 void rewriteResult(const std::vector<std::string> &uris) { 36 for (size_t i = 0; i < uris.size(); i++) 37 { 38 llinfos << "[" << i << "] " << uris[i] << llendl; 39 } 40 mUris = uris; 41 } 42}; 43 44std::vector<std::string> LLSRV::rewriteURI(const std::string& uri) 45{ 46 LLPointer<Responder> resp = new Responder; 47 48 gAres->rewriteURI(uri, resp); 49 gAres->processAll(); 50 51 // It's been observed in deployment that c-ares can return control 52 // to us without firing all of our callbacks, in which case the 53 // returned vector will be empty, instead of a singleton as we 54 // might wish. 55 56 if (!resp->mUris.empty()) 57 { 58 return resp->mUris; 59 } 60 61 std::vector<std::string> uris; 62 uris.push_back(uri); 63 return uris; 64}