moonmq icon indicating copy to clipboard operation
moonmq copied to clipboard

The way to determine tcp/unix may be not so right.

Open ckrissun opened this issue 11 years ago • 2 comments
trafficstars

Take a look at this:

  n := "tcp"
  if strings.Contains(cfg.Addr, "/") {
      n = "unix"
  }

When cfg.Addr equals to ./server.sock, everything is ok. But what happen when cfg.Addr is server.sock? Absolutely, something goes wrong.

I notice that, when net.ResolveTCPAddr returns an error, then we can say cfg.Addr is a unix address

  n := "tcp"
  if _, err := net.ResolveTCPAddr("tcp", cfg.Addr); err != nil {
      n = "unix"
  }

Thanks!

ckrissun avatar Jun 23 '14 10:06 ckrissun

I see some other apps use above way to select tcp network and don't think it is a big problem because the config address is set by yourself, if you set invalid, dial will be error, you will be responsible for your configuration.

Thanks you!

siddontang avatar Jun 23 '14 11:06 siddontang

Yeah, I see. It's really the user's responsibility to do that. Maybe I just want to make everything right as possible as i can. Thank you.

ckrissun avatar Jun 23 '14 11:06 ckrissun