aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmessage/lltrustedmessageservice.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llmessage/lltrustedmessageservice.cpp')
-rw-r--r--linden/indra/llmessage/lltrustedmessageservice.cpp90
1 files changed, 90 insertions, 0 deletions
diff --git a/linden/indra/llmessage/lltrustedmessageservice.cpp b/linden/indra/llmessage/lltrustedmessageservice.cpp
new file mode 100644
index 0000000..505ece5
--- /dev/null
+++ b/linden/indra/llmessage/lltrustedmessageservice.cpp
@@ -0,0 +1,90 @@
1/**
2 * @file lltrustedmessageservice.cpp
3 * @brief LLTrustedMessageService implementation
4 *
5 * $LicenseInfo:firstyear=2009&license=viewergpl$
6 *
7 * Copyright (c) 2009, Linden Research, Inc.
8 *
9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab
11 * to you under the terms of the GNU General Public License, version 2.0
12 * ("GPL"), unless you have obtained a separate licensing agreement
13 * ("Other License"), formally executed by you and Linden Lab. Terms of
14 * the GPL can be found in doc/GPL-license.txt in this distribution, or
15 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
16 *
17 * There are special exceptions to the terms and conditions of the GPL as
18 * it is applied to this Source Code. View the full text of the exception
19 * in the file doc/FLOSS-exception.txt in this software distribution, or
20 * online at
21 * http://secondlifegrid.net/programs/open_source/licensing/flossexception
22 *
23 * By copying, modifying or distributing this software, you acknowledge
24 * that you have read and understood your obligations described above,
25 * and agree to abide by those obligations.
26 *
27 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
28 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
29 * COMPLETENESS OR PERFORMANCE.
30 * $/LicenseInfo$
31 */
32
33#include "linden_common.h"
34
35#include "lltrustedmessageservice.h"
36#include "llhost.h"
37#include "llmessageconfig.h"
38#include "message.h"
39
40
41bool LLTrustedMessageService::validate(const std::string& name, LLSD& context)
42const
43{
44 return true;
45}
46
47void LLTrustedMessageService::post(LLHTTPNode::ResponsePtr response,
48 const LLSD& context,
49 const LLSD& input) const
50{
51 std::string name = context["request"]["wildcard"]["message-name"];
52 std::string senderIP = context["request"]["remote-host"];
53 std::string senderPort = context["request"]["headers"]
54 ["x-secondlife-udp-listen-port"];
55
56 LLSD message_data;
57 std::string sender = senderIP + ":" + senderPort;
58 message_data["sender"] = sender;
59 message_data["body"] = input;
60
61 // untrusted senders should not have access to the trusted message
62 // service, but this can happen in development, so check and warn
63 LLMessageConfig::SenderTrust trust =
64 LLMessageConfig::getSenderTrustedness(name);
65 if ((trust == LLMessageConfig::TRUSTED ||
66 (trust == LLMessageConfig::NOT_SET &&
67 gMessageSystem->isTrustedMessage(name)))
68 && !gMessageSystem->isTrustedSender(LLHost(sender)))
69 {
70 LL_WARNS("Messaging") << "trusted message POST to /trusted-message/"
71 << name << " from unknown or untrusted sender "
72 << sender << llendl;
73 response->status(403, "Unknown or untrusted sender");
74 }
75 else
76 {
77 gMessageSystem->receivedMessageFromTrustedSender();
78 if (input.has("binary-template-data"))
79 {
80 llinfos << "Dispatching template: " << input << llendl;
81 // try and send this message using udp dispatch
82 LLMessageSystem::dispatchTemplate(name, message_data, response);
83 }
84 else
85 {
86 llinfos << "Dispatching without template: " << input << llendl;
87 LLMessageSystem::dispatch(name, message_data, response);
88 }
89 }
90}