-
Notifications
You must be signed in to change notification settings - Fork 52
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
Add sock
to stream connect parameters
#344
Conversation
8ff5ba0
to
053c806
Compare
add newline
f178df0
to
4d4fe83
Compare
sock
to stream connect parameters
Now everything looks good, the only issue i see is that its possible to create socket which is bound to
Why i think this is important, because different OS will start generate different |
@cheatfate good point, I will take a look. Maybe you could add some helpers to #354 for this, to check if IPv6 addresses are in the "ipv4 mapped range", and helpers to switch between the two? |
This helpers are already in there Problem is, what should we do? Do we need to raise an assert or we should perform some automatic actions... |
Indeed, I missed them, sorry! There is actually 3 place where the domain needs to match: If there is a mismatch somewhere, it will raise |
@cheatfate anything else blocking here? Do you want to create a specific TransportOsError exception and check for domain mismatchs in |
The greater problem, which somewhat goes in hand with ipv6 support, is the ownership question: after passing in a random socket, who is the owner of that socket? This has an effect on chronos in several ways, but above all, which assumptions chronos can make about it: is it blocking? is it dual stack? is it bound? what's the buffer size -> this in turns affects the API that chronos offers, or how "thin" of a layer it is. If a user passes in a socket which is blocking, should chronos force it to be non-blocking? This is a requirement for chronos to work, but whose responsibility is it to set the options? Should we instead expose some other socket-creation API that ensures that the socket has been created appropriately? Who closes it? Should there be a way to release the socket back to the application? what happens with in-flight requests? Before merging this PR, this architectural question should be answered, else we end up with an API that may become unsupportable. |
Note that this api type isn't new in chronos, it's based on the datagram transport that already allows to pass in an existing socket nim-chronos/chronos/transports/datagram.nim Line 652 in 77ffff3
|
After a long discussion of this PR with @arnetheduck, he points my attention that this PR has significant flaw. And it is my fault that this flaw appears (createServer() definition). And i think because of this i misguided you about same functionality for The problem i'm trying to describe is owner transfership. When When So the only way to go further is to add all the options and addresses into the connect call and remove |
Relevant to this PR as well: #25 Re ownership, we could indeed introduce that as an "official" API, meaning that chronos takes over ownership and becomes responsible for closing later on: it would also solve the problem of socket options where chronos would set all the options it needs on the socket. The key point would be that this needs to be made consistently clear in the API in some way: naming, The lack of solid ownership tracking in Nim will indeed open up the possibility for users to abuse ownership transfer (for example by using the socket after transferring ownership) - this is a general problem however and as long as the method we choose is well-documented and explicit, this risk is acceptable. |
#362 got merged instead |
In order to do hole punching, a peer must be able to bind to the same port as it is listening to during the dialling synchronization.