xrpld
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 xrpl {
8
9namespace RPC {
10struct JsonContext;
11} // namespace RPC
12
13json::Value
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.empty())
26 ret[jss::ip] = std::string{context.headers.forwardedFor};
27 break;
28 case Role::PROXY:
29 ret[jss::role] = "proxied";
30 if (!context.headers.forwardedFor.empty())
31 ret[jss::ip] = std::string{context.headers.forwardedFor};
32 break;
33 default:;
34 }
35
36 // This is only accessible on ws sessions.
37 if (context.infoSub)
38 {
39 if (context.infoSub->getConsumer().isUnlimited())
40 ret[jss::unlimited] = true;
41 }
42
43 return ret;
44}
45
46} // namespace xrpl
Represents a JSON value.
Definition json_value.h:130
Consumer & getConsumer()
Definition InfoSub.cpp:108
bool isUnlimited() const
Returns true if this is a privileged endpoint.
Definition Consumer.cpp:70
T empty(T... args)
@ Object
object value (collection of name/value pairs).
Definition json_value.h:26
API version numbers used in later API versions.
Definition ApiVersion.h:35
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
json::Value doPing(RPC::JsonContext &)
Definition Ping.cpp:14
@ IDENTIFIED
Definition Role.h:24
@ ADMIN
Definition Role.h:24
@ PROXY
Definition Role.h:24
InfoSub::pointer infoSub
Definition Context.h:28
std::string_view forwardedFor
Definition Context.h:40