mirror of
https://github.com/drakkan/sftpgo.git
synced 2024-11-25 09:00:27 +00:00
fix unused parameter lint warnings
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
parent
d5946da1e2
commit
7f5a13d185
34 changed files with 59 additions and 58 deletions
|
@ -40,7 +40,7 @@ Certificates are saved in the configured "certs_path".
|
|||
After this initial step, the certificates are automatically checked and
|
||||
renewed by the SFTPGo service
|
||||
`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
Run: func(_ *cobra.Command, _ []string) {
|
||||
logger.DisableLogger()
|
||||
logger.EnableConsoleLogger(zerolog.DebugLevel)
|
||||
configDir = util.CleanDirInput(configDir)
|
||||
|
|
|
@ -21,4 +21,4 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func addAWSContainerFlags(cmd *cobra.Command) {}
|
||||
func addAWSContainerFlags(_ *cobra.Command) {}
|
||||
|
|
|
@ -38,7 +38,7 @@ command-line interface.
|
|||
By default, it creates the man page files in the "man" directory under the
|
||||
current directory.
|
||||
`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
Run: func(cmd *cobra.Command, _ []string) {
|
||||
logger.DisableLogger()
|
||||
logger.EnableConsoleLogger(zerolog.DebugLevel)
|
||||
if _, err := os.Stat(manDir); errors.Is(err, fs.ErrNotExist) {
|
||||
|
|
|
@ -49,7 +49,7 @@ To initialize/update the data provider from the configuration directory simply u
|
|||
$ sftpgo initprovider
|
||||
|
||||
Please take a look at the usage below to customize the options.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
Run: func(_ *cobra.Command, _ []string) {
|
||||
logger.DisableLogger()
|
||||
logger.EnableConsoleLogger(zerolog.DebugLevel)
|
||||
configDir = util.CleanDirInput(configDir)
|
||||
|
|
|
@ -35,7 +35,7 @@ line flags simply use:
|
|||
sftpgo service install
|
||||
|
||||
Please take a look at the usage below to customize the startup options`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
Run: func(_ *cobra.Command, _ []string) {
|
||||
s := service.Service{
|
||||
ConfigDir: util.CleanDirInput(configDir),
|
||||
ConfigFile: configFile,
|
||||
|
|
|
@ -106,7 +106,7 @@ use:
|
|||
$ sftpgo portable
|
||||
|
||||
Please take a look at the usage below to customize the serving parameters`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
Run: func(_ *cobra.Command, _ []string) {
|
||||
portableDir := directoryToServe
|
||||
fsProvider := sdk.GetProviderByName(portableFsProvider)
|
||||
if !filepath.IsAbs(portableDir) {
|
||||
|
|
|
@ -27,7 +27,7 @@ var (
|
|||
reloadCmd = &cobra.Command{
|
||||
Use: "reload",
|
||||
Short: "Reload the SFTPGo Windows Service sending a \"paramchange\" request",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
Run: func(_ *cobra.Command, _ []string) {
|
||||
s := service.WindowsService{
|
||||
Service: service.Service{
|
||||
Shutdown: make(chan bool),
|
||||
|
|
|
@ -39,7 +39,7 @@ configuration file and resets the provider by deleting all data and schemas.
|
|||
This command is not supported for the memory provider.
|
||||
|
||||
Please take a look at the usage below to customize the options.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
Run: func(_ *cobra.Command, _ []string) {
|
||||
logger.DisableLogger()
|
||||
logger.EnableConsoleLogger(zerolog.DebugLevel)
|
||||
configDir = util.CleanDirInput(configDir)
|
||||
|
|
|
@ -37,7 +37,7 @@ configuration file and restore the provider schema and/or data to a previous ver
|
|||
This command is not supported for the memory provider.
|
||||
|
||||
Please take a look at the usage below to customize the options.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
Run: func(_ *cobra.Command, _ []string) {
|
||||
logger.DisableLogger()
|
||||
logger.EnableConsoleLogger(zerolog.DebugLevel)
|
||||
if revertProviderTargetVersion != 19 {
|
||||
|
|
|
@ -27,7 +27,7 @@ var (
|
|||
rotateLogCmd = &cobra.Command{
|
||||
Use: "rotatelogs",
|
||||
Short: "Signal to the running service to rotate the logs",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
Run: func(_ *cobra.Command, _ []string) {
|
||||
s := service.WindowsService{
|
||||
Service: service.Service{
|
||||
Shutdown: make(chan bool),
|
||||
|
|
|
@ -33,7 +33,7 @@ use:
|
|||
$ sftpgo serve
|
||||
|
||||
Please take a look at the usage below to customize the startup options`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
Run: func(_ *cobra.Command, _ []string) {
|
||||
service := service.Service{
|
||||
ConfigDir: util.CleanDirInput(configDir),
|
||||
ConfigFile: configFile,
|
||||
|
|
|
@ -33,7 +33,7 @@ var (
|
|||
Short: "Test the SMTP configuration",
|
||||
Long: `SFTPGo will try to send a test email to the specified recipient.
|
||||
If the SMTP configuration is correct you should receive this email.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
Run: func(_ *cobra.Command, _ []string) {
|
||||
logger.DisableLogger()
|
||||
logger.EnableConsoleLogger(zerolog.DebugLevel)
|
||||
configDir = util.CleanDirInput(configDir)
|
||||
|
|
|
@ -29,7 +29,7 @@ var (
|
|||
startCmd = &cobra.Command{
|
||||
Use: "start",
|
||||
Short: "Start the SFTPGo Windows Service",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
Run: func(_ *cobra.Command, _ []string) {
|
||||
configDir = util.CleanDirInput(configDir)
|
||||
if !filepath.IsAbs(logFilePath) && util.IsFileInputValid(logFilePath) {
|
||||
logFilePath = filepath.Join(configDir, logFilePath)
|
||||
|
|
|
@ -51,7 +51,7 @@ Subsystem sftp sftpgo startsubsys
|
|||
|
||||
Command-line flags should be specified in the Subsystem declaration.
|
||||
`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
Run: func(_ *cobra.Command, _ []string) {
|
||||
logSender := "startsubsys"
|
||||
connectionID := xid.New().String()
|
||||
var zeroLogLevel zerolog.Level
|
||||
|
|
|
@ -27,7 +27,7 @@ var (
|
|||
statusCmd = &cobra.Command{
|
||||
Use: "status",
|
||||
Short: "Retrieve the status for the SFTPGo Windows Service",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
Run: func(_ *cobra.Command, _ []string) {
|
||||
s := service.WindowsService{
|
||||
Service: service.Service{
|
||||
Shutdown: make(chan bool),
|
||||
|
|
|
@ -27,7 +27,7 @@ var (
|
|||
stopCmd = &cobra.Command{
|
||||
Use: "stop",
|
||||
Short: "Stop the SFTPGo Windows Service",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
Run: func(_ *cobra.Command, _ []string) {
|
||||
s := service.WindowsService{
|
||||
Service: service.Service{
|
||||
Shutdown: make(chan bool),
|
||||
|
|
|
@ -27,7 +27,7 @@ var (
|
|||
uninstallCmd = &cobra.Command{
|
||||
Use: "uninstall",
|
||||
Short: "Uninstall the SFTPGo Windows Service",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
Run: func(_ *cobra.Command, _ []string) {
|
||||
s := service.WindowsService{
|
||||
Service: service.Service{
|
||||
Shutdown: make(chan bool),
|
||||
|
|
|
@ -97,7 +97,7 @@ func (m *CertManager) loadCertificates() error {
|
|||
|
||||
// GetCertificateFunc returns the loaded certificate
|
||||
func (m *CertManager) GetCertificateFunc(certID string) func(*tls.ClientHelloInfo) (*tls.Certificate, error) {
|
||||
return func(clientHello *tls.ClientHelloInfo) (*tls.Certificate, error) {
|
||||
return func(_ *tls.ClientHelloInfo) (*tls.Certificate, error) {
|
||||
m.RLock()
|
||||
defer m.RUnlock()
|
||||
|
||||
|
|
|
@ -27,6 +27,6 @@ func init() {
|
|||
version.AddFeature("-bolt")
|
||||
}
|
||||
|
||||
func initializeBoltProvider(basePath string) error {
|
||||
func initializeBoltProvider(_ string) error {
|
||||
return errors.New("bolt disabled at build time")
|
||||
}
|
||||
|
|
|
@ -27,6 +27,6 @@ func init() {
|
|||
version.AddFeature("-sqlite")
|
||||
}
|
||||
|
||||
func initializeSQLiteProvider(basePath string) error {
|
||||
func initializeSQLiteProvider(_ string) error {
|
||||
return errors.New("SQLite disabled at build time")
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -377,7 +377,7 @@ func (fs *httpFsImpl) dirsize(w http.ResponseWriter, r *http.Request) {
|
|||
numFiles := 0
|
||||
size := int64(0)
|
||||
if info.IsDir() {
|
||||
err = filepath.Walk(fsPath, func(path string, info os.FileInfo, err error) error {
|
||||
err = filepath.Walk(fsPath, func(_ string, info os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -227,6 +227,7 @@ func CommandLog(command, path, target, user, fileMode, connectionID, protocol st
|
|||
logger.Info().
|
||||
Timestamp().
|
||||
Str("sender", command).
|
||||
Str("local_addr", localAddr).
|
||||
Str("remote_addr", remoteAddr).
|
||||
Str("username", user).
|
||||
Str("file_path", path).
|
||||
|
@ -235,7 +236,7 @@ func CommandLog(command, path, target, user, fileMode, connectionID, protocol st
|
|||
Int("uid", uid).
|
||||
Int("gid", gid).
|
||||
Str("access_time", atime).
|
||||
Str("modification_time", atime).
|
||||
Str("modification_time", mtime).
|
||||
Int64("size", size).
|
||||
Str("ssh_command", sshCommand).
|
||||
Str("connection_id", connectionID).
|
||||
|
|
|
@ -14,62 +14,62 @@ func init() {
|
|||
}
|
||||
|
||||
// AddMetricsEndpoint exposes metrics to the specified endpoint
|
||||
func AddMetricsEndpoint(metricsPath string, handler chi.Router) {}
|
||||
func AddMetricsEndpoint(_ string, _ chi.Router) {}
|
||||
|
||||
// TransferCompleted updates metrics after an upload or a download
|
||||
func TransferCompleted(bytesSent, bytesReceived int64, transferKind int, err error, isSFTPFs bool) {}
|
||||
func TransferCompleted(_, _ int64, _ int, _ error, _ bool) {}
|
||||
|
||||
// S3TransferCompleted updates metrics after an S3 upload or a download
|
||||
func S3TransferCompleted(bytes int64, transferKind int, err error) {}
|
||||
func S3TransferCompleted(_ int64, _ int, _ error) {}
|
||||
|
||||
// S3ListObjectsCompleted updates metrics after an S3 list objects request terminates
|
||||
func S3ListObjectsCompleted(err error) {}
|
||||
func S3ListObjectsCompleted(_ error) {}
|
||||
|
||||
// S3CopyObjectCompleted updates metrics after an S3 copy object request terminates
|
||||
func S3CopyObjectCompleted(err error) {}
|
||||
func S3CopyObjectCompleted(_ error) {}
|
||||
|
||||
// S3DeleteObjectCompleted updates metrics after an S3 delete object request terminates
|
||||
func S3DeleteObjectCompleted(err error) {}
|
||||
func S3DeleteObjectCompleted(_ error) {}
|
||||
|
||||
// S3HeadBucketCompleted updates metrics after an S3 head bucket request terminates
|
||||
func S3HeadBucketCompleted(err error) {}
|
||||
func S3HeadBucketCompleted(_ error) {}
|
||||
|
||||
// GCSTransferCompleted updates metrics after a GCS upload or a download
|
||||
func GCSTransferCompleted(bytes int64, transferKind int, err error) {}
|
||||
func GCSTransferCompleted(_ int64, _ int, _ error) {}
|
||||
|
||||
// GCSListObjectsCompleted updates metrics after a GCS list objects request terminates
|
||||
func GCSListObjectsCompleted(err error) {}
|
||||
func GCSListObjectsCompleted(_ error) {}
|
||||
|
||||
// GCSCopyObjectCompleted updates metrics after a GCS copy object request terminates
|
||||
func GCSCopyObjectCompleted(err error) {}
|
||||
func GCSCopyObjectCompleted(_ error) {}
|
||||
|
||||
// GCSDeleteObjectCompleted updates metrics after a GCS delete object request terminates
|
||||
func GCSDeleteObjectCompleted(err error) {}
|
||||
func GCSDeleteObjectCompleted(_ error) {}
|
||||
|
||||
// GCSHeadBucketCompleted updates metrics after a GCS head bucket request terminates
|
||||
func GCSHeadBucketCompleted(err error) {}
|
||||
func GCSHeadBucketCompleted(_ error) {}
|
||||
|
||||
// HTTPFsTransferCompleted updates metrics after an HTTPFs upload or a download
|
||||
func HTTPFsTransferCompleted(bytes int64, transferKind int, err error) {}
|
||||
func HTTPFsTransferCompleted(_ int64, _ int, _ error) {}
|
||||
|
||||
// SSHCommandCompleted update metrics after an SSH command terminates
|
||||
func SSHCommandCompleted(err error) {}
|
||||
func SSHCommandCompleted(_ error) {}
|
||||
|
||||
// UpdateDataProviderAvailability updates the metric for the data provider availability
|
||||
func UpdateDataProviderAvailability(err error) {}
|
||||
func UpdateDataProviderAvailability(_ error) {}
|
||||
|
||||
// AddLoginAttempt increments the metrics for login attempts
|
||||
func AddLoginAttempt(authMethod string) {}
|
||||
func AddLoginAttempt(_ string) {}
|
||||
|
||||
// AddLoginResult increments the metrics for login results
|
||||
func AddLoginResult(authMethod string, err error) {}
|
||||
func AddLoginResult(_ string, _ error) {}
|
||||
|
||||
// AddNoAuthTryed increments the metric for clients disconnected
|
||||
// for inactivity before trying to login
|
||||
func AddNoAuthTryed() {}
|
||||
|
||||
// HTTPRequestServed increments the metrics for HTTP requests
|
||||
func HTTPRequestServed(status int) {}
|
||||
func HTTPRequestServed(_ int) {}
|
||||
|
||||
// UpdateActiveConnectionsSize sets the metric for active connections
|
||||
func UpdateActiveConnectionsSize(size int) {}
|
||||
func UpdateActiveConnectionsSize(_ int) {}
|
||||
|
|
|
@ -17,6 +17,6 @@
|
|||
|
||||
package service
|
||||
|
||||
func registerAWSContainer(disableAWSInstallationCode bool) error {
|
||||
func registerAWSContainer(_ bool) error {
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -18,6 +18,6 @@ import (
|
|||
"os/exec"
|
||||
)
|
||||
|
||||
func wrapCmd(cmd *exec.Cmd, uid, gid int) *exec.Cmd {
|
||||
func wrapCmd(cmd *exec.Cmd, _, _ int) *exec.Cmd {
|
||||
return cmd
|
||||
}
|
||||
|
|
|
@ -247,7 +247,7 @@ func TestHTTPFsWalk(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
|
||||
var walkedPaths []string
|
||||
err = httpFs.Walk("/", func(walkedPath string, info fs.FileInfo, err error) error {
|
||||
err = httpFs.Walk("/", func(walkedPath string, _ fs.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -269,7 +269,7 @@ func TestHTTPFsWalk(t *testing.T) {
|
|||
}
|
||||
}
|
||||
walkedPaths = nil
|
||||
err = httpFs.Walk("/", func(walkedPath string, info fs.FileInfo, err error) error {
|
||||
err = httpFs.Walk("/", func(walkedPath string, _ fs.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -2719,7 +2719,7 @@ func TestInteractiveLoginWithPasscode(t *testing.T) {
|
|||
passwordAsked := false
|
||||
passcodeAsked := false
|
||||
authMethods := []ssh.AuthMethod{
|
||||
ssh.KeyboardInteractive(func(user, instruction string, questions []string, echos []bool) ([]string, error) {
|
||||
ssh.KeyboardInteractive(func(_, _ string, questions []string, _ []bool) ([]string, error) {
|
||||
var answers []string
|
||||
if strings.HasPrefix(questions[0], "Password") {
|
||||
answers = append(answers, defaultPassword)
|
||||
|
@ -2768,7 +2768,7 @@ func TestInteractiveLoginWithPasscode(t *testing.T) {
|
|||
_, _, err = getCustomAuthSftpClient(user, authMethods, "")
|
||||
assert.Error(t, err)
|
||||
authMethods = []ssh.AuthMethod{
|
||||
ssh.KeyboardInteractive(func(user, instruction string, questions []string, echos []bool) ([]string, error) {
|
||||
ssh.KeyboardInteractive(func(_, _ string, questions []string, _ []bool) ([]string, error) {
|
||||
var answers []string
|
||||
if strings.HasPrefix(questions[0], "Password") {
|
||||
answers = append(answers, defaultPassword)
|
||||
|
|
|
@ -28,6 +28,6 @@ func init() {
|
|||
}
|
||||
|
||||
// NewAzBlobFs returns an error, Azure Blob storage is disabled
|
||||
func NewAzBlobFs(connectionID, localTempDir, mountPath string, config AzBlobFsConfig) (Fs, error) {
|
||||
func NewAzBlobFs(_, _, _ string, _ AzBlobFsConfig) (Fs, error) {
|
||||
return nil, errors.New("Azure Blob Storage disabled at build time")
|
||||
}
|
||||
|
|
|
@ -28,6 +28,6 @@ func init() {
|
|||
}
|
||||
|
||||
// NewGCSFs returns an error, GCS is disabled
|
||||
func NewGCSFs(connectionID, localTempDir, mountPath string, config GCSFsConfig) (Fs, error) {
|
||||
func NewGCSFs(_, _, _ string, _ GCSFsConfig) (Fs, error) {
|
||||
return nil, errors.New("Google Cloud Storage disabled at build time")
|
||||
}
|
||||
|
|
|
@ -216,7 +216,7 @@ func NewHTTPFs(connectionID, localTempDir, mountPath string, config HTTPFsConfig
|
|||
return nil, fmt.Errorf("httpfs: invalid unix domain socket path: %q", socketPath)
|
||||
}
|
||||
if endpointURL.Scheme == "https" {
|
||||
transport.DialTLSContext = func(ctx context.Context, network, addr string) (net.Conn, error) {
|
||||
transport.DialTLSContext = func(ctx context.Context, _, _ string) (net.Conn, error) {
|
||||
var tlsConfig *tls.Config
|
||||
var d tls.Dialer
|
||||
if config.SkipTLSVerify {
|
||||
|
@ -226,7 +226,7 @@ func NewHTTPFs(connectionID, localTempDir, mountPath string, config HTTPFsConfig
|
|||
return d.DialContext(ctx, "unix", socketPath)
|
||||
}
|
||||
} else {
|
||||
transport.DialContext = func(ctx context.Context, network, addr string) (net.Conn, error) {
|
||||
transport.DialContext = func(ctx context.Context, _, _ string) (net.Conn, error) {
|
||||
var d net.Dialer
|
||||
return d.DialContext(ctx, "unix", socketPath)
|
||||
}
|
||||
|
|
|
@ -372,7 +372,7 @@ func (fs *OsFs) GetDirSize(dirname string) (int, int64, error) {
|
|||
size := int64(0)
|
||||
isDir, err := IsDirectory(fs, dirname)
|
||||
if err == nil && isDir {
|
||||
err = filepath.Walk(dirname, func(path string, info os.FileInfo, err error) error {
|
||||
err = filepath.Walk(dirname, func(_ string, info os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -28,6 +28,6 @@ func init() {
|
|||
}
|
||||
|
||||
// NewS3Fs returns an error, S3 is disabled
|
||||
func NewS3Fs(connectionID, localTempDir, mountPath string, config S3FsConfig) (Fs, error) {
|
||||
func NewS3Fs(_, _, _ string, _ S3FsConfig) (Fs, error) {
|
||||
return nil, errors.New("S3 disabled at build time")
|
||||
}
|
||||
|
|
|
@ -827,7 +827,7 @@ func (fs *SFTPFs) createConnection() error {
|
|||
var err error
|
||||
clientConfig := &ssh.ClientConfig{
|
||||
User: fs.config.Username,
|
||||
HostKeyCallback: func(hostname string, remote net.Addr, key ssh.PublicKey) error {
|
||||
HostKeyCallback: func(_ string, _ net.Addr, key ssh.PublicKey) error {
|
||||
fp := ssh.FingerprintSHA256(key)
|
||||
if util.Contains(sftpFingerprints, fp) {
|
||||
if util.Contains(fs.config.forbiddenSelfUsernames, fs.config.Username) {
|
||||
|
|
Loading…
Reference in a new issue