-
Notifications
You must be signed in to change notification settings - Fork 37
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
Does not work using net.Listener with TLS #24
Comments
Oh yes! So you doing something wrong, and I am doing it too! |
@gitfury You can use |
Hi,
I tried the same code, and used ConfigureServerAndConfig but it still does not work. |
|
Works, thank you! |
You can already do it by yourself, notice that func ConfigureOwnServer(s *fasthttp.Server) *http2.Server {
s2 := &http2.Server{
Adaptor: fasthttp2.NewServerAdaptor(s),
}
s.NextProto(http2.H2TLSProto, func(c net.Conn) error {
if c.RemoteAddr().String() != "127.0.0.1:8443" {
c.Close()
return errors.New("Not allowed")
}
return s2.ServeConn(c)
})
return s2
} |
Ah I see thank you! One more thing, on IOS Safari fasthttp2 does not seem to work, output doesn't seem to say anything but Safari cay "cannot parse response". Is this something you can replicate on your own end or am I doing something wrong again? |
Weird. I am able to access http2.gofiber.io from Safari on an iPhone. I'd say is something on your end? Can you enter http2.gofiber.io from there or it happens only on your own website? |
Ah it works, it was something on my end, I was connecting via http instead of https. Also, is there a way to handle new connections before they get parsed by fasthttp? I see the ConnState hook is similar to I'm looking for, but I also need to be able to close those connections and I cannot close the connection inside ConnState without getting a panic for "use of closed network connection". Or maybe there's a way I can use my TCP listener to accept the connection, then send it to fasthttp to handle it after? |
You can try to make your own net.Listener that wraps the original net.Listener. But, why do you want that? Can I know about your use case? |
To gather data about an IP making a connection and to be able to block or accept them before my server spends CPU time parsing their request, etc. |
Then you can use the example I gave you before in this comment. NextProto gets called after the TLS handshake, so fasthttp nor fasthttp2 will spend any time parsing any request on the NextProto callback. |
Yes, this works for http2. But I also want it to work for HTTP/1.1. EDIT:
I assume this has downsides though? Because fasthttp uses worker pools instead of goroutines, this shouldn't hurt the original performance too much right? or is there a way I can implement the worker pool myself, it seems unexported |
It seems as if using
fasthttp2.ConfigureServer(server)
does not work, even when the server is serving on a TLS listener. Am I doing something incorrect or is there no support for this?The text was updated successfully, but these errors were encountered: