-
Notifications
You must be signed in to change notification settings - Fork 42
connection is not closed when rejected by InterceptSecured #155
Comments
@marten-seemann Would you be able to create the PR for this or do you want me to create one ? |
@aarshkshah1992 Wouldn't it be better to call this callback during the TLS handshake, not after it's finished? |
@marten-seemann I am not sure it would be easy to source the local and remote multi-addresses for the connection that we require for calling However, I do NOT have an understanding of |
Yes, we'd probably have to make a slight change to the interface expose by that package. Maybe I'm not very familiar with the motivation behind the connection gater, is there any reason that |
@marten-seemann |
We can override the |
The
The same logic applies if we use TLS as a handshake protocol, so we probably should make the change there at the same time. Would it make sense to move the responsibility of calling |
It's not the handshake's responsibility to call Take a look at #156 -- I think it solves it elegantly, although ideally quic-go would expose these hooks so we're not hijacking the hook that the |
I'm not sure how such a hook would look like. quic-go is using crypto/tls (or rather, a fork thereof) to perform the handshake. My reasoning is the following: Since both go-libp2p-tls and go-libp2p-quic-transport use TLS 1.3 to perform the handshake, the behavior regarding the connection gater should be the same: Either we reject the handshake attempt during the handshake, as you've implemented in #156, or we do it after the handshake, as currently implemented in master (and just close the connection if that fails). I don't see any reason to treat TLS and QUIC different in that regard. |
@marten-seemann Our solution needs to cover Noise, SecIO, etc., not just TLS 1.3. We don't want to run around injecting the connection gater into all handshakes. Conceptually, it's the transport's responsibility to gate connections. It does so delegating to the upgrader (if the transport has no native security), or it does so explicitly. If we add this to the TLS 1.3 handshake directly, it would run twice for non-QUIC cases: once in the handshake, once in the upgrader. We can't remove the call from the upgrader, because that means we need to push the connection gater to the handshakes too, and also modify SecIO and Noise, which we definitely won't do. Handshakes are pretty lean, in the sense that they can operate purely on a |
Fair enough. Then I suggest we go with #157, instead of making QUIC a special case here. |
Why not? This seems pretty reasonable to me. If double checking is expensive, something is probably wrong. Basically, @marten-seemann's saying that we should either:
Checking early in some cases and later in others is inconsistent and confusing. |
@Stebalien I don't regard it as inconsistent. It's the transport's responsibility to gate accepted and secured connections. Some transports are entirely coupled with their handshake (because it's native), and can take advantage of the connection gater sooner. The correct way to do this would've been for quic-go to expose hooks during the connection pipeline. With the right hook, we could complete the handshake and then intercept the connection, just like the Upgrader is doing. But quic-go does not support hooks/callbacks (I remember seeing an issue for it somewhere), so we have to intercept the handshake itself. Since the hooks don't exist and QUIC and TLS are coupled, why not take advantage and intercept at the lower level? See the savings in #156 (comment). Also, our handshakes are pretty lean; they don't care about higher level libp2p constructs. Plus, pushing the connection gater to all handshakes will mean we'd call the gater from three places:
This proliferation is not good. Honestly, I think this discussion is outliving its purpose. In 2 days we won't even remember/look at this. I'm planning to close #157 and merge #156 tomorrow (Friday), but I'd like to have your buy-in that we disagree and commit on the premises that I've posted above. |
Thank you @Stebalien, that's an excellent summary of my argument.
Can you elaborate what this hook would do? I don't remember any hook-related issue in quic-go. As far as my understanding goes, this hook wouldn't do anything other than exactly what #157 implements. The same applies to |
Re: the architecture question, the right interception point for When the latter happens, The right hooks in quic-go would allow us to:
|
See #152 (review).
The text was updated successfully, but these errors were encountered: