rippled
Loading...
Searching...
No Matches
xrpld
rpc
handlers
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
7
namespace
ripple
{
8
9
namespace
RPC {
10
struct
JsonContext;
11
}
// namespace RPC
12
13
Json::Value
14
doPing
(
RPC::JsonContext
& context)
15
{
16
Json::Value
ret(
Json::objectValue
);
17
switch
(context.
role
)
18
{
19
case
Role::ADMIN
:
20
ret[jss::role] =
"admin"
;
21
break
;
22
case
Role::IDENTIFIED
:
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
std::string
Json::Value
Represents a JSON value.
Definition
json_value.h:131
ripple::InfoSub::getConsumer
Consumer & getConsumer()
Definition
InfoSub.cpp:49
ripple::Resource::Consumer::isUnlimited
bool isUnlimited() const
Returns true if this is a privileged endpoint.
Definition
Consumer.cpp:68
Json::objectValue
@ objectValue
object value (collection of name/value pairs).
Definition
json_value.h:27
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition
algorithm.h:6
ripple::doPing
Json::Value doPing(RPC::JsonContext &)
Definition
Ping.cpp:14
ripple::Role::IDENTIFIED
@ IDENTIFIED
ripple::Role::ADMIN
@ ADMIN
ripple::Role::PROXY
@ PROXY
std::string_view::size
T size(T... args)
ripple::RPC::Context::role
Role role
Definition
Context.h:27
ripple::RPC::Context::infoSub
InfoSub::pointer infoSub
Definition
Context.h:29
ripple::RPC::JsonContext::Headers::forwardedFor
std::string_view forwardedFor
Definition
Context.h:41
ripple::RPC::JsonContext::Headers::user
std::string_view user
Definition
Context.h:40
ripple::RPC::JsonContext
Definition
Context.h:34
ripple::RPC::JsonContext::headers
Headers headers
Definition
Context.h:46
Generated by
1.9.8