continued work on encryption

This commit is contained in:
ston1th 2022-04-07 00:54:13 +02:00
commit 880e2f06b3
14 changed files with 362 additions and 39 deletions

View file

@ -51,7 +51,7 @@ type FS struct {
keepalive bool
}
func NewFS(u *url.URL, log logr.Logger) (fs *FS, err error) {
func NewFS(u *url.URL, block bool, log logr.Logger) (fs *FS, err error) {
cfg, err := sshConfig(u)
if err != nil {
return
@ -66,6 +66,14 @@ func NewFS(u *url.URL, log logr.Logger) (fs *FS, err error) {
ctx, cancel := context.WithCancel(context.Background())
fs.cancel = cancel
go fs.connect(ctx)
if block {
for {
if _, e := fs.Stat("."); e != ErrNotConnected {
return
}
time.Sleep(time.Millisecond * 100)
}
}
return
}
@ -95,7 +103,12 @@ func (fs *FS) connect(ctx context.Context) {
go fs.keepAlive(ctx)
fs.keepalive = true
}
fs.client, err = sftp.NewClient(fs.c, sftp.UseFstat(true))
fs.client, err = sftp.NewClient(fs.c,
sftp.UseFstat(true),
sftp.UseConcurrentReads(true),
//sftp.UseConcurrentWrites(true),
//sftp.MaxPacket(23552),
)
select {
case <-ctx.Done():
return