Skip to content

Commit

Permalink
explicit allow_remote setting for remote access
Browse files Browse the repository at this point in the history
  • Loading branch information
madMAx43v3r committed Jan 21, 2025
1 parent f938c26 commit 695cd4d
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 18 deletions.
1 change: 1 addition & 0 deletions config/local_init/allow_remote
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
false
11 changes: 9 additions & 2 deletions src/mmx_farmer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,21 @@ int main(int argc, char** argv)
vnx::init("mmx_farmer", argc, argv, options);

std::string node_url = ":11330";
std::string endpoint = "0.0.0.0:11333";
std::string endpoint = "0.0.0.0"; // requires allow_remote
bool with_wallet = true;
bool with_harvester = true;
bool allow_remote = false;

vnx::read_config("node", node_url);
vnx::read_config("endpoint", endpoint);
vnx::read_config("wallet", with_wallet);
vnx::read_config("harvester", with_harvester);
vnx::read_config("allow_remote", allow_remote);

if(!allow_remote) {
endpoint = "localhost";
}
vnx::log_info() << "Remote service access is: " << (allow_remote ? "enabled on " + endpoint : "disabled");

auto node = vnx::Endpoint::from_url(node_url);
if(auto tcp = std::dynamic_pointer_cast<const vnx::TcpEndpoint>(node)) {
Expand All @@ -62,7 +69,7 @@ int main(int argc, char** argv)
proxy->forward_list = {"Node", "Router"};

{
vnx::Handle<vnx::Server> module = new vnx::Server("Server", vnx::Endpoint::from_url(endpoint));
vnx::Handle<vnx::Server> module = new vnx::Server("Server", vnx::Endpoint::from_url(endpoint + ":11333"));
module->use_authentication = true;
module->default_access = "REMOTE";
module.start_detached();
Expand Down
6 changes: 1 addition & 5 deletions src/mmx_harvester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,8 @@ int main(int argc, char** argv)
vnx::init("mmx_harvester", argc, argv, options);

std::string node_url = ":11330";
std::string endpoint = ":11333";

vnx::read_config("node", node_url);
vnx::read_config("endpoint", endpoint);

auto node = vnx::Endpoint::from_url(node_url);
if(auto tcp = std::dynamic_pointer_cast<const vnx::TcpEndpoint>(node)) {
Expand All @@ -54,9 +52,7 @@ int main(int argc, char** argv)
proxy->forward_list = {"Node", "Farmer"};

{
vnx::Handle<vnx::Server> module = new vnx::Server("Server", vnx::Endpoint::from_url(endpoint));
module->use_authentication = true;
module->default_access = "REMOTE";
vnx::Handle<vnx::Server> module = new vnx::Server("Server", vnx::Endpoint::from_url("localhost:11333"));
module.start_detached();
}
{
Expand Down
23 changes: 16 additions & 7 deletions src/mmx_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,22 @@ int main(int argc, char** argv)
bool with_wallet = true;
bool with_timelord = true;
bool with_harvester = true;
bool allow_remote = false;
uint32_t wapi_threads = 1;
std::string public_endpoint = "0.0.0.0:11330"; // for remote farmer, etc
std::string endpoint = "0.0.0.0"; // requires allow_remote

vnx::read_config("gui", with_gui);
vnx::read_config("wallet", with_wallet);
vnx::read_config("farmer", with_farmer);
vnx::read_config("timelord", with_timelord);
vnx::read_config("harvester", with_harvester);
vnx::read_config("allow_remote", allow_remote);
vnx::read_config("wapi_threads", wapi_threads);
vnx::read_config("public_endpoint", public_endpoint);
vnx::read_config("endpoint", endpoint);

if(!allow_remote) {
endpoint = "localhost";
}
wapi_threads = std::max(std::min(wapi_threads, 256u), 1u);

vnx::log_info() << "AVX2 support: " << (avx2_available() ? "yes" : "no");
Expand All @@ -112,6 +117,8 @@ int main(int argc, char** argv)
vnx::log_info() << "ARM-SHA2 support: " << (sha256_arm_available() ? "yes" : "no");
#endif // __aarch64__

vnx::log_info() << "Remote service access is: " << (allow_remote ? "enabled on " + endpoint : "disabled");

if(with_farmer) {
with_wallet = true;
} else {
Expand Down Expand Up @@ -140,13 +147,15 @@ int main(int argc, char** argv)
module.start_detached();
}
{
vnx::Handle<vnx::Server> module = new vnx::Server("Server0", vnx::Endpoint::from_url(public_endpoint));
// for remote farmer / timelord
vnx::Handle<vnx::Server> module = new vnx::Server("Server0", vnx::Endpoint::from_url(endpoint + ":11330"));
module->use_authentication = true;
module->default_access = "REMOTE";
module.start_detached();
}
{
vnx::Handle<vnx::Server> module = new vnx::Server("Server1", vnx::Endpoint::from_url(":11331"));
// for CLI
vnx::Handle<vnx::Server> module = new vnx::Server("Server1", vnx::Endpoint::from_url("localhost:11331"));
module.start_detached();
}
if(with_wallet) {
Expand All @@ -158,7 +167,7 @@ int main(int argc, char** argv)
module.start_detached();
}
{
vnx::Handle<vnx::Server> module = new vnx::Server("Server5", vnx::Endpoint::from_url(":11335"));
vnx::Handle<vnx::Server> module = new vnx::Server("Server5", vnx::Endpoint::from_url("localhost:11335"));
module.start_detached();
}
}
Expand Down Expand Up @@ -194,7 +203,7 @@ int main(int argc, char** argv)
module.start_detached();
}
{
vnx::Handle<vnx::Server> module = new vnx::Server("Server2", vnx::Endpoint::from_url(":11332"));
vnx::Handle<vnx::Server> module = new vnx::Server("Server2", vnx::Endpoint::from_url("localhost:11332"));
module.start_detached();
}
}
Expand All @@ -205,7 +214,7 @@ int main(int argc, char** argv)
}
{
// for remote harvesters
vnx::Handle<vnx::Server> module = new vnx::Server("Server3", vnx::Endpoint::from_url("0.0.0.0:11333"));
vnx::Handle<vnx::Server> module = new vnx::Server("Server3", vnx::Endpoint::from_url(endpoint + ":11333"));
module->use_authentication = true;
module->default_access = "REMOTE";
module.start_detached();
Expand Down
4 changes: 1 addition & 3 deletions src/mmx_timelord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,8 @@ int main(int argc, char** argv)
vnx::init("mmx_timelord", argc, argv, options);

std::string node_url = ":11330";
std::string endpoint = ":11332";

vnx::read_config("node", node_url);
vnx::read_config("endpoint", endpoint);

vnx::log_info() << "SHA-NI support: " << (sha256_ni_available() ? "yes" : "no");
#ifdef __aarch64__
Expand All @@ -61,7 +59,7 @@ int main(int argc, char** argv)
proxy->forward_list = {"Node", "Wallet"};

{
vnx::Handle<vnx::Server> module = new vnx::Server("Server", vnx::Endpoint::from_url(endpoint));
vnx::Handle<vnx::Server> module = new vnx::Server("Server", vnx::Endpoint::from_url("localhost:11332"));
module->use_authentication = true;
module->default_access = "REMOTE";
module.start_detached();
Expand Down
2 changes: 1 addition & 1 deletion src/mmx_wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ int main(int argc, char** argv)
proxy->forward_list = {"Node", "Router"};

{
vnx::Handle<vnx::Server> module = new vnx::Server("Server", vnx::Endpoint::from_url(":11335"));
vnx::Handle<vnx::Server> module = new vnx::Server("Server", vnx::Endpoint::from_url("localhost:11335"));
module.start_detached();
}
{
Expand Down
12 changes: 12 additions & 0 deletions www/web-gui/public/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Vue.component('node-settings', {
loading: true,
timelord: null,
open_port: null,
allow_remote: null,
opencl_device_list_relidx: null,
opencl_device: null,
opencl_device_list: null,
Expand All @@ -29,6 +30,7 @@ Vue.component('node-settings', {
this.loading = false;
this.timelord = data.timelord ? true : false;
this.open_port = data["Router.open_port"] ? true : false;
this.allow_remote = data["allow_remote"] ? true : false;
this.opencl_device = data["Node.opencl_device_select"] != null ? data["Node.opencl_device_select"] : -1;
this.opencl_device_list_relidx = [];
this.opencl_device_list = [{name: "None", value: -1}];
Expand Down Expand Up @@ -144,6 +146,11 @@ Vue.component('node-settings', {
this.set_config("Router.open_port", value, true);
}
},
allow_remote(value, prev) {
if(prev != null) {
this.set_config("allow_remote", value, true);
}
},
opencl_device(value, prev) {
if(prev != null) {
this.set_config("Node.opencl_device_select", value, true, true);
Expand Down Expand Up @@ -244,6 +251,11 @@ Vue.component('node-settings', {
:label="$t('node_settings.open_port')"
class="my-0"
></v-checkbox>
<v-checkbox
v-model="allow_remote"
label="Allow remote service access (for remote harvesters)"
class="my-0"
></v-checkbox>
<v-select
v-model="opencl_device"
Expand Down

0 comments on commit 695cd4d

Please sign in to comment.