MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / processRequest

Method processRequest

source/server/StarServerRconClient.cpp:91–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89}
90
91void ServerRconClient::processRequest() {
92 receive(4);
93 uint32_t size = m_packetBuffer.read<uint32_t>();
94
95 receive(size);
96 uint32_t requestId;
97 m_packetBuffer >> requestId;
98
99 uint32_t cmd;
100 m_packetBuffer >> cmd;
101
102 switch (cmd) {
103 case SERVERDATA_AUTH: {
104 String password;
105 m_packetBuffer >> password;
106 if (!m_rconPassword.empty() && m_rconPassword.equals(password)) {
107 m_authed = true;
108 send(requestId, SERVERDATA_RESPONSE_VALUE);
109 send(requestId, SERVERDATA_AUTH_RESPONSE);
110 } else {
111 m_authed = false;
112 sendAuthFailure();
113 }
114 break;
115 }
116 case SERVERDATA_EXECCOMMAND:
117 if (m_authed) {
118 String command;
119 m_packetBuffer >> command;
120 try {
121 Logger::info("RCON {}: {}", m_socket->remoteAddress(), command);
122 sendCmdResponse(requestId, handleCommand(command));
123 } catch (std::exception const& e) {
124 sendCmdResponse(requestId, strf("RCON: Error executing: {}: {}", command, outputException(e, true)));
125 }
126 } else {
127 sendAuthFailure();
128 }
129 break;
130 default:
131 sendCmdResponse(requestId, strf("Unknown request {:06x}", cmd));
132 }
133}
134
135void ServerRconClient::run() {
136 try {

Callers

nothing calls this directly

Calls 5

strfFunction · 0.85
remoteAddressMethod · 0.80
outputExceptionFunction · 0.50
emptyMethod · 0.45
equalsMethod · 0.45

Tested by

no test coverage detected