mirror of
https://github.com/rclone/rclone
synced 2024-12-25 17:03:45 +01:00
serve ftp: check --passive-port arguments are correct
See: https://forum.rclone.org/t/serve-ftp-passive-port-validity-check/27458
This commit is contained in:
parent
a6ca4b3817
commit
7d3648dc46
@ -13,6 +13,7 @@ import (
|
||||
"net"
|
||||
"os"
|
||||
"os/user"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"sync"
|
||||
"time"
|
||||
@ -128,6 +129,8 @@ type server struct {
|
||||
useTLS bool
|
||||
}
|
||||
|
||||
var passivePortsRe = regexp.MustCompile(`^\s*\d+\s*-\s*\d+\s*$`)
|
||||
|
||||
// Make a new FTP to serve the remote
|
||||
func newServer(ctx context.Context, f fs.Fs, opt *Options) (*server, error) {
|
||||
host, port, err := net.SplitHostPort(opt.ListenAddr)
|
||||
@ -151,6 +154,11 @@ func newServer(ctx context.Context, f fs.Fs, opt *Options) (*server, error) {
|
||||
}
|
||||
s.useTLS = s.opt.TLSKey != ""
|
||||
|
||||
// Check PassivePorts format since the the server library doesn't!
|
||||
if !passivePortsRe.MatchString(opt.PassivePorts) {
|
||||
return nil, fmt.Errorf("invalid format for passive ports %q", opt.PassivePorts)
|
||||
}
|
||||
|
||||
ftpopt := &ftp.ServerOpts{
|
||||
Name: "Rclone FTP Server",
|
||||
WelcomeMessage: "Welcome to Rclone " + fs.Version + " FTP Server",
|
||||
|
Loading…
Reference in New Issue
Block a user