From b97d17f79f5d56019e50733bf124d408c5687531 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Fri, 2 Jan 2026 18:23:17 -0800 Subject: [PATCH] Standardize -ip.bind flags to default to empty and fall back to -ip (#7945) * Add documentation for issue #7941 fix * rm FIX_ISSUE_7941.md * Standardize -ip.bind flags to default to empty string and fall back to -ip option - Change s3 command -ip.bind default logic to use -ip instead of localhost - Change sftp command -ip.bind default to empty and fall back to 0.0.0.0 - Update help text for consistency * Fix compilation error: add -ip flag to s3 command and update bindIp fallback * Revert -ip flag addition for s3 command, set bindIp fallback to 0.0.0.0 * Update s3 command -ip.bind help text to reflect correct default behavior --- weed/command/s3.go | 4 ++-- weed/command/sftp.go | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/weed/command/s3.go b/weed/command/s3.go index afd7a8f9c..e84a4f45d 100644 --- a/weed/command/s3.go +++ b/weed/command/s3.go @@ -68,7 +68,7 @@ type S3Options struct { func init() { cmdS3.Run = runS3 // break init cycle s3StandaloneOptions.filer = cmdS3.Flag.String("filer", "localhost:8888", "comma-separated filer server addresses for high availability") - s3StandaloneOptions.bindIp = cmdS3.Flag.String("ip.bind", "", "ip address to bind to. Default to localhost.") + s3StandaloneOptions.bindIp = cmdS3.Flag.String("ip.bind", "", "ip address to bind to. If empty, default to 0.0.0.0.") s3StandaloneOptions.port = cmdS3.Flag.Int("port", 8333, "s3 server http listen port") s3StandaloneOptions.portHttps = cmdS3.Flag.Int("port.https", 0, "s3 server https listen port") s3StandaloneOptions.portGrpc = cmdS3.Flag.Int("port.grpc", 0, "s3 server grpc listen port") @@ -302,7 +302,7 @@ func (s3opt *S3Options) startS3Server() bool { *s3opt.portGrpc = 10000 + *s3opt.port } if *s3opt.bindIp == "" { - *s3opt.bindIp = "localhost" + *s3opt.bindIp = "0.0.0.0" } if runtime.GOOS != "windows" { diff --git a/weed/command/sftp.go b/weed/command/sftp.go index f1a0d9e09..58cc5b14a 100644 --- a/weed/command/sftp.go +++ b/weed/command/sftp.go @@ -60,7 +60,7 @@ func init() { cmdSftp.Run = runSftp sftpOptionsStandalone.filer = cmdSftp.Flag.String("filer", "localhost:8888", "filer server address (ip:port)") - sftpOptionsStandalone.bindIp = cmdSftp.Flag.String("ip.bind", "0.0.0.0", "ip address to bind SFTP server") + sftpOptionsStandalone.bindIp = cmdSftp.Flag.String("ip.bind", "", "ip address to bind to. If empty, default to 0.0.0.0.") sftpOptionsStandalone.port = cmdSftp.Flag.Int("port", 2022, "SFTP server listen port") sftpOptionsStandalone.sshPrivateKey = cmdSftp.Flag.String("sshPrivateKey", "", "path to the SSH private key file for host authentication") sftpOptionsStandalone.hostKeysFolder = cmdSftp.Flag.String("hostKeysFolder", "", "path to folder containing SSH private key files for host authentication") @@ -95,6 +95,9 @@ func runSftp(cmd *Command, args []string) bool { } func (sftpOpt *SftpOptions) startSftpServer() bool { + if *sftpOpt.bindIp == "" { + *sftpOpt.bindIp = "0.0.0.0" + } filerAddress := pb.ServerAddress(*sftpOpt.filer) grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.client")