rippled
Loading...
Searching...
No Matches
Ping.cpp
1#include <xrpld/rpc/Context.h>
2#include <xrpld/rpc/Role.h>
3
4#include <xrpl/json/json_value.h>
5#include <xrpl/protocol/jss.h>
6
7namespace ripple {
8
9namespace RPC {
10struct JsonContext;
11} // namespace RPC
12
15{
17 switch (context.role)
18 {
19 case Role::ADMIN:
20 ret[jss::role] = "admin";
21 break;
23 ret[jss::role] = "identified";
24 ret[jss::username] = std::string{context.headers.user};
25 if (context.headers.forwardedFor.size())
26 ret[jss::ip] = std::string{context.headers.forwardedFor};
27 break;
28 case Role::PROXY:
29 ret[jss::role] = "proxied";
30 ret[jss::ip] = std::string{context.headers.forwardedFor};
31 default:;
32 }
33
34 // This is only accessible on ws sessions.
35 if (context.infoSub)
36 {
37 if (context.infoSub->getConsumer().isUnlimited())
38 ret[jss::unlimited] = true;
39 }
40
41 return ret;
42}
43
44} // namespace ripple
Represents a JSON value.
Definition json_value.h:131
Consumer & getConsumer()
Definition InfoSub.cpp:49
bool isUnlimited() const
Returns true if this is a privileged endpoint.
Definition Consumer.cpp:68
@ objectValue
object value (collection of name/value pairs).
Definition json_value.h:27
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
Json::Value doPing(RPC::JsonContext &)
Definition Ping.cpp:14
T size(T... args)
InfoSub::pointer infoSub
Definition Context.h:29
std::string_view forwardedFor
Definition Context.h:41