-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow IPv6 in Proxy settings and moving validation out from the UI into the model/ interface #430
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,7 @@ | |
#include <uint256.h> | ||
#include <univalue.h> | ||
#include <util/check.h> | ||
#include <util/strencodings.h> | ||
#include <util/translation.h> | ||
#include <validation.h> | ||
#include <validationinterface.h> | ||
|
@@ -169,6 +170,27 @@ class NodeImpl : public Node | |
} | ||
void mapPort(bool use_upnp, bool use_natpmp) override { StartMapPort(use_upnp, use_natpmp); } | ||
bool getProxy(Network net, Proxy& proxy_info) override { return GetProxy(net, proxy_info); } | ||
std::string defaultProxyAddress() override | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't believe this should return a string. I think it should be an in/out Proxy&. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is just for display purposes, it doesn't make sense to build the object which also involves |
||
{ | ||
return std::string(DEFAULT_PROXY_HOST) + ":" + ToString(DEFAULT_PROXY_PORT); | ||
} | ||
bool validateProxyAddress(const std::string& addr_port) override | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. validateProxyAddress shouldn't be in this module. It should exist in the nodemodel or possibly in netbase. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree, maybe it could be moved deeper into de netbase but I didn't what to touch that at this stage, it can be done later once we update the interfaces upstream. |
||
{ | ||
uint16_t port{0}; | ||
std::string hostname; | ||
// First, attempt to split the input address into hostname and port components. | ||
// We call SplitHostPort to validate that a port is provided in addr_port. | ||
// If either splitting fails or port is zero (not specified), return false. | ||
if (!SplitHostPort(addr_port, port, hostname) || !port) return false; | ||
|
||
// Create a service endpoint (CService) from the address and port. | ||
// If port is missing in addr_port, DEFAULT_PROXY_PORT is used as the fallback. | ||
CService serv(LookupNumeric(addr_port, DEFAULT_PROXY_PORT)); | ||
|
||
// Construct the Proxy with the service endpoint and return if it's valid | ||
Proxy addrProxy = Proxy(serv, true); | ||
return addrProxy.IsValid(); | ||
} | ||
size_t getNodeCount(ConnectionDirection flags) override | ||
{ | ||
return m_context->connman ? m_context->connman->GetNodeCount(flags) : 0; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these actually default settings values or just values presented to the user? If they are just hints, they can be left as strings in the QML.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are proper default values. I would leave them here for now, but maybe they can be moved into the netbase later.