Path + format
This commit is contained in:
parent
514731cf4b
commit
4448577ec1
4 changed files with 33 additions and 22 deletions
|
@ -46,7 +46,9 @@ type LdapError struct {
|
||||||
Username string
|
Username string
|
||||||
Err error
|
Err error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *LdapError) Error() string { return "ldap error for " + e.Username + ": " + e.Err.Error() }
|
func (e *LdapError) Error() string { return "ldap error for " + e.Username + ": " + e.Err.Error() }
|
||||||
|
|
||||||
type LdapWrongPasswordError struct{ LdapError }
|
type LdapWrongPasswordError struct{ LdapError }
|
||||||
|
|
||||||
func LdapGetS3(c *Config, username, password string) (access_key, secret_key string, werr error) {
|
func LdapGetS3(c *Config, username, password string) (access_key, secret_key string, werr error) {
|
||||||
|
|
13
main.go
13
main.go
|
@ -3,15 +3,15 @@ package main
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"git.deuxfleurs.fr/Deuxfleurs/bagage/s3"
|
||||||
|
"git.deuxfleurs.fr/Deuxfleurs/bagage/sftp"
|
||||||
|
"github.com/minio/minio-go/v7"
|
||||||
|
"github.com/minio/minio-go/v7/pkg/credentials"
|
||||||
|
"golang.org/x/crypto/ssh"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net"
|
|
||||||
"git.deuxfleurs.fr/Deuxfleurs/bagage/sftp"
|
|
||||||
"git.deuxfleurs.fr/Deuxfleurs/bagage/s3"
|
|
||||||
"github.com/minio/minio-go/v7/pkg/credentials"
|
|
||||||
"github.com/minio/minio-go/v7"
|
|
||||||
"golang.org/x/crypto/ssh"
|
|
||||||
"log"
|
"log"
|
||||||
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@ type s3creds struct {
|
||||||
accessKey string
|
accessKey string
|
||||||
secretKey string
|
secretKey string
|
||||||
}
|
}
|
||||||
|
|
||||||
var keychain map[string]s3creds
|
var keychain map[string]s3creds
|
||||||
|
|
||||||
func sshServer(dconfig *Config, done chan error) {
|
func sshServer(dconfig *Config, done chan error) {
|
||||||
|
|
10
s3/file.go
10
s3/file.go
|
@ -19,6 +19,7 @@ type S3File struct {
|
||||||
objw *io.PipeWriter
|
objw *io.PipeWriter
|
||||||
donew chan error
|
donew chan error
|
||||||
pos int64
|
pos int64
|
||||||
|
eof bool
|
||||||
entries []fs.FileInfo
|
entries []fs.FileInfo
|
||||||
Path S3Path
|
Path S3Path
|
||||||
}
|
}
|
||||||
|
@ -85,12 +86,19 @@ func (f *S3File) Read(p []byte) (n int, err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *S3File) ReadAt(p []byte, off int64) (n int, err error) {
|
func (f *S3File) ReadAt(p []byte, off int64) (n int, err error) {
|
||||||
|
if f.eof {
|
||||||
|
return 0, io.EOF
|
||||||
|
}
|
||||||
|
|
||||||
log.Printf("s3 ReadAt %v\n", off)
|
log.Printf("s3 ReadAt %v\n", off)
|
||||||
if err := f.loadObject(); err != nil {
|
if err := f.loadObject(); err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return f.obj.ReadAt(p, off)
|
n, err = f.obj.ReadAt(p, off)
|
||||||
|
f.eof = err == io.EOF
|
||||||
|
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *S3File) WriteAt(p []byte, off int64) (n int, err error) {
|
func (f *S3File) WriteAt(p []byte, off int64) (n int, err error) {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/minio/minio-go/v7"
|
|
||||||
"git.deuxfleurs.fr/Deuxfleurs/bagage/s3"
|
"git.deuxfleurs.fr/Deuxfleurs/bagage/s3"
|
||||||
|
"github.com/minio/minio-go/v7"
|
||||||
"golang.org/x/net/webdav"
|
"golang.org/x/net/webdav"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
Loading…
Reference in a new issue