Skip to content
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

Make bootstrap daemon use toxcore's version #875

Merged
merged 1 commit into from
Jun 25, 2018

Conversation

nurupo
Copy link
Member

@nurupo nurupo commented Apr 17, 2018

I have wanted to make the daemon report toxcore's version for quite a bit now, and here I finally I got around to doing this. The main motivation for this was the onion vulnerability #873. To fix the vulnerability, all DHT nodes should be updated to the new upcoming toxcore version. Reporting toxcore version in the bootstrap daemon would enable us to see at the very least if the bootstrap nodes are updated, my main interest being the the nodes that are listed on the https://nodes.tox.chat page which displays the daemon version of the nodes.

The daemon version is just a uint32_t, there is not much you can encode in 4 bytes. I have been thinking of packing the toxcore version into that uint32_t, 1 byte for major, 1 byte for minor, 1 byte for patch and 1 byte for misc: bit indicating that this is a new version scheme, a bit indicating that the daemon was build using a release checkpoint of toxcore rather than an in-development (there might be big differences between 2.x.y release and the same 2.x.y right before the version bump, containing all the changes for the next version). Such version encoding would be inconsistent with the previous one of YYYYMMDD, which you could print out as an number to show the version to the user, which is what nodes.tox.chat and a few other scrips do. With the packed version encoding the version would need to be decoded first, if you print the uint32_t as it is, it won't make sense. So to keep the compatibility with the way the daemon version is being printed by others I settled on a 1AAABBBCCC format, where AAA is the major version, BBB is the minor version and CCC is the patch version, all capped at 999. The leading 1 is just so that the leading zeros wouldn't get removed when printing it as a number, e.g. instead of 0.2.1 being printed as 2001, it would be printed as 1000002001, i.e. 000.002.001.


This change is Reviewable

@nurupo nurupo requested a review from iphydf April 17, 2018 04:09
@CLAassistant
Copy link

CLAassistant commented Apr 17, 2018

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@kpp
Copy link

kpp commented Apr 17, 2018

You are overcomplicating the issue.

Previously it used to be define DAEMON_VERSION_NUMBER 2016010100UL. Nothing stops you from updating it to define DAEMON_VERSION_NUMBER 2018041700UL .

Don't forget you are not the only one who is implementing toxcore. These changes are changes in protocol and must be discussed with all implementors of tox.

@iphydf
Copy link
Member

iphydf commented Apr 17, 2018

The bootstrap Daemon version response isn't part of the specified protocol. It should be, but until then the implementation is the definition. I think we can make this change and then write it down so others can implement it.

@kpp
Copy link

kpp commented Apr 17, 2018

The bootstrap Daemon version response isn't part of the specified protocol.

That is not the reason to make your implementation become the part of the specified protocol since there are a lot of programs that check the version of tox with the given packet. You are going to break them. Why?

My suggestion is to write down a document that standardize the current situation. If 4 bytes is not enough for you we may keep 128 bytes of version info.

Please stop juggling with bits and bytes. You have done enough which led to #873

@iphydf
Copy link
Member

iphydf commented Apr 17, 2018

Yes, agree. We should make sure those programs support the new version format before releasing this change. Do you know of other programs besides the node list?

@kpp
Copy link

kpp commented Apr 17, 2018

Do you know of other programs besides the node list?

https://github.com/irungentoo/toxcore/blob/master/other/fun/bootstrap_node_info.py
https://github.com/TokTok/c-toxcore/blob/master/other/fun/bootstrap_node_info.py
https://github.com/tox-rs/tox/blob/master/src/toxcore/dht/packet.rs#L1095

The vulnerability was found in tox-rs/tox, as it was described by Evgeniy in #873. You are not the only one implementors of tox in the world.

@nurupo
Copy link
Member Author

nurupo commented Apr 17, 2018

Previously it used to be define DAEMON_VERSION_NUMBER 2016010100UL. Nothing stops you from updating it to define DAEMON_VERSION_NUMBER 2018041700UL.

Right, I could update it like that, but it would be more meaningful if the version reflected the toxcore version instead. The daemon usually doesn't change much at all, it can stay for a year without a single change aside from refactoring, yet toxcore changes a lot faster and changes the daemon's behavior, like the recent DHT changes in toxcore aimed to reduce the bandwidth consumption.

Don't forget you are not the only one who is implementing toxcore. These changes are changes in protocol and must be discussed with all implementors of tox.

It would make sense to extend the daemon's version information to include daemon name and version and the name and version of the toxcore implementation it uses then. Don't think this is going to fit into 4 bytes though, we'd likely need some string for that, so some spec change is needed.

Please stop juggling with bits and bytes. You have done enough which led to #873

Are you asking everyone to stop coding? Now that's rude and inappropriate of you.

@kpp
Copy link

kpp commented Apr 17, 2018

Right, I could update it like that

