mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-07 14:50:55 +03:00
refactoring: add common package
The common package defines the interfaces that a protocol must implement and contain code that can be shared among supported protocols. This way should be easier to support new protocols
This commit is contained in:
@@ -8,10 +8,10 @@ import (
|
||||
)
|
||||
|
||||
type certManager struct {
|
||||
cert *tls.Certificate
|
||||
certPath string
|
||||
keyPath string
|
||||
lock *sync.RWMutex
|
||||
sync.RWMutex
|
||||
cert *tls.Certificate
|
||||
}
|
||||
|
||||
func (m *certManager) loadCertificate() error {
|
||||
@@ -21,16 +21,16 @@ func (m *certManager) loadCertificate() error {
|
||||
return err
|
||||
}
|
||||
logger.Debug(logSender, "", "https certificate successfully loaded")
|
||||
m.lock.Lock()
|
||||
defer m.lock.Unlock()
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
m.cert = &newCert
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *certManager) GetCertificateFunc() func(*tls.ClientHelloInfo) (*tls.Certificate, error) {
|
||||
return func(clientHello *tls.ClientHelloInfo) (*tls.Certificate, error) {
|
||||
m.lock.RLock()
|
||||
defer m.lock.RUnlock()
|
||||
m.RLock()
|
||||
defer m.RUnlock()
|
||||
return m.cert, nil
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,6 @@ func newCertManager(certificateFile, certificateKeyFile string) (*certManager, e
|
||||
cert: nil,
|
||||
certPath: certificateFile,
|
||||
keyPath: certificateKeyFile,
|
||||
lock: new(sync.RWMutex),
|
||||
}
|
||||
err := manager.loadCertificate()
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user