diff --git a/pkg/proc/client.go b/pkg/proc/client.go index 5991ddd..bceb83a 100644 --- a/pkg/proc/client.go +++ b/pkg/proc/client.go @@ -20,7 +20,8 @@ func ProcConn(s storage.StorageReader, c net.Conn) error { switch tp { case MessageTypeCat: - name := GetCatName(body) + // omit first byte + name := GetCatName(body[1:]) ylogger.Zero.Debug().Str("object-path", name).Msg("cat object ") r, err := s.CatFileFromStorage(name) if err != nil { diff --git a/pkg/storage/sessionpool.go b/pkg/storage/sessionpool.go index d744db7..f9dd1af 100644 --- a/pkg/storage/sessionpool.go +++ b/pkg/storage/sessionpool.go @@ -8,6 +8,7 @@ import ( "github.com/aws/aws-sdk-go/service/s3" "github.com/pkg/errors" "github.com/yezzey-gp/yproxy/config" + "github.com/yezzey-gp/yproxy/pkg/ylogger" ) type SessionPool interface { @@ -35,6 +36,9 @@ func (sp *S3SessionPool) createSession() (*session.Session, error) { AccessKeyID: sp.cnf.AccessKeyId, SecretAccessKey: sp.cnf.SecretAccessKey, }} + + ylogger.Zero.Debug().Str("endpoint", sp.cnf.StorageEndpoint).Msg("acquire external storage session") + providers := make([]credentials.Provider, 0) providers = append(providers, provider) providers = append(providers, defaults.CredProviders(s.Config, defaults.Handlers())...) @@ -45,6 +49,8 @@ func (sp *S3SessionPool) createSession() (*session.Session, error) { s.Config.WithRegion(sp.cnf.StorageRegion) + s.Config.WithEndpoint(sp.cnf.StorageEndpoint) + s.Config.WithCredentials(newCredentials) return s, err } diff --git a/pkg/storage/storage.go b/pkg/storage/storage.go index 92b161e..fdc5a69 100644 --- a/pkg/storage/storage.go +++ b/pkg/storage/storage.go @@ -38,7 +38,9 @@ func (s *S3StorageReader) CatFileFromStorage(name string) (io.Reader, error) { Key: aws.String(objectPath), } - ylogger.Zero.Debug().Str("key", objectPath).Str("bucket", s.cnf.StorageBucket).Msg("requesting external storage") + ylogger.Zero.Debug().Str("key", objectPath).Str("bucket", + s.cnf.StorageBucket).Msg("requesting external storage") + object, err := sess.GetObject(input) return object.Body, err }