add 'network' permission

This commit is contained in:
MihailRis
2025-12-08 19:21:50 +03:00
committed by ShiftyX1
parent 56d808e3e2
commit dd40780334
10 changed files with 67 additions and 27 deletions
+12 -5
View File
@@ -94,12 +94,17 @@ bool ClientConnection::alive() const {
static network::Server& create_tcp_server(
DebuggingServer& dbgServer, Engine& engine, int port
) {
auto& network = engine.getNetwork();
u64id_t serverId = network.openTcpServer(
auto network = engine.getNetwork();
if (network == nullptr) {
throw std::runtime_error(
"unable to create tcp server: project has no network permission"
);
}
u64id_t serverId = network->openTcpServer(
port,
[&network, &dbgServer](u64id_t sid, u64id_t id) {
auto& connection = dynamic_cast<network::ReadableConnection&>(
*network.getConnection(id, true)
*network->getConnection(id, true)
);
connection.setPrivate(true);
logger.info() << "connected client " << id << ": "
@@ -108,7 +113,7 @@ static network::Server& create_tcp_server(
dbgServer.setClient(id);
}
);
auto& server = *network.getServer(serverId, true);
auto& server = *network->getServer(serverId, true);
server.setPrivate(true);
auto& tcpServer = dynamic_cast<network::TcpServer&>(server);
@@ -302,8 +307,10 @@ void DebuggingServer::sendValue(
}
void DebuggingServer::setClient(u64id_t client) {
auto network = engine.getNetwork();
assert (network != nullptr);
connection =
std::make_unique<ClientConnection>(engine.getNetwork(), client);
std::make_unique<ClientConnection>(*network, client);
connectionEstablished = false;
}
+1
View File
@@ -14,6 +14,7 @@ namespace scripting {
struct Permissions {
static inline std::string WRITE_TO_USER = "write-to-user";
static inline std::string NETWORK = "network";
std::set<std::string> permissions;