Would you please do it!

It would make sense to extend the daemon's version information to include daemon name and version and the name and version of the toxcore implementation it uses then.

Then let's do it! Make 2 new packets, call them REQ_VERSION, RESP_VERSION, let them be in semver syntax (128 bytes) + date + 128 byte comment. What stops you from making things like that?

@nurupo
Copy link
Member Author

nurupo commented Apr 17, 2018

That is not the reason to make your implementation become the part of the specified protocol since there are a lot of programs that check the version of tox with the given packet. You are going to break them. Why?

The bootstrap version is defined just as a 32 bit word in the spec, the spec doesn't specify versioning scheme, it's up to an implementation, it could be anything, there could be another bootstrap daemon implementation somewhere that doesn't follow tox-boostrapd's versioning scheme of YYYYMMDDVV. Also, all programs that check the bootstrap version that I know of: bootstrap_node_info and Tox Status treat it as an integer without any regards to its scheme just as the spec defines it. What I have proposed doesn't break the spec nor those programs printing the version, it's still a 32 bit word as defined in the spec. So, what breakage are you talking about here exactly?

@kpp
Copy link

kpp commented Apr 17, 2018

The bootstrap version is defined just as a 32 bit word in the spec

So will you update docs according to your PR or no? If you will not then it is fine for you to make any changes. Have fun!

@sudden6
Copy link

sudden6 commented Apr 17, 2018

This field seems to specify only informational stuff and not something code should depend on (yet), so I think @nurupo is right that it should be mostly human readable. In a future version I'd like to have a better specified versioning scheme + a comment/implementation name string.

@nurupo
Copy link
Member Author

nurupo commented Apr 17, 2018

Then let's do it! Make 2 new packets, call them REQ_VERSION, RESP_VERSION, let them be in semver syntax (128 bytes) + date + 128 byte comment. What stops you from making things like that?

I don't think that there is anything that stops anyone from proposing changes to the spec. Is there?

So will you update docs according to your PR or no? If you will not then it is fine for you to make any changes. Have fun!

If what you want is to improve the spec by making the definition of a bootstrap version more detailed than a 32 bit word, i.e. define the exact versioning scheme that all bootstrap daemons need to follow, instead of leaving it up to an implementation, or define a new bootstrap version packet, you should open a discussion/proposal thread against the spec repository and discuss it in there, instead of discussing it in a PR that makes a spec compatible and non-breaking change to an implementation of a bootstrap daemon. What stops you from doing that?

@sudden6
Copy link

sudden6 commented Apr 24, 2018

:lgtm_strong:


Reviewed 1 of 1 files at r1.
Review status: all files reviewed at latest revision, all discussions resolved, some commit checks failed.


Comments from Reviewable

@iphydf
Copy link
Member

iphydf commented Jun 20, 2018

:lgtm_strong:

This is compliant with the spec as written.


Reviewed 1 of 1 files at r1.
Review status: :shipit: complete! 2 of 1 LGTMs obtained


Comments from Reviewable

@iphydf iphydf added this to the v0.2.3 milestone Jun 20, 2018
@iphydf
Copy link
Member

iphydf commented Jun 20, 2018

Please rebase onto master and optionally fast-forward master onto it.

@iphydf iphydf removed their request for review June 20, 2018 22:56
@iphydf iphydf modified the milestones: v0.2.3, v0.2.x Jun 24, 2018
@nurupo
Copy link
Member Author

nurupo commented Jun 25, 2018

@iphydf rebased.

@iphydf iphydf merged commit 7684b5a into TokTok:master Jun 25, 2018
@iphydf iphydf removed this from the v0.2.x milestone Jun 25, 2018
@iphydf iphydf added this to the v0.2.3 milestone Jun 25, 2018
iphydf added a commit to iphydf/c-toxcore that referenced this pull request Sep 5, 2018
v0.2.3
**Merged PRs:**

- [TokTok#951] Only run astyle if the astyle binary exists.
- [TokTok#950] Remove utils.c and utils.h from toxencryptsave build.
- [TokTok#949] Fixes to the imported sodium sources to compile without warnings.
- [TokTok#948] Add a MAX_HOSTNAME_LENGTH constant.
- [TokTok#947] Remove the format test.
- [TokTok#937] Add new Circle CI configuration.
- [TokTok#935] Add a test for double conference invite.
- [TokTok#933] Add Logger to various net_crypto functions, and add `const` to Logger where possible.
- [TokTok#931] Avoid conditional-uninitialised warning for tcp test.
- [TokTok#930] Disable UDP when proxy is enabled.
- [TokTok#928] Use clang-format for C++ code.
- [TokTok#927] Add assertions to bootstrap tests for correct connection type.
- [TokTok#926] Make NULL options behave the same as default options.
- [TokTok#925] Add tests for what happens when passing an invalid proxy host.
- [TokTok#924] Make the net_crypto connection state an enum.
- [TokTok#922] Clarify/Improve test_some test
- [TokTok#921] Beginnings of a TCP_test.c overhaul
- [TokTok#920] Add test for creating multiple conferences in one tox.
- [TokTok#918] Merge irungentoo/master into toktok
- [TokTok#917] Add random testing program.
- [TokTok#916] Fix linking with address sanitizer.
- [TokTok#915] Remove resource_leak_test.
- [TokTok#914] Make dht_test more stable.
- [TokTok#913] Minor cleanup: return early on error condition.
- [TokTok#906] Sort bazel build file according to buildifier standard.
- [TokTok#905] In DEBUG mode, make toxcore crash on signed integer overflow.
- [TokTok#902] Log only the filename, not the full path in LOGGER.
- [TokTok#899] Fix macOS macro because of GNU Mach
- [TokTok#898] Fix enumeration of Crypto_Connection instances
- [TokTok#897] Fix ipport_isset: port 0 is not a valid port.
- [TokTok#894] Fix logging related crash in bootstrap node
- [TokTok#893] Fix bootstrap crashes, still
- [TokTok#892] Add empty logger to DHT bootstrap daemons.
- [TokTok#887] Fix FreeBSD build on Travis
- [TokTok#884] Fix the often call of event tox_friend_connection_status
- [TokTok#883] Make toxcore compile on BSD
- [TokTok#878] fix DHT_bootstrap key loading
- [TokTok#877] Add minitox to under "Other resources" section in the README
- [TokTok#875] Make bootstrap daemon use toxcore's version
- [TokTok#867] Improve network error reporting on Windows
- [TokTok#841] Only check full rtp offset if RTP_LARGE_FRAME is set
- [TokTok#823] Finish @Diadlo's network Family abstraction.
- [TokTok#822] Move system header includes from network.h to network.c
iphydf added a commit to iphydf/c-toxcore that referenced this pull request Sep 5, 2018
v0.2.3
**Merged PRs:**

- [TokTok#951] Only run astyle if the astyle binary exists.
- [TokTok#950] Remove utils.c and utils.h from toxencryptsave build.
- [TokTok#949] Fixes to the imported sodium sources to compile without warnings.
- [TokTok#948] Add a MAX_HOSTNAME_LENGTH constant.
- [TokTok#947] Remove the format test.
- [TokTok#937] Add new Circle CI configuration.
- [TokTok#935] Add a test for double conference invite.
- [TokTok#933] Add Logger to various net_crypto functions, and add `const` to Logger where possible.
- [TokTok#931] Avoid conditional-uninitialised warning for tcp test.
- [TokTok#930] Disable UDP when proxy is enabled.
- [TokTok#928] Use clang-format for C++ code.
- [TokTok#927] Add assertions to bootstrap tests for correct connection type.
- [TokTok#926] Make NULL options behave the same as default options.
- [TokTok#925] Add tests for what happens when passing an invalid proxy host.
- [TokTok#924] Make the net_crypto connection state an enum.
- [TokTok#922] Clarify/Improve test_some test
- [TokTok#921] Beginnings of a TCP_test.c overhaul
- [TokTok#920] Add test for creating multiple conferences in one tox.
- [TokTok#918] Merge irungentoo/master into toktok
- [TokTok#917] Add random testing program.
- [TokTok#916] Fix linking with address sanitizer.
- [TokTok#915] Remove resource_leak_test.
- [TokTok#914] Make dht_test more stable.
- [TokTok#913] Minor cleanup: return early on error condition.
- [TokTok#906] Sort bazel build file according to buildifier standard.
- [TokTok#905] In DEBUG mode, make toxcore crash on signed integer overflow.
- [TokTok#902] Log only the filename, not the full path in LOGGER.
- [TokTok#899] Fix macOS macro because of GNU Mach
- [TokTok#898] Fix enumeration of Crypto_Connection instances
- [TokTok#897] Fix ipport_isset: port 0 is not a valid port.
- [TokTok#894] Fix logging related crash in bootstrap node
- [TokTok#893] Fix bootstrap crashes, still
- [TokTok#892] Add empty logger to DHT bootstrap daemons.
- [TokTok#887] Fix FreeBSD build on Travis
- [TokTok#884] Fix the often call of event tox_friend_connection_status
- [TokTok#883] Make toxcore compile on BSD
- [TokTok#878] fix DHT_bootstrap key loading
- [TokTok#877] Add minitox to under "Other resources" section in the README
- [TokTok#875] Make bootstrap daemon use toxcore's version
- [TokTok#867] Improve network error reporting on Windows
- [TokTok#841] Only check full rtp offset if RTP_LARGE_FRAME is set
- [TokTok#823] Finish @Diadlo's network Family abstraction.
- [TokTok#822] Move system header includes from network.h to network.c
This pull request was closed.
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.

5 participants