Skip to content

embed bdboot - #6

Open
dbear496 wants to merge 17 commits into
RetroShare:masterfrom
dbear496:bdboot-embed
Open

dbear496 wants to merge 17 commits into
RetroShare:masterfrom
dbear496:bdboot-embed

Conversation

@dbear496

@dbear496 dbear496 commented Nov 8, 2026 •

Copy link
Copy Markdown

Adds an option to embed the data from the bdboot.txt file directly into the library. This should be helpful for Windows platforms where libraries are expected to be self-contained without supporting data files.

depends on #3

- avoid globbing sources
- move platform-dependent compile options for bitdht from other projects 
to this one
- create an alias target for use by superproject
- avoid messing with RS_DATA_DIR globally
SMH it's so bad that this build system assumes where the user will place 
this repo relative to others.
@jolavillette

Copy link
Copy Markdown

Two things in the embed path:

  1. Byte order: the generated table stores host-order values (.s_addr=${addr_hex}, .sin_port=${port}), while reloadFromStore() goes through bdnet_inet_aton() and htons(port). On little-endian, the first bdboot.txt entry, 2.56.183.60 24012, would come out as 60.183.56.2 port 52317.
  2. RetroShare never reaches the embedded list: reloadFromStore() only falls back to it when mStoreFileBak is empty, and libretroshare always passes the install path as the backup file (rsinit.cc:1091-1096, empty only on Android). With both files missing it returns the failed backup read.

Also, the option is only ON on Windows, so the Linux and macOS packages still lack bdboot.txt.

@jolavillette

Copy link
Copy Markdown

With libretroshare 041579b81 the DHT now falls back to the embedded list (with the option on) when neither the account's nor the installed bdboot.txt is there. I built 9e2a4ae with -DBD_EMBED_BDBOOT=ON (Linux, Debian sid) and loaded a bdStore with no file: the addresses are right now, the ports aren't (2.56.183.60 gets port 52317 instead of 24012, 2.237.248.180 24035 instead of 58205). .sin_port=${port} needs htons() too.

@jolavillette

Copy link
Copy Markdown

Tested on Windows (Qt6, root 0bd21db62, lib 041579b81, BitDHT 9e2a4ae with htons() added to .sin_port): fresh profile (--base-dir on an empty dir), no bdboot.txt in the package or the profile, and the DHT indicator turns green. So with the port fix the embedded list is enough to bootstrap.

@jolavillette

Copy link
Copy Markdown

b06921e uses htonl() on the port instead of htons(). sin_port is 16 bits, so on x86 the value gets truncated to 0: with the same probe as before (Linux, Debian sid), the ports now come out as 0 (2.56.183.60 port 0, 2.237.248.180 port 0), and GCC warns narrowing conversion of 'htonl(24012)' from 'uint32_t' to 'in_port_t' on each line of the generated file. The line should be ".sin_port=htons(${port}),".

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.

2 participants