Skip to content
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

Setting app.Server().MaxConnsPerIP🐛 #1456

Closed
ncbarta opened this issue Jul 28, 2021 · 7 comments · Fixed by #1503
Closed

Setting app.Server().MaxConnsPerIP🐛 #1456

ncbarta opened this issue Jul 28, 2021 · 7 comments · Fixed by #1503

Comments

@ncbarta
Copy link

ncbarta commented Jul 28, 2021

Fiber version
v2.15.0
Issue description
Setting app.Server().MaxConnsPerIP() = x
either causes the server to use http instead of https/tls, or it causes c.Secure() and c.Protocol() to give false information.
This could also simply be by design. If so, it should be made less transparent to users.
Code snippet

package main

import (
	"fmt"
	"os"
	"path/filepath"

	"github.com/gofiber/fiber/v2"
)

func main() {
	rootDir, err := filepath.Abs(filepath.Dir(os.Args[0]))
	if err != nil {
		panic("rootdir not found")
	}

	app := fiber.New(fiber.Config{
		EnableTrustedProxyCheck: true,
		Network:                 "tcp4", //Observation: specifing tcp makes the listener on https://[::]:443, and tcp4 makes 127.0.0.1:443
		Prefork:                 false,
	})

	// app.Server().MaxConnsPerIP = 4

	app.Get("/", func(c *fiber.Ctx) error {
		//openssl s_client -connect localhost:443
		//c.Protocol gives http, even though it looks like https on wireshark, however I lack the testing abilities to know.
		//The bug could be either that the traffic is not using tls, or that the following functions are giving the wrong info.
		fmt.Println(c.Secure())
		return c.SendString(c.Protocol())
	})

	CA_certPath := filepath.Join(rootDir, "cert", "cert.pem")
	CA_keyPath := filepath.Join(rootDir, "cert", "key.pem")

	app.ListenTLS(":443", CA_certPath, CA_keyPath)
}
@welcome
Copy link

welcome bot commented Jul 28, 2021

Thanks for opening your first issue here! 🎉 Be sure to follow the issue template! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord

@tysg
Copy link

tysg commented Aug 2, 2021

Is anyone working on this? If not, may I work on it? I'm investigating on the issue, and it could be an upstream error in fasthttp

@ReneWerner87
Copy link
Member

I don't think anyone is working on this yet, you are welcome to do it.

@tysg
Copy link

tysg commented Aug 2, 2021

Looks like it's an upstream issue in fasthttp. I've submitted an issue at valyala/fasthttp#1062

@tysg
Copy link

tysg commented Aug 6, 2021

The issue has since been fixed. Let's upgrade the fasthttp version when they make the next release :)

@ReneWerner87
Copy link
Member

ok thx for the hint

@ncbarta
Copy link
Author

ncbarta commented Aug 17, 2021

https://github.com/valyala/fasthttp/releases/tag/v1.29.0 new release has been made

Thank you @tysg for your investigation and solution!

@ncbarta ncbarta closed this as completed Aug 17, 2021
@ReneWerner87 ReneWerner87 linked a pull request Aug 22, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants