Skip to content

networking: support private IPs#513

Merged
philippwerner merged 4 commits into
developfrom
features/2025-08-21-private-ips
Aug 26, 2025
Merged

networking: support private IPs#513
philippwerner merged 4 commits into
developfrom
features/2025-08-21-private-ips

Conversation

@krypdkat

Copy link
Copy Markdown
Contributor

#508
add #define NUMBER_OF_PRIVATE_IP X such that the node won't share first X IP addresses in the bootstrap list in exchangePeerAddress (handshake) packet, these IPs won't be deleted from public peer.
Reason: allowing operators to have private connections to the node, easier to control nodes if it getting DDoS

Comment thread src/network_core/peers.h Outdated
return;
}

if (isPrivateIp(address.u8))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the private IP not anyways already contained in the initial knownPublicPeers? if yes, the function will already return in line 459 for a private IP

Comment thread src/qubic.cpp Outdated
@@ -6964,7 +6964,8 @@ EFI_STATUS efi_main(EFI_HANDLE imageHandle, EFI_SYSTEM_TABLE* systemTable)
{
// randomly select verified public peers
const unsigned int publicPeerIndex = random(numberOfPublicPeers);

@J0ET0M J0ET0M Aug 21, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could it be more efficient when we add a lower bound for the random function?

e.g. random(NUMBER_OF_PRIVATE_IP,numberOfPublicPeers)

to get only a random peer from the "public" list. this would avoid the extra check with isPrivateIp(..)

inline static unsigned int random_range(unsigned int min, unsigned int max)
{
    unsigned int value;
    _rdrand32_step(&value);

    // Ensure range is valid
    unsigned int range = max - min + 1;

    return min + (value % range);
}

@krypdkat

Copy link
Copy Markdown
Contributor Author

thanks, addressed both comments @Franziska-Mueller @J0ET0M

Comment thread src/qubic.cpp Outdated
// randomly select verified public peers
const unsigned int publicPeerIndex = random(numberOfPublicPeers);
if (publicPeers[publicPeerIndex].isHandshaked /*&& publicPeers[publicPeerIndex].isFullnode*/)
// randomly select verified public peers and discard private IPs

@J0ET0M J0ET0M Aug 21, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this lead to an infinite loop when handshaked numberOfPublicPeers - NUMBER_OF_PRIVATE_IP < NUMBER_OF_EXCHANGED_PEERS

if yes we can also fill it with request->peers[j].u32 = 0;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we don't delete IP from bootstrap list numberOfPublicPeers should always > NUMBER_OF_PRIVATE_IP

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but I can add a check for future safety

@philippwerner philippwerner merged commit e13ac4c into develop Aug 26, 2025
1 check passed
hackerby888 added a commit to hackerby888/qubic-core-lite that referenced this pull request Aug 27, 2025
* Verify SC files automatically (qubic#506)

* compliance changes for CCF SC

* compliance changes for GQMPROP SC

* compliance changes for MSVAULT SC

* compliance changes for QEARN SC

* compliance changes for QBAY SC

* compliance changes for QUOTTERY SC

* compliance changes for QUTIL SC

* compliance changes for QX SC

* Qx: add div type explicitly to fix compile errors in test project

* compliance changes for TestExampleD SC

* add contract verify workflow

* Update contract-verify.yml

* update branch name in contract-verify.yml

* find all contract files to verify

* fix typo in contract-verify.yml

* print full path to file list

* use list of contract files as input for verify action

* only trigger contract-verify.yml when contract files or workflow file changed

* use published action in contract-verify.yml

* Revert "use published action in contract-verify.yml"

This reverts commit 6fbd535.

* mention contract verification tool in contracts.md

* make QPI div and mod constexpr

* update contract verify tool text in contracts.md

* add STATIC_ASSERT macro to enable use of static asserts in SC files

* remove workflow trigger on feature branch before merging into develop

* contributing doc: add paragraph about curly braces style

* update contract guidelines (qubic#512)

* remove unused defines that clash with QPI definitions

* fix: fixed gtest bug in qearn (qubic#516)

* fix: fixed gtest bug in qearn

* fix: removed unnecessary local variables in BEGIN_EPOCH procedure

* update contract verify tool to v0.3.3-beta

* Fix incorrect vc optimization of FourQ for release mode. (qubic#517)

* Add unittest for fourq.

* Fix MSVC misoptimization causing incorrect operation ordering.

* Unittest: Ensure FourQ is initialized if signature verification is used in contract testing.

* Add comment for optimization bug of MSVC.

* networking: support private IPs (qubic#513)

* nw: support private IPs

* remove redundant code

* fix warning

* add checking boundary when accessing publicPeers

* Fix bug relate to invalid mining seed of qpi mining. (qubic#518)

* update params for epoch 176 / v1.257.0

* Increase target tick duration

The delay function did not work due to bugs. Now the delay function
works and tick time should decrease.

---------

Co-authored-by: Franziska Mueller <11660876+Franziska-Mueller@users.noreply.github.com>
Co-authored-by: TakaYuPP <yutotaka24@gmail.com>
Co-authored-by: cyber-pc <165458555+cyber-pc@users.noreply.github.com>
Co-authored-by: dkat <39078779+krypdkat@users.noreply.github.com>
Co-authored-by: fnordspace <qubic@fnord.space>
@Franziska-Mueller Franziska-Mueller deleted the features/2025-08-21-private-ips branch April 23, 2026 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants