comparison OrthancServer/main.cpp @ 2353:2421c137c304

reject connections earlier if DicomAlwaysAllowStore == false
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 19 Jul 2017 09:08:04 +0200
parents 3ab96768d144
children 3ec85ff48374
comparison
equal deleted inserted replaced
2352:3ab96768d144 2353:2421c137c304
150 150
151 class OrthancApplicationEntityFilter : public IApplicationEntityFilter 151 class OrthancApplicationEntityFilter : public IApplicationEntityFilter
152 { 152 {
153 private: 153 private:
154 ServerContext& context_; 154 ServerContext& context_;
155 bool alwaysAllowStore_;
155 156
156 public: 157 public:
157 OrthancApplicationEntityFilter(ServerContext& context) : context_(context) 158 OrthancApplicationEntityFilter(ServerContext& context) :
158 { 159 context_(context)
160 {
161 alwaysAllowStore_ = Configuration::GetGlobalBoolParameter("DicomAlwaysAllowStore", true);
159 } 162 }
160 163
161 virtual bool IsAllowedConnection(const std::string& remoteIp, 164 virtual bool IsAllowedConnection(const std::string& remoteIp,
162 const std::string& remoteAet, 165 const std::string& remoteAet,
163 const std::string& calledAet) 166 const std::string& calledAet)
164 { 167 {
165 LOG(INFO) << "Incoming connection from AET " << remoteAet 168 LOG(INFO) << "Incoming connection from AET " << remoteAet
166 << " on IP " << remoteIp << ", calling AET " << calledAet; 169 << " on IP " << remoteIp << ", calling AET " << calledAet;
167 170
168 return true; 171 return (alwaysAllowStore_ ||
172 Configuration::IsKnownAETitle(remoteAet, remoteIp));
169 } 173 }
170 174
171 virtual bool IsAllowedRequest(const std::string& remoteIp, 175 virtual bool IsAllowedRequest(const std::string& remoteIp,
172 const std::string& remoteAet, 176 const std::string& remoteAet,
173 const std::string& calledAet, 177 const std::string& calledAet,
175 { 179 {
176 LOG(INFO) << "Incoming " << Orthanc::EnumerationToString(type) << " request from AET " 180 LOG(INFO) << "Incoming " << Orthanc::EnumerationToString(type) << " request from AET "
177 << remoteAet << " on IP " << remoteIp << ", calling AET " << calledAet; 181 << remoteAet << " on IP " << remoteIp << ", calling AET " << calledAet;
178 182
179 if (type == DicomRequestType_Store && 183 if (type == DicomRequestType_Store &&
180 Configuration::GetGlobalBoolParameter("DicomAlwaysAllowStore", true)) 184 alwaysAllowStore_)
181 { 185 {
182 // Incoming store requests are always accepted, even from unknown AET 186 // Incoming store requests are always accepted, even from unknown AET
183 return true; 187 return true;
184 } 188 }
185 189 else if (!Configuration::IsKnownAETitle(remoteAet, remoteIp))
186 if (!Configuration::IsKnownAETitle(remoteAet, remoteIp))
187 { 190 {
188 return false; 191 return false;
189 } 192 }
190 else 193 else
191 { 194 {