1 From fa51c56049a99ef17d86b0327bcf66f47338da45 Mon Sep 17 00:00:00 2001
2 From: Morgan Helton <mhelton@gmail.com>
3 Date: Sun, 26 May 2024 12:17:01 -0500
4 Subject: [PATCH] envoy: allow specification of external binary
7 pkg/envoy/envoy.go | 17 ++++++++++-------
8 1 file changed, 10 insertions(+), 7 deletions(-)
10 diff --git a/pkg/envoy/envoy.go b/pkg/envoy/envoy.go
11 index 62f2d34c..879001cd 100644
12 --- a/pkg/envoy/envoy.go
13 +++ b/pkg/envoy/envoy.go
14 @@ -8,9 +8,9 @@ import (
25 @@ -34,8 +34,12 @@ import (
28 configFileName = "envoy-config.yaml"
29 + workingDirectoryName = ".pomerium-envoy"
30 + embeddedEnvoyPermissions fs.FileMode = 0o700
33 +var OverrideEnvoyPath = ""
35 type serverOptions struct {
37 logLevel config.LogLevel
38 @@ -58,17 +62,16 @@ type Server struct {
40 // NewServer creates a new server with traffic routed by envoy.
41 func NewServer(ctx context.Context, src config.Source, builder *envoyconfig.Builder) (*Server, error) {
42 - if err := preserveRlimitNofile(); err != nil {
43 - log.Debug(ctx).Err(err).Msg("couldn't preserve RLIMIT_NOFILE before starting Envoy")
45 + envoyPath := OverrideEnvoyPath
46 + wd := filepath.Join(os.TempDir(), workingDirectoryName)
48 - envoyPath, err := Extract()
49 + err := os.MkdirAll(wd, embeddedEnvoyPermissions)
51 - return nil, fmt.Errorf("extracting envoy: %w", err)
52 + return nil, fmt.Errorf("error creating temporary working directory for envoy: %w", err)
56 - wd: path.Dir(envoyPath),
59 grpcPort: src.GetConfig().GRPCPort,
60 httpPort: src.GetConfig().HTTPPort,