mirror of
https://github.com/pomerium/pomerium.git
synced 2025-08-01 16:01:26 +02:00
very bad demo code
This commit is contained in:
parent
b4aa275403
commit
d588135b3a
30 changed files with 1308 additions and 248 deletions
|
@ -1,9 +1,6 @@
|
|||
package envoy
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"hash"
|
||||
"io"
|
||||
|
@ -13,8 +10,6 @@ import (
|
|||
"sync"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
|
||||
"github.com/pomerium/pomerium/pkg/envoy/files"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -76,34 +71,6 @@ func Extract() (fullEnvoyPath string, err error) {
|
|||
return setupFullEnvoyPath, setupErr
|
||||
}
|
||||
|
||||
func extract(dstName string) (err error) {
|
||||
checksum, err := hex.DecodeString(strings.Fields(files.Checksum())[0])
|
||||
if err != nil {
|
||||
return fmt.Errorf("checksum %s: %w", files.Checksum(), err)
|
||||
}
|
||||
|
||||
hr := &hashReader{
|
||||
Hash: sha256.New(),
|
||||
r: bytes.NewReader(files.Binary()),
|
||||
}
|
||||
|
||||
dst, err := os.OpenFile(dstName, os.O_CREATE|os.O_WRONLY, ownerRX)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer func() { err = dst.Close() }()
|
||||
|
||||
if _, err = io.Copy(dst, io.LimitReader(hr, maxExpandedEnvoySize)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
sum := hr.Sum(nil)
|
||||
if !bytes.Equal(sum, checksum) {
|
||||
return fmt.Errorf("expected %x, got %x checksum", checksum, sum)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func cleanTempDir(tmpDir string) {
|
||||
d, err := os.Open(tmpDir)
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue