func getListenPeer(c *config.CherryRooms, port string) (net.Listener, error) { var listenConn net.Listener var listenError error if c.GetCertificatePath() != "" && c.GetPrivateKeyPath() != "" { cert, err := tls.LoadX509KeyPair(c.GetCertificatePath(), c.GetPrivateKeyPath()) if err != nil { return nil, err } secParams := &tls.Config{Certificates: []tls.Certificate{cert}} listenConn, listenError = tls.Listen("tcp", c.GetServerName()+":"+port, secParams) } else { listenConn, listenError = net.Listen("tcp", c.GetServerName()+":"+port) } return listenConn, listenError }