diff options
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 23 |
1 files changed, 12 insertions, 11 deletions
@@ -3,15 +3,15 @@ package main import ( "context" "fmt" - "io" - "io/ioutil" - "net" - "git.deuxfleurs.fr/Deuxfleurs/bagage/sftp" "git.deuxfleurs.fr/Deuxfleurs/bagage/s3" - "github.com/minio/minio-go/v7/pkg/credentials" + "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/ioutil" "log" + "net" "net/http" ) @@ -26,7 +26,7 @@ func main() { go httpServer(config, done) go sshServer(config, done) - err := <- done + err := <-done if err != nil { log.Fatalf("A component failed: %v", err) } @@ -36,9 +36,10 @@ type s3creds struct { accessKey string secretKey string } + var keychain map[string]s3creds -func sshServer(dconfig* Config, done chan error) { +func sshServer(dconfig *Config, done chan error) { keychain = make(map[string]s3creds) config := &ssh.ServerConfig{ @@ -46,7 +47,7 @@ func sshServer(dconfig* Config, done chan error) { log.Printf("Login: %s\n", c.User()) access_key, secret_key, err := LdapGetS3(dconfig, c.User(), string(pass)) if err == nil { - keychain[c.User()] = s3creds{ access_key, secret_key } + keychain[c.User()] = s3creds{access_key, secret_key} } return nil, err }, @@ -82,7 +83,7 @@ func sshServer(dconfig* Config, done chan error) { } } -func handleSSHConn(nConn net.Conn, dconfig* Config, config *ssh.ServerConfig) { +func handleSSHConn(nConn net.Conn, dconfig *Config, config *ssh.ServerConfig) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -138,7 +139,7 @@ func handleSSHConn(nConn net.Conn, dconfig* Config, config *ssh.ServerConfig) { } }(requests) - creds := keychain[user] + creds := keychain[user] mc, err := minio.New(dconfig.Endpoint, &minio.Options{ Creds: credentials.NewStaticV4(creds.accessKey, creds.secretKey, ""), Secure: dconfig.UseSSL, @@ -163,7 +164,7 @@ func handleSSHConn(nConn net.Conn, dconfig* Config, config *ssh.ServerConfig) { } } -func httpServer(config* Config, done chan error) { +func httpServer(config *Config, done chan error) { // Assemble components to handle WebDAV requests http.Handle(config.DavPath+"/", BasicAuthExtract{ |