Skip to content

Conversation

kevkevinpal
Copy link
Contributor

right now for -torcontrol you can pass in any string as long as it doesn't have a : but that is invalid. I added an additional check before calling SplitHostPort to see if there is a :

closes #23589

right now for -torcontrol you can pass in any string as long as it
doesn't have a : but that is invalid. I added an additional check before
calling SplitHostPort to see if there is a :
@DrahtBot
Copy link
Contributor

DrahtBot commented Jun 30, 2023

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Reviews

See the guideline for information on the review process.

Type Reviewers
Concept NACK luke-jr

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

@kevkevinpal
Copy link
Contributor Author

Screenshot 2023-06-30 at 4 40 24 PM
Screenshot 2023-06-30 at 4 40 12 PM
Screenshot 2023-06-30 at 4 39 51 PM

@Ayush170-Future
Copy link
Contributor

Ayush170-Future commented Jul 2, 2023

Overall, I think the code is good. However, there have been some earlier remarks in this comment on where to place this code.

Someone with a better understanding of the entire codebase should comment on the placement of this.

In any case, I'm testing it locally and will report back on whether it meets the requirements soon (one suggestion I think you should avoid using / in the branch name)

@kevkevinpal
Copy link
Contributor Author

Overall, I think the code is good. However, there have been some earlier remarks in this comment on where to place this code.

Someone with a better understanding of the entire codebase should comment on the placement of this.

In any case, I'm testing it locally and will report back on whether it meets the requirements soon (one suggestion I think you should avoid using / in the branch name)

Yea I could totally move the logic to a util or somewhere other than init.cpp since there might be too much logic in there. Not exactly sure where would be the best spot.

Also another thing I wanted to clarify is that will -torcontrol always be in the format of host:port or is there ever a chance of being abe to just provide one or the other? because then we can try splitting and validating each part individually

@Ayush170-Future
Copy link
Contributor

Tested this locally.

  1. Any string that is not of the type <host>:<port> is rejected.
    Example: ./src/bitcoind -torcontrol=1.

  2. Also works for Domain names.
    Example: ./src/bitcoind -torcontrol=localhost:9051 is accepted.

  3. But multiple instances of : are also accepted.
    Example: ./src/bitcoind -torcontrol=localhost:9051:23 is also accepted.
    This should also be avoided, right?

Also another thing I wanted to clarify is that will -torcontrol always be in the format of host:port or is there ever a chance of being abe to just provide one or the other? because then we can try splitting and validating each part individually

Yes, I think -torcontrol should always be of form <host>:<port>.

Copy link
Member

@luke-jr luke-jr left a comment

Choose a reason for hiding this comment

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

Concept NACK. Port isn't required (the default is 9051). Furthermore, even "1" is a valid value (it would be the same as 0.0.0.1:9051), though I suppose it wouldn't hurt to check for it specifically and reject it.

@Ayush170-Future
Copy link
Contributor

A gentle ping to @luke-jr, what about this issue then? 23589

@willcl-ark willcl-ark closed this Jul 11, 2023
@willcl-ark willcl-ark reopened this Jul 11, 2023
@willcl-ark
Copy link
Member

Unrelated to the actual implementation in this PR, but I disagree with some of Luke's points:

Port isn't required (the default is 9051).

The way this is currently documented, both host and port should be required. However, it does align with many of our other options to have a default port, and if that makes sense here too then the help for torcontrol arg should be updated to show port as optional as a first step.

Furthermore, even "1" is a valid value (it would be the same as 0.0.0.1:9051), though I suppose it wouldn't hurt to check for it specifically and reject it.

Whilst this is technically true for low-level networking (code), IMO it's extremely un-common to not require users to use dot-decimal notation for hosts, and I think we should reject non dot-decimal hosts to prevent exactly the issue in #23589. We'll lose no flexibility by doing so as users who want to use 0.0.0.1 can just, set the option to that directly?

@kevkevinpal
Copy link
Contributor Author

The way this is currently documented, both host and port should be required. However, it does align with many of our other options to have a default port, and if that makes sense here too then the help for torcontrol arg should be updated to show port as optional as a first step.

I think it makes sense to make the port optional if that is also what is being done for the other options.

Whilst this is technically true for low-level networking (code), IMO it's extremely un-common to not require users to use dot-decimal notation for hosts, and I think we should reject non dot-decimal hosts to prevent exactly the issue in #23589. We'll lose no flexibility by doing so as users who want to use 0.0.0.1 can just, set the option to that directly?

one of my concerns is that if there are users not using non dot-decimal hosts then it would cause breakage for those users if we begin to reject non dot-decimal hosts

do we reject non dot-decimal hosts anywhere else in this codebase?

@kevkevinpal
Copy link
Contributor Author

closing this PR for now since this #28101 should fix the issue, the PR just changes the helper text to explain that a default port is included but no additional checks are added

@kevkevinpal kevkevinpal closed this Sep 5, 2023
achow101 added a commit to bitcoin-core/gui that referenced this pull request Sep 12, 2023
… to specify that a default port is used

9a84200 doc, refactor: Changing -torcontrol help to specify that a default port is used (kevkevin)

Pull request description:

  Right now when we get the help for -torcontrol it says that there is a default ip and port we dont specify if there is a specified ip that we would also use port 9051 as default

  Also I create a new const instead of using 9051 directly in the function

  linking this PR because this was discussed here bitcoin/bitcoin#28018

ACKs for top commit:
  jonatack:
    re-ACK 9a84200
  achow101:
    ACK 9a84200
  MarnixCroes:
    utACK 9a84200
  kristapsk:
    utACK 9a84200

Tree-SHA512: 21d9e65f3c280a2853a9cf60d4e93e8d72caccea106206d1862c19535bde7ea6ada7f55e6ea19a1fc0f59dbe791ec6fc4084fdbe7fa6d6991fa89c62070db637
Frank-GER pushed a commit to syscoin/syscoin that referenced this pull request Sep 19, 2023
…ify that a default port is used

9a84200 doc, refactor: Changing -torcontrol help to specify that a default port is used (kevkevin)

Pull request description:

  Right now when we get the help for -torcontrol it says that there is a default ip and port we dont specify if there is a specified ip that we would also use port 9051 as default

  Also I create a new const instead of using 9051 directly in the function

  linking this PR because this was discussed here bitcoin#28018

ACKs for top commit:
  jonatack:
    re-ACK 9a84200
  achow101:
    ACK 9a84200
  MarnixCroes:
    utACK 9a84200
  kristapsk:
    utACK 9a84200

Tree-SHA512: 21d9e65f3c280a2853a9cf60d4e93e8d72caccea106206d1862c19535bde7ea6ada7f55e6ea19a1fc0f59dbe791ec6fc4084fdbe7fa6d6991fa89c62070db637
@bitcoin bitcoin locked and limited conversation to collaborators Sep 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

init: torcontrol argument should be validated
5 participants