8000 create Address message with SocketAddr, get SocketAddr from Address m… by tamasblummer · Pull Request #64 · rust-bitcoin/rust-bitcoin · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

create Address message with SocketAddr, get SocketAddr from Address m… #64

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

Merged
merged 1 commit into from
Mar 23, 2018

Conversation

tamasblummer
Copy link
Contributor

…essage.

Creating addr message for a socket or socket from an addr message is a common task upstream. It makes sense to support in this base library.

@tamasblummer tamasblummer requested a review from apoelstra March 20, 2018 16:29
@apoelstra
Copy link
Member

cc @TheBlueMatt can you review this?

If not I can do it this week.

Copy link
Member
@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

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

Looks good, would like a check to make sure the Address isnt a bitcoin-tor-wrapped one before converting to a socket_addr, though.

#[test]
fn test_socket_addr () {
let s4 = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(111,222,123,4)), 5555);
let a4 = Address::new(&s4, 9);
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a test that this mapps correctly to bitcoin's ipv6-mapped addresses? I assume its correct, but good to check as IIRC there are multiple ways to map (I belive Bitcoin uses the ::ffff:IPv4 one, but should double-check).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is what Ipv6Addr::to_ipv4 checks and I used in Address::socket_addr() therefore the test should never fail.

Copy link
Member

Choose a reason for hiding this comment

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

Sure, I'm just saying cause I thought somehow there were multiple ways to wrap IPv4 in IPv6 (though it appears ::ffff:... is now standard), so wanted a check that it actually is using the one we expected. Does'nt matter much, though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

see in deserialize_address_test

}

/// extract socket address from an address message
pub fn socket_addr (&self) -> SocketAddr {
Copy link
Member

Choose a reason for hiding this comment

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

You should have a check that the contained addr isnt a Tor-wrapped one and return a Result<>, sadly, I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please give me a pointer how that is recognized. I did not yet deal with tor at this level.

Copy link
Member

Choose a reason for hiding this comment

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

@tamasblummer
Copy link
Contributor Author

addressed comments and squashed commits

@tamasblummer tamasblummer force-pushed the address_socket branch 5 times, most recently from d6cc04b to 9819bfb Compare March 23, 2018 12:06
@tamasblummer
Copy link
Contributor Author

@apoelstra please remove rust 1.14 check if there is no good reason for it.

@TheBlueMatt
Copy link
Member
TheBlueMatt commented Mar 23, 2018 via email

@tamasblummer
Copy link
Contributor Author

updated for rust 1.14 squashed.

Copy link
Member
@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

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

LGTM

@apoelstra apoelstra merged commit cabac23 into rust-bitcoin:master Mar 23, 2018
@tamasblummer tamasblummer deleted the address_socket branch April 4, 2018 10:25
Tibo-lg pushed a commit to p2pderivatives/rust-bitcoin that referenced this pull request Sep 1, 2020
pankcuf pushed a commit to pankcuf/rust-dashcore that referenced this pull request Apr 16, 2025
…ing them (rust-bitcoin#64)

* quorum sigs from message

* quorum sigs from message

* quorum sigs from message

* more work

* more work

* more work

* more work

* more work

* work to get this working

* change

* change

* clean up

* fixes

* bls8

* fmt

* bump to version 39
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.

3 participants
0