mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-10 21:41:50 +00:00
feat: debugging server does not require network permission now
This commit is contained in:
parent
4c7043d4c2
commit
6cdd6b833c
4 changed files with 14 additions and 4 deletions
|
|
@ -139,7 +139,8 @@ void Engine::initialize(CoreParameters coreParameters) {
|
||||||
editor = std::make_unique<devtools::Editor>(*this);
|
editor = std::make_unique<devtools::Editor>(*this);
|
||||||
cmd = std::make_unique<cmd::CommandsInterpreter>();
|
cmd = std::make_unique<cmd::CommandsInterpreter>();
|
||||||
|
|
||||||
if (project->permissions.has(Permissions::NETWORK)) {
|
if (project->permissions.has(Permissions::NETWORK) ||
|
||||||
|
!params.debugServerString.empty()) {
|
||||||
network = network::Network::create(settings.network);
|
network = network::Network::create(settings.network);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ static int l_start_debug_instance(lua::State* L) {
|
||||||
throw std::runtime_error("could not find free port");
|
throw std::runtime_error("could not find free port");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
auto projectPath = lua::isstring(L, 2) ? lua::require_lstring(L, 2) : "";
|
||||||
const auto& paths = engine->getPaths();
|
const auto& paths = engine->getPaths();
|
||||||
|
|
||||||
std::vector<std::string> args {
|
std::vector<std::string> args {
|
||||||
|
|
@ -36,6 +37,11 @@ static int l_start_debug_instance(lua::State* L) {
|
||||||
"--dir", paths.getUserFilesFolder().u8string(),
|
"--dir", paths.getUserFilesFolder().u8string(),
|
||||||
"--dbg-server", "tcp:" + std::to_string(port),
|
"--dbg-server", "tcp:" + std::to_string(port),
|
||||||
};
|
};
|
||||||
|
if (!projectPath.empty()) {
|
||||||
|
args.emplace_back("--project");
|
||||||
|
args.emplace_back(io::resolve(std::string(projectPath)).string());
|
||||||
|
}
|
||||||
|
|
||||||
platform::new_engine_instance(std::move(args));
|
platform::new_engine_instance(std::move(args));
|
||||||
return lua::pushinteger(L, port);
|
return lua::pushinteger(L, port);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
#include "coders/json.hpp"
|
#include "coders/json.hpp"
|
||||||
#include "engine/Engine.hpp"
|
#include "engine/Engine.hpp"
|
||||||
#include "network/Network.hpp"
|
#include "network/Network.hpp"
|
||||||
|
#include "devtools/Project.hpp"
|
||||||
|
|
||||||
#include <variant>
|
#include <variant>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
@ -439,7 +440,7 @@ static int l_is_nodelay(lua::State* L, network::Network& network) {
|
||||||
return lua::pushboolean(L, false);
|
return lua::pushboolean(L, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int l_pull_events(lua::State* L, network::Network& network) {
|
static int l_pull_events(lua::State* L) {
|
||||||
std::vector<NetworkEvent> local_queue;
|
std::vector<NetworkEvent> local_queue;
|
||||||
{
|
{
|
||||||
std::lock_guard lock(events_queue_mutex);
|
std::lock_guard lock(events_queue_mutex);
|
||||||
|
|
@ -528,7 +529,8 @@ int wrap(lua_State* L) {
|
||||||
int result = 0;
|
int result = 0;
|
||||||
try {
|
try {
|
||||||
auto network = engine->getNetwork();
|
auto network = engine->getNetwork();
|
||||||
if (network == nullptr) {
|
const auto& permissions = engine->getProject().permissions;
|
||||||
|
if (network == nullptr || !permissions.has(Permissions::NETWORK)) {
|
||||||
throw std::runtime_error(
|
throw std::runtime_error(
|
||||||
"network subsystem is not available in the project"
|
"network subsystem is not available in the project"
|
||||||
);
|
);
|
||||||
|
|
@ -554,7 +556,7 @@ const luaL_Reg networklib[] = {
|
||||||
{"get_total_download", wrap<l_get_total_download>},
|
{"get_total_download", wrap<l_get_total_download>},
|
||||||
{"find_free_port", wrap<l_find_free_port>},
|
{"find_free_port", wrap<l_find_free_port>},
|
||||||
{"is_available", lua::wrap<l_is_available>},
|
{"is_available", lua::wrap<l_is_available>},
|
||||||
{"__pull_events", wrap<l_pull_events>},
|
{"__pull_events", lua::wrap<l_pull_events>},
|
||||||
{"__open_tcp", wrap<l_open_tcp>},
|
{"__open_tcp", wrap<l_open_tcp>},
|
||||||
{"__open_udp", wrap<l_open_udp>},
|
{"__open_udp", wrap<l_open_udp>},
|
||||||
{"__closeserver", wrap<l_closeserver>},
|
{"__closeserver", wrap<l_closeserver>},
|
||||||
|
|
|
||||||
|
|
@ -281,6 +281,7 @@ void platform::new_engine_instance(const std::vector<std::string>& args) {
|
||||||
ss << " >/dev/null &";
|
ss << " >/dev/null &";
|
||||||
|
|
||||||
auto command = ss.str();
|
auto command = ss.str();
|
||||||
|
logger.info() << command;
|
||||||
if (int res = system(command.c_str())) {
|
if (int res = system(command.c_str())) {
|
||||||
throw std::runtime_error(
|
throw std::runtime_error(
|
||||||
"starting an engine instance failed with code: " +
|
"starting an engine instance failed with code: " +
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue