diff options
Diffstat (limited to 'linden/indra/llmessage/message.cpp')
-rw-r--r-- | linden/indra/llmessage/message.cpp | 383 |
1 files changed, 197 insertions, 186 deletions
diff --git a/linden/indra/llmessage/message.cpp b/linden/indra/llmessage/message.cpp index ccc3d79..78af35b 100644 --- a/linden/indra/llmessage/message.cpp +++ b/linden/indra/llmessage/message.cpp | |||
@@ -17,7 +17,8 @@ | |||
17 | * There are special exceptions to the terms and conditions of the GPL as | 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 | 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 | 19 | * in the file doc/FLOSS-exception.txt in this software distribution, or |
20 | * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception | 20 | * online at |
21 | * http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
21 | * | 22 | * |
22 | * By copying, modifying or distributing this software, you acknowledge | 23 | * By copying, modifying or distributing this software, you acknowledge |
23 | * that you have read and understood your obligations described above, | 24 | * that you have read and understood your obligations described above, |
@@ -58,13 +59,16 @@ | |||
58 | #include "llerrorlegacy.h" | 59 | #include "llerrorlegacy.h" |
59 | #include "llfasttimer.h" | 60 | #include "llfasttimer.h" |
60 | #include "llhttpclient.h" | 61 | #include "llhttpclient.h" |
62 | #include "llhttpnodeadapter.h" | ||
61 | #include "llhttpsender.h" | 63 | #include "llhttpsender.h" |
62 | #include "llmd5.h" | 64 | #include "llmd5.h" |
63 | #include "llmessagebuilder.h" | 65 | #include "llmessagebuilder.h" |
64 | #include "llmessageconfig.h" | 66 | #include "llmessageconfig.h" |
67 | #include "lltemplatemessagedispatcher.h" | ||
65 | #include "llpumpio.h" | 68 | #include "llpumpio.h" |
66 | #include "lltemplatemessagebuilder.h" | 69 | #include "lltemplatemessagebuilder.h" |
67 | #include "lltemplatemessagereader.h" | 70 | #include "lltemplatemessagereader.h" |
71 | #include "lltrustedmessageservice.h" | ||
68 | #include "llmessagetemplate.h" | 72 | #include "llmessagetemplate.h" |
69 | #include "llmessagetemplateparser.h" | 73 | #include "llmessagetemplateparser.h" |
70 | #include "llsd.h" | 74 | #include "llsd.h" |
@@ -141,52 +145,6 @@ namespace | |||
141 | }; | 145 | }; |
142 | } | 146 | } |
143 | 147 | ||
144 | |||
145 | class LLTrustedMessageService : public LLHTTPNode | ||
146 | { | ||
147 | virtual bool validate(const std::string& name, LLSD& context) const | ||
148 | { return true; } | ||
149 | |||
150 | virtual void post(LLHTTPNode::ResponsePtr response, | ||
151 | const LLSD& context, | ||
152 | const LLSD& input) const; | ||
153 | }; | ||
154 | |||
155 | //virtual | ||
156 | void LLTrustedMessageService::post(LLHTTPNode::ResponsePtr response, | ||
157 | const LLSD& context, | ||
158 | const LLSD& input) const | ||
159 | { | ||
160 | std::string name = context["request"]["wildcard"]["message-name"]; | ||
161 | std::string senderIP = context["request"]["remote-host"]; | ||
162 | std::string senderPort = context["request"]["headers"] | ||
163 | ["x-secondlife-udp-listen-port"]; | ||
164 | |||
165 | LLSD message_data; | ||
166 | std::string sender = senderIP + ":" + senderPort; | ||
167 | message_data["sender"] = sender; | ||
168 | message_data["body"] = input; | ||
169 | |||
170 | // untrusted senders should not have access to the trusted message | ||
171 | // service, but this can happen in development, so check and warn | ||
172 | LLMessageConfig::SenderTrust trust = | ||
173 | LLMessageConfig::getSenderTrustedness(name); | ||
174 | if ((trust == LLMessageConfig::TRUSTED || | ||
175 | (trust == LLMessageConfig::NOT_SET && | ||
176 | gMessageSystem->isTrustedMessage(name))) | ||
177 | && !gMessageSystem->isTrustedSender(LLHost(sender))) | ||
178 | { | ||
179 | LL_WARNS("Messaging") << "trusted message POST to /trusted-message/" | ||
180 | << name << " from unknown or untrusted sender " | ||
181 | << sender << llendl; | ||
182 | response->status(403, "Unknown or untrusted sender"); | ||
183 | } | ||
184 | else | ||
185 | { | ||
186 | LLMessageSystem::dispatch(name, message_data, response); | ||
187 | } | ||
188 | } | ||
189 | |||
190 | class LLMessageHandlerBridge : public LLHTTPNode | 148 | class LLMessageHandlerBridge : public LLHTTPNode |
191 | { | 149 | { |
192 | virtual bool validate(const std::string& name, LLSD& context) const | 150 | virtual bool validate(const std::string& name, LLSD& context) const |
@@ -222,9 +180,6 @@ void LLMessageHandlerBridge::post(LLHTTPNode::ResponsePtr response, | |||
222 | LLHTTPRegistration<LLMessageHandlerBridge> | 180 | LLHTTPRegistration<LLMessageHandlerBridge> |
223 | gHTTPRegistrationMessageWildcard("/message/<message-name>"); | 181 | gHTTPRegistrationMessageWildcard("/message/<message-name>"); |
224 | 182 | ||
225 | LLHTTPRegistration<LLTrustedMessageService> | ||
226 | gHTTPRegistrationTrustedMessageWildcard("/trusted-message/<message-name>"); | ||
227 | |||
228 | //virtual | 183 | //virtual |
229 | LLUseCircuitCodeResponder::~LLUseCircuitCodeResponder() | 184 | LLUseCircuitCodeResponder::~LLUseCircuitCodeResponder() |
230 | { | 185 | { |
@@ -290,7 +245,10 @@ LLMessageSystem::LLMessageSystem(const std::string& filename, U32 port, | |||
290 | S32 version_major, | 245 | S32 version_major, |
291 | S32 version_minor, | 246 | S32 version_minor, |
292 | S32 version_patch, | 247 | S32 version_patch, |
293 | bool failure_is_fatal) | 248 | bool failure_is_fatal, |
249 | const F32 circuit_heartbeat_interval, const F32 circuit_timeout) : | ||
250 | mCircuitInfo(circuit_heartbeat_interval, circuit_timeout), | ||
251 | mLastMessageFromTrustedMessageService(false) | ||
294 | { | 252 | { |
295 | init(); | 253 | init(); |
296 | 254 | ||
@@ -303,6 +261,9 @@ LLMessageSystem::LLMessageSystem(const std::string& filename, U32 port, | |||
303 | // default to not accepting packets from not alive circuits | 261 | // default to not accepting packets from not alive circuits |
304 | mbProtected = TRUE; | 262 | mbProtected = TRUE; |
305 | 263 | ||
264 | // default to blocking trusted connections on a public interface if one is specified | ||
265 | mBlockUntrustedInterface = true; | ||
266 | |||
306 | mSendPacketFailureCount = 0; | 267 | mSendPacketFailureCount = 0; |
307 | 268 | ||
308 | mCircuitPrintFreq = 60.f; // seconds | 269 | mCircuitPrintFreq = 60.f; // seconds |
@@ -437,7 +398,9 @@ void LLMessageSystem::clearReceiveState() | |||
437 | mCurrentRecvPacketID = 0; | 398 | mCurrentRecvPacketID = 0; |
438 | mIncomingCompressedSize = 0; | 399 | mIncomingCompressedSize = 0; |
439 | mLastSender.invalidate(); | 400 | mLastSender.invalidate(); |
401 | mLastReceivingIF.invalidate(); | ||
440 | mMessageReader->clearMessage(); | 402 | mMessageReader->clearMessage(); |
403 | mLastMessageFromTrustedMessageService = false; | ||
441 | } | 404 | } |
442 | 405 | ||
443 | 406 | ||
@@ -470,6 +433,17 @@ bool LLMessageSystem::isTrustedSender(const LLHost& host) const | |||
470 | return cdp->getTrusted(); | 433 | return cdp->getTrusted(); |
471 | } | 434 | } |
472 | 435 | ||
436 | void LLMessageSystem::receivedMessageFromTrustedSender() | ||
437 | { | ||
438 | mLastMessageFromTrustedMessageService = true; | ||
439 | } | ||
440 | |||
441 | bool LLMessageSystem::isTrustedSender() const | ||
442 | { | ||
443 | return mLastMessageFromTrustedMessageService || | ||
444 | isTrustedSender(getSender()); | ||
445 | } | ||
446 | |||
473 | static LLMessageSystem::message_template_name_map_t::const_iterator | 447 | static LLMessageSystem::message_template_name_map_t::const_iterator |
474 | findTemplate(const LLMessageSystem::message_template_name_map_t& templates, | 448 | findTemplate(const LLMessageSystem::message_template_name_map_t& templates, |
475 | std::string name) | 449 | std::string name) |
@@ -586,6 +560,7 @@ BOOL LLMessageSystem::checkMessages( S64 frame_count ) | |||
586 | 560 | ||
587 | receive_size = mTrueReceiveSize; | 561 | receive_size = mTrueReceiveSize; |
588 | mLastSender = mPacketRing.getLastSender(); | 562 | mLastSender = mPacketRing.getLastSender(); |
563 | mLastReceivingIF = mPacketRing.getLastReceivingInterface(); | ||
589 | 564 | ||
590 | if (receive_size < (S32) LL_MINIMUM_VALID_PACKET_SIZE) | 565 | if (receive_size < (S32) LL_MINIMUM_VALID_PACKET_SIZE) |
591 | { | 566 | { |
@@ -709,11 +684,16 @@ BOOL LLMessageSystem::checkMessages( S64 frame_count ) | |||
709 | // UseCircuitCode can be a valid, off-circuit packet. | 684 | // UseCircuitCode can be a valid, off-circuit packet. |
710 | // But we don't want to acknowledge UseCircuitCode until the circuit is | 685 | // But we don't want to acknowledge UseCircuitCode until the circuit is |
711 | // available, which is why the acknowledgement test is done above. JC | 686 | // available, which is why the acknowledgement test is done above. JC |
712 | 687 | bool trusted = cdp && cdp->getTrusted(); | |
713 | valid_packet = mTemplateMessageReader->validateMessage( | 688 | valid_packet = mTemplateMessageReader->validateMessage( |
714 | buffer, | 689 | buffer, |
715 | receive_size, | 690 | receive_size, |
716 | host); | 691 | host, |
692 | trusted); | ||
693 | if (!valid_packet) | ||
694 | { | ||
695 | clearReceiveState(); | ||
696 | } | ||
717 | 697 | ||
718 | // UseCircuitCode is allowed in even from an invalid circuit, so that | 698 | // UseCircuitCode is allowed in even from an invalid circuit, so that |
719 | // we can toss circuits around. | 699 | // we can toss circuits around. |
@@ -741,29 +721,6 @@ BOOL LLMessageSystem::checkMessages( S64 frame_count ) | |||
741 | valid_packet = FALSE; | 721 | valid_packet = FALSE; |
742 | } | 722 | } |
743 | 723 | ||
744 | if ( | ||
745 | valid_packet && | ||
746 | mTemplateMessageReader->isBanned(cdp && cdp->getTrusted())) | ||
747 | { | ||
748 | LL_WARNS("Messaging") << "LLMessageSystem::checkMessages " | ||
749 | << "received banned message " | ||
750 | << mTemplateMessageReader->getMessageName() | ||
751 | << " from " | ||
752 | << ((cdp && cdp->getTrusted()) ? "trusted " : "untrusted ") | ||
753 | << host << llendl; | ||
754 | clearReceiveState(); | ||
755 | valid_packet = FALSE; | ||
756 | } | ||
757 | |||
758 | if( valid_packet && mTemplateMessageReader->isUdpBanned()) | ||
759 | { | ||
760 | llwarns << "Received UDP black listed message " | ||
761 | << mTemplateMessageReader->getMessageName() | ||
762 | << " from " << host << llendl; | ||
763 | clearReceiveState(); | ||
764 | valid_packet = FALSE; | ||
765 | } | ||
766 | |||
767 | if( valid_packet ) | 724 | if( valid_packet ) |
768 | { | 725 | { |
769 | logValidMsg(cdp, host, recv_reliable, recv_resent, (BOOL)(acks>0) ); | 726 | logValidMsg(cdp, host, recv_reliable, recv_resent, (BOOL)(acks>0) ); |
@@ -776,94 +733,6 @@ BOOL LLMessageSystem::checkMessages( S64 frame_count ) | |||
776 | 733 | ||
777 | if (valid_packet) | 734 | if (valid_packet) |
778 | { | 735 | { |
779 | // enable this for output of message names | ||
780 | //LL_INFOS("Messaging") << "< \"" << mTemplateMessageReader->getMessageName() | ||
781 | //<< "\"" << llendl; | ||
782 | |||
783 | /* Code for dumping the complete contents of a message. Keep for future use in optimizing messages. | ||
784 | if( 1 ) | ||
785 | { | ||
786 | static char* object_update = LLMessageStringTable::getInstance()->getString("ObjectUpdate"); | ||
787 | if(object_update == mTemplateMessageReader->getMessageName() ) | ||
788 | { | ||
789 | LL_INFOS("Messaging") << "ObjectUpdate:" << llendl; | ||
790 | U32 i; | ||
791 | LL_INFOS("Messaging") << " Zero Encoded: " << zero_unexpanded_size << llendl; | ||
792 | for( i = 0; i<zero_unexpanded_size; i++ ) | ||
793 | { | ||
794 | LL_INFOS("Messaging") << " " << i << ": " << (U32) zero_unexpanded_buffer[i] << llendl; | ||
795 | } | ||
796 | LL_INFOS("Messaging") << "" << llendl; | ||
797 | |||
798 | LL_INFOS("Messaging") << " Zero Unencoded: " << receive_size << llendl; | ||
799 | for( i = 0; i<receive_size; i++ ) | ||
800 | { | ||
801 | LL_INFOS("Messaging") << " " << i << ": " << (U32) buffer[i] << llendl; | ||
802 | } | ||
803 | LL_INFOS("Messaging") << "" << llendl; | ||
804 | |||
805 | LL_INFOS("Messaging") << " Blocks and variables: " << llendl; | ||
806 | S32 byte_count = 0; | ||
807 | for (LLMessageTemplate::message_block_map_t::iterator | ||
808 | iter = mCurrentRMessageTemplate->mMemberBlocks.begin(), | ||
809 | end = mCurrentRMessageTemplate->mMemberBlocks.end(); | ||
810 | iter != end; iter++) | ||
811 | { | ||
812 | LLMessageBlock* block = iter->second; | ||
813 | const char* block_name = block->mName; | ||
814 | for (LLMsgBlkData::msg_var_data_map_t::iterator | ||
815 | iter = block->mMemberVariables.begin(), | ||
816 | end = block->mMemberVariables.end(); | ||
817 | iter != end; iter++) | ||
818 | { | ||
819 | const char* var_name = iter->first; | ||
820 | |||
821 | if( getNumberOfBlocksFast( block_name ) < 1 ) | ||
822 | { | ||
823 | LL_INFOS("Messaging") << var_name << " has no blocks" << llendl; | ||
824 | } | ||
825 | for( S32 blocknum = 0; blocknum < getNumberOfBlocksFast( block_name ); blocknum++ ) | ||
826 | { | ||
827 | char *bnamep = (char *)block_name + blocknum; // this works because it's just a hash. The bnamep is never derefference | ||
828 | char *vnamep = (char *)var_name; | ||
829 | |||
830 | LLMsgBlkData *msg_block_data = mCurrentRMessageData->mMemberBlocks[bnamep]; | ||
831 | |||
832 | if (!msg_block_data) | ||
833 | { | ||
834 | std::string errmsg = llformat("Block %s #%d not in message %s", block_name, blocknum, mCurrentRMessageData->mName); | ||
835 | LL_ERRS("Messaging") << errmsg << llendl; | ||
836 | } | ||
837 | |||
838 | LLMsgVarData vardata = msg_block_data->mMemberVarData[vnamep]; | ||
839 | |||
840 | if (!vardata.getName()) | ||
841 | { | ||
842 | std::string errmsg = llformat("Variable %s not in message %s block %s", vnamep, mCurrentRMessageData->mName, bnamep); | ||
843 | LL_ERRS("Messaging") << errmsg << llendl; | ||
844 | } | ||
845 | |||
846 | const S32 vardata_size = vardata.getSize(); | ||
847 | if( vardata_size ) | ||
848 | { | ||
849 | for( i = 0; i < vardata_size; i++ ) | ||
850 | { | ||
851 | byte_count++; | ||
852 | LL_INFOS("Messaging") << block_name << " " << var_name << " [" << blocknum << "][" << i << "]= " << (U32)(((U8*)vardata.getData())[i]) << llendl; | ||
853 | } | ||
854 | } | ||
855 | else | ||
856 | { | ||
857 | LL_INFOS("Messaging") << block_name << " " << var_name << " [" << blocknum << "] 0 bytes" << llendl; | ||
858 | } | ||
859 | } | ||
860 | } | ||
861 | } | ||
862 | LL_INFOS("Messaging") << "Byte count =" << byte_count << llendl; | ||
863 | } | ||
864 | } | ||
865 | */ | ||
866 | |||
867 | mPacketsIn++; | 736 | mPacketsIn++; |
868 | mBytesIn += mTrueReceiveSize; | 737 | mBytesIn += mTrueReceiveSize; |
869 | 738 | ||
@@ -891,9 +760,6 @@ BOOL LLMessageSystem::checkMessages( S64 frame_count ) | |||
891 | mInvalidOnCircuitPackets++; | 760 | mInvalidOnCircuitPackets++; |
892 | } | 761 | } |
893 | } | 762 | } |
894 | |||
895 | // Code for dumping the complete contents of a message | ||
896 | // delete [] zero_unexpanded_buffer; | ||
897 | } | 763 | } |
898 | } while (!valid_packet && receive_size > 0); | 764 | } while (!valid_packet && receive_size > 0); |
899 | 765 | ||
@@ -996,7 +862,7 @@ void LLMessageSystem::processAcks() | |||
996 | } | 862 | } |
997 | } | 863 | } |
998 | 864 | ||
999 | void LLMessageSystem::copyMessageRtoS() | 865 | void LLMessageSystem::copyMessageReceivedToSend() |
1000 | { | 866 | { |
1001 | // NOTE: babbage: switch builder to match reader to avoid | 867 | // NOTE: babbage: switch builder to match reader to avoid |
1002 | // converting message format | 868 | // converting message format |
@@ -1013,6 +879,94 @@ void LLMessageSystem::copyMessageRtoS() | |||
1013 | mMessageReader->copyToBuilder(*mMessageBuilder); | 879 | mMessageReader->copyToBuilder(*mMessageBuilder); |
1014 | } | 880 | } |
1015 | 881 | ||
882 | LLSD LLMessageSystem::getReceivedMessageLLSD() const | ||
883 | { | ||
884 | LLSDMessageBuilder builder; | ||
885 | mMessageReader->copyToBuilder(builder); | ||
886 | return builder.getMessage(); | ||
887 | } | ||
888 | |||
889 | LLSD LLMessageSystem::getBuiltMessageLLSD() const | ||
890 | { | ||
891 | LLSD result; | ||
892 | if (mLLSDMessageBuilder == mMessageBuilder) | ||
893 | { | ||
894 | result = mLLSDMessageBuilder->getMessage(); | ||
895 | } | ||
896 | else | ||
897 | { | ||
898 | // TODO: implement as below? | ||
899 | llerrs << "Message not built as LLSD." << llendl; | ||
900 | } | ||
901 | return result; | ||
902 | } | ||
903 | |||
904 | LLSD LLMessageSystem::wrapReceivedTemplateData() const | ||
905 | { | ||
906 | if(mMessageReader == mTemplateMessageReader) | ||
907 | { | ||
908 | LLTemplateMessageBuilder builder(mMessageTemplates); | ||
909 | builder.newMessage(mMessageReader->getMessageName()); | ||
910 | mMessageReader->copyToBuilder(builder); | ||
911 | U8 buffer[MAX_BUFFER_SIZE]; | ||
912 | const U8 offset_to_data = 0; | ||
913 | U32 size = builder.buildMessage(buffer, MAX_BUFFER_SIZE, | ||
914 | offset_to_data); | ||
915 | std::vector<U8> binary_data(buffer, buffer+size); | ||
916 | LLSD wrapped_data = LLSD::emptyMap(); | ||
917 | wrapped_data["binary-template-data"] = binary_data; | ||
918 | return wrapped_data; | ||
919 | } | ||
920 | else | ||
921 | { | ||
922 | return getReceivedMessageLLSD(); | ||
923 | } | ||
924 | } | ||
925 | |||
926 | LLSD LLMessageSystem::wrapBuiltTemplateData() const | ||
927 | { | ||
928 | LLSD result; | ||
929 | if (mLLSDMessageBuilder == mMessageBuilder) | ||
930 | { | ||
931 | result = getBuiltMessageLLSD(); | ||
932 | } | ||
933 | else | ||
934 | { | ||
935 | U8 buffer[MAX_BUFFER_SIZE]; | ||
936 | const U8 offset_to_data = 0; | ||
937 | U32 size = mTemplateMessageBuilder->buildMessage( | ||
938 | buffer, MAX_BUFFER_SIZE, | ||
939 | offset_to_data); | ||
940 | std::vector<U8> binary_data(buffer, buffer+size); | ||
941 | LLSD wrapped_data = LLSD::emptyMap(); | ||
942 | wrapped_data["binary-template-data"] = binary_data; | ||
943 | result = wrapped_data; | ||
944 | } | ||
945 | return result; | ||
946 | } | ||
947 | |||
948 | LLStoredMessagePtr LLMessageSystem::getReceivedMessage() const | ||
949 | { | ||
950 | const std::string& name = mMessageReader->getMessageName(); | ||
951 | LLSD message = wrapReceivedTemplateData(); | ||
952 | |||
953 | return LLStoredMessagePtr(new LLStoredMessage(name, message)); | ||
954 | } | ||
955 | |||
956 | LLStoredMessagePtr LLMessageSystem::getBuiltMessage() const | ||
957 | { | ||
958 | const std::string& name = mMessageBuilder->getMessageName(); | ||
959 | LLSD message = wrapBuiltTemplateData(); | ||
960 | |||
961 | return LLStoredMessagePtr(new LLStoredMessage(name, message)); | ||
962 | } | ||
963 | |||
964 | S32 LLMessageSystem::sendMessage(const LLHost &host, LLStoredMessagePtr message) | ||
965 | { | ||
966 | return sendMessage(host, message->mName.c_str(), message->mMessage); | ||
967 | } | ||
968 | |||
969 | |||
1016 | void LLMessageSystem::clearMessage() | 970 | void LLMessageSystem::clearMessage() |
1017 | { | 971 | { |
1018 | mSendReliable = FALSE; | 972 | mSendReliable = FALSE; |
@@ -1025,6 +979,11 @@ void LLMessageSystem::nextBlockFast(const char *blockname) | |||
1025 | mMessageBuilder->nextBlock(blockname); | 979 | mMessageBuilder->nextBlock(blockname); |
1026 | } | 980 | } |
1027 | 981 | ||
982 | void LLMessageSystem::nextBlock(const char *blockname) | ||
983 | { | ||
984 | nextBlockFast(LLMessageStringTable::getInstance()->getString(blockname)); | ||
985 | } | ||
986 | |||
1028 | BOOL LLMessageSystem::isSendFull(const char* blockname) | 987 | BOOL LLMessageSystem::isSendFull(const char* blockname) |
1029 | { | 988 | { |
1030 | char* stringTableName = NULL; | 989 | char* stringTableName = NULL; |
@@ -1104,19 +1063,19 @@ S32 LLMessageSystem::sendReliable( const LLHost &host, | |||
1104 | 1063 | ||
1105 | void LLMessageSystem::forwardMessage(const LLHost &host) | 1064 | void LLMessageSystem::forwardMessage(const LLHost &host) |
1106 | { | 1065 | { |
1107 | copyMessageRtoS(); | 1066 | copyMessageReceivedToSend(); |
1108 | sendMessage(host); | 1067 | sendMessage(host); |
1109 | } | 1068 | } |
1110 | 1069 | ||
1111 | void LLMessageSystem::forwardReliable(const LLHost &host) | 1070 | void LLMessageSystem::forwardReliable(const LLHost &host) |
1112 | { | 1071 | { |
1113 | copyMessageRtoS(); | 1072 | copyMessageReceivedToSend(); |
1114 | sendReliable(host); | 1073 | sendReliable(host); |
1115 | } | 1074 | } |
1116 | 1075 | ||
1117 | void LLMessageSystem::forwardReliable(const U32 circuit_code) | 1076 | void LLMessageSystem::forwardReliable(const U32 circuit_code) |
1118 | { | 1077 | { |
1119 | copyMessageRtoS(); | 1078 | copyMessageReceivedToSend(); |
1120 | sendReliable(findHost(circuit_code)); | 1079 | sendReliable(findHost(circuit_code)); |
1121 | } | 1080 | } |
1122 | 1081 | ||
@@ -1127,7 +1086,7 @@ S32 LLMessageSystem::forwardReliable( const LLHost &host, | |||
1127 | void (*callback)(void **,S32), | 1086 | void (*callback)(void **,S32), |
1128 | void ** callback_data) | 1087 | void ** callback_data) |
1129 | { | 1088 | { |
1130 | copyMessageRtoS(); | 1089 | copyMessageReceivedToSend(); |
1131 | return sendReliable(host, retries, ping_based_timeout, timeout, callback, callback_data); | 1090 | return sendReliable(host, retries, ping_based_timeout, timeout, callback, callback_data); |
1132 | } | 1091 | } |
1133 | 1092 | ||
@@ -1194,7 +1153,7 @@ LLHTTPClient::ResponderPtr LLMessageSystem::createResponder(const std::string& n | |||
1194 | return new LLFnPtrResponder( | 1153 | return new LLFnPtrResponder( |
1195 | NULL, | 1154 | NULL, |
1196 | NULL, | 1155 | NULL, |
1197 | mMessageBuilder->getMessageName()); | 1156 | name); |
1198 | } | 1157 | } |
1199 | } | 1158 | } |
1200 | 1159 | ||
@@ -1455,13 +1414,6 @@ S32 LLMessageSystem::sendMessage( | |||
1455 | LL_WARNS("Messaging") << "trying to send message to invalid host" << llendl; | 1414 | LL_WARNS("Messaging") << "trying to send message to invalid host" << llendl; |
1456 | return 0; | 1415 | return 0; |
1457 | } | 1416 | } |
1458 | newMessage(name); | ||
1459 | if (mMessageBuilder != mLLSDMessageBuilder) | ||
1460 | { | ||
1461 | LL_WARNS("Messaging") << "trying to send llsd message when builder is not LLSD!" | ||
1462 | << llendl; | ||
1463 | return 0; | ||
1464 | } | ||
1465 | 1417 | ||
1466 | const LLHTTPSender& sender = LLHTTPSender::getSender(host); | 1418 | const LLHTTPSender& sender = LLHTTPSender::getSender(host); |
1467 | sender.send(host, name, message, createResponder(name)); | 1419 | sender.send(host, name, message, createResponder(name)); |
@@ -2170,6 +2122,15 @@ void LLMessageSystem::dispatch( | |||
2170 | handler->post(responsep, context, message); | 2122 | handler->post(responsep, context, message); |
2171 | } | 2123 | } |
2172 | 2124 | ||
2125 | //static | ||
2126 | void LLMessageSystem::dispatchTemplate(const std::string& msg_name, | ||
2127 | const LLSD& message, | ||
2128 | LLHTTPNode::ResponsePtr responsep) | ||
2129 | { | ||
2130 | LLTemplateMessageDispatcher dispatcher(*(gMessageSystem->mTemplateMessageReader)); | ||
2131 | dispatcher.dispatch(msg_name, message, responsep); | ||
2132 | } | ||
2133 | |||
2173 | static void check_for_unrecognized_messages( | 2134 | static void check_for_unrecognized_messages( |
2174 | const char* type, | 2135 | const char* type, |
2175 | const LLSD& map, | 2136 | const LLSD& map, |
@@ -2352,6 +2313,23 @@ void process_create_trusted_circuit(LLMessageSystem *msg, void **) | |||
2352 | return; | 2313 | return; |
2353 | } | 2314 | } |
2354 | 2315 | ||
2316 | U32 untrusted_interface = msg->getUntrustedInterface().getAddress(); | ||
2317 | U32 last_interface = msg->getReceivingInterface().getAddress(); | ||
2318 | if ( ( untrusted_interface != INVALID_HOST_IP_ADDRESS ) && ( untrusted_interface == last_interface ) ) | ||
2319 | { | ||
2320 | if( msg->getBlockUntrustedInterface() ) | ||
2321 | { | ||
2322 | LL_WARNS("Messaging") << "Ignoring CreateTrustedCircuit on public interface from host: " | ||
2323 | << msg->getSender() << llendl; | ||
2324 | return; | ||
2325 | } | ||
2326 | else | ||
2327 | { | ||
2328 | LL_WARNS("Messaging") << "Processing CreateTrustedCircuit on public interface from host: " | ||
2329 | << msg->getSender() << llendl; | ||
2330 | } | ||
2331 | } | ||
2332 | |||
2355 | char their_digest[MD5HEX_STR_SIZE]; /* Flawfinder: ignore */ | 2333 | char their_digest[MD5HEX_STR_SIZE]; /* Flawfinder: ignore */ |
2356 | S32 size = msg->getSizeFast(_PREHASH_DataBlock, _PREHASH_Digest); | 2334 | S32 size = msg->getSizeFast(_PREHASH_DataBlock, _PREHASH_Digest); |
2357 | if(size != MD5HEX_STR_BYTES) | 2335 | if(size != MD5HEX_STR_BYTES) |
@@ -2408,6 +2386,24 @@ void process_deny_trusted_circuit(LLMessageSystem *msg, void **) | |||
2408 | // Don't respond to requests that use the same end point ID | 2386 | // Don't respond to requests that use the same end point ID |
2409 | return; | 2387 | return; |
2410 | } | 2388 | } |
2389 | |||
2390 | U32 untrusted_interface = msg->getUntrustedInterface().getAddress(); | ||
2391 | U32 last_interface = msg->getReceivingInterface().getAddress(); | ||
2392 | if ( ( untrusted_interface != INVALID_HOST_IP_ADDRESS ) && ( untrusted_interface == last_interface ) ) | ||
2393 | { | ||
2394 | if( msg->getBlockUntrustedInterface() ) | ||
2395 | { | ||
2396 | LL_WARNS("Messaging") << "Ignoring DenyTrustedCircuit on public interface from host: " | ||
2397 | << msg->getSender() << llendl; | ||
2398 | return; | ||
2399 | } | ||
2400 | else | ||
2401 | { | ||
2402 | LL_WARNS("Messaging") << "Processing DenyTrustedCircuit on public interface from host: " | ||
2403 | << msg->getSender() << llendl; | ||
2404 | } | ||
2405 | } | ||
2406 | |||
2411 | 2407 | ||
2412 | // Assume that we require trust to proceed, so resend. | 2408 | // Assume that we require trust to proceed, so resend. |
2413 | // This catches the case where a circuit that was trusted | 2409 | // This catches the case where a circuit that was trusted |
@@ -2496,7 +2492,9 @@ bool start_messaging_system( | |||
2496 | bool b_dump_prehash_file, | 2492 | bool b_dump_prehash_file, |
2497 | const std::string& secret, | 2493 | const std::string& secret, |
2498 | const LLUseCircuitCodeResponder* responder, | 2494 | const LLUseCircuitCodeResponder* responder, |
2499 | bool failure_is_fatal) | 2495 | bool failure_is_fatal, |
2496 | const F32 circuit_heartbeat_interval, | ||
2497 | const F32 circuit_timeout) | ||
2500 | { | 2498 | { |
2501 | gMessageSystem = new LLMessageSystem( | 2499 | gMessageSystem = new LLMessageSystem( |
2502 | template_name, | 2500 | template_name, |
@@ -2504,7 +2502,9 @@ bool start_messaging_system( | |||
2504 | version_major, | 2502 | version_major, |
2505 | version_minor, | 2503 | version_minor, |
2506 | version_patch, | 2504 | version_patch, |
2507 | failure_is_fatal); | 2505 | failure_is_fatal, |
2506 | circuit_heartbeat_interval, | ||
2507 | circuit_timeout); | ||
2508 | g_shared_secret.assign(secret); | 2508 | g_shared_secret.assign(secret); |
2509 | 2509 | ||
2510 | if (!gMessageSystem) | 2510 | if (!gMessageSystem) |
@@ -2683,7 +2683,7 @@ void LLMessageSystem::summarizeLogs(std::ostream& str) | |||
2683 | str << "END MESSAGE LOG SUMMARY" << std::endl; | 2683 | str << "END MESSAGE LOG SUMMARY" << std::endl; |
2684 | } | 2684 | } |
2685 | 2685 | ||
2686 | void end_messaging_system() | 2686 | void end_messaging_system(bool print_summary) |
2687 | { | 2687 | { |
2688 | gTransferManager.cleanup(); | 2688 | gTransferManager.cleanup(); |
2689 | LLTransferTargetVFile::updateQueue(true); // shutdown LLTransferTargetVFile | 2689 | LLTransferTargetVFile::updateQueue(true); // shutdown LLTransferTargetVFile |
@@ -2691,9 +2691,12 @@ void end_messaging_system() | |||
2691 | { | 2691 | { |
2692 | gMessageSystem->stopLogging(); | 2692 | gMessageSystem->stopLogging(); |
2693 | 2693 | ||
2694 | std::ostringstream str; | 2694 | if (print_summary) |
2695 | gMessageSystem->summarizeLogs(str); | 2695 | { |
2696 | LL_INFOS("Messaging") << str.str().c_str() << llendl; | 2696 | std::ostringstream str; |
2697 | gMessageSystem->summarizeLogs(str); | ||
2698 | LL_INFOS("Messaging") << str.str().c_str() << llendl; | ||
2699 | } | ||
2697 | 2700 | ||
2698 | delete gMessageSystem; | 2701 | delete gMessageSystem; |
2699 | gMessageSystem = NULL; | 2702 | gMessageSystem = NULL; |
@@ -4041,3 +4044,11 @@ void LLMessageSystem::banUdpMessage(const std::string& name) | |||
4041 | llwarns << "Attempted to ban an unknown message: " << name << "." << llendl; | 4044 | llwarns << "Attempted to ban an unknown message: " << name << "." << llendl; |
4042 | } | 4045 | } |
4043 | } | 4046 | } |
4047 | const LLHost& LLMessageSystem::getSender() const | ||
4048 | { | ||
4049 | return mLastSender; | ||
4050 | } | ||
4051 | |||
4052 | LLHTTPRegistration<LLHTTPNodeAdapter<LLTrustedMessageService> > | ||
4053 | gHTTPRegistrationTrustedMessageWildcard("/trusted-message/<message-name>"); | ||
4054 | |||