More resolved TODOs
This commit is contained in:
parent
3a56fb9db8
commit
07e3705f09
4 changed files with 26 additions and 15 deletions
|
|
@ -103,13 +103,6 @@ func init() {
|
||||||
runCmd.Flags().StringVar(&shareBackendFlag, "share-backend", defaultShareType, "Specifies the file share backend to use. The default value is OS-specific.")
|
runCmd.Flags().StringVar(&shareBackendFlag, "share-backend", defaultShareType, "Specifies the file share backend to use. The default value is OS-specific.")
|
||||||
runCmd.Flags().StringVar(&shareListenIPFlag, "share-listen", share.GetDefaultListenIPStr(), "Specifies the IP to bind the network share port to. NOTE: For FTP, changing the bind address is not enough to connect remotely. You should also specify --ftp-extip.")
|
runCmd.Flags().StringVar(&shareListenIPFlag, "share-listen", share.GetDefaultListenIPStr(), "Specifies the IP to bind the network share port to. NOTE: For FTP, changing the bind address is not enough to connect remotely. You should also specify --ftp-extip.")
|
||||||
|
|
||||||
smbExternDefault := false
|
|
||||||
if runtime.GOOS == "windows" {
|
|
||||||
smbExternDefault = true
|
|
||||||
}
|
|
||||||
|
|
||||||
runCmd.Flags().StringVar(&ftpExtIPFlag, "ftp-extip", share.GetDefaultListenIPStr(), "Specifies the external IP the FTP server should advertise.")
|
runCmd.Flags().StringVar(&ftpExtIPFlag, "ftp-extip", share.GetDefaultListenIPStr(), "Specifies the external IP the FTP server should advertise.")
|
||||||
runCmd.Flags().BoolVar(&smbUseExternAddrFlag, "smb-extern", smbExternDefault, "Specifies whether Linsk emulate external networking for the VM's SMB server. This is the default for Windows as there is no way to specify ports in Windows SMB client.")
|
runCmd.Flags().BoolVar(&smbUseExternAddrFlag, "smb-extern", share.IsSMBExtModeDefault(), "Specifies whether Linsk emulate external networking for the VM's SMB server. This is the default for Windows as there is no way to specify ports in Windows SMB client.")
|
||||||
|
|
||||||
// TODO: log the use of smbUseExternAddrFlag when SMB is not enabled.
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
10
share/cfg.go
10
share/cfg.go
|
|
@ -7,12 +7,6 @@ import (
|
||||||
"log/slog"
|
"log/slog"
|
||||||
)
|
)
|
||||||
|
|
||||||
var defaultListenIP = net.ParseIP("127.0.0.1")
|
|
||||||
|
|
||||||
func GetDefaultListenIPStr() string {
|
|
||||||
return defaultListenIP.String()
|
|
||||||
}
|
|
||||||
|
|
||||||
type UserConfiguration struct {
|
type UserConfiguration struct {
|
||||||
listenIP net.IP
|
listenIP net.IP
|
||||||
ftpExtIP net.IP
|
ftpExtIP net.IP
|
||||||
|
|
@ -49,6 +43,10 @@ func (rc RawUserConfiguration) Process(backend string, warnLogger *slog.Logger)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if rc.SMBExtMode && backend != "smb" && !IsSMBExtModeDefault() {
|
||||||
|
slog.Warn("SMB external mode specification is ineffective with non-SMB backends")
|
||||||
|
}
|
||||||
|
|
||||||
return &UserConfiguration{
|
return &UserConfiguration{
|
||||||
listenIP: listenIP,
|
listenIP: listenIP,
|
||||||
ftpExtIP: ftpExtIP,
|
ftpExtIP: ftpExtIP,
|
||||||
|
|
|
||||||
16
share/defaults.go
Normal file
16
share/defaults.go
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
package share
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net"
|
||||||
|
"runtime"
|
||||||
|
)
|
||||||
|
|
||||||
|
func IsSMBExtModeDefault() bool {
|
||||||
|
return runtime.GOOS == "windows1"
|
||||||
|
}
|
||||||
|
|
||||||
|
var defaultListenIP = net.ParseIP("127.0.0.1")
|
||||||
|
|
||||||
|
func GetDefaultListenIPStr() string {
|
||||||
|
return defaultListenIP.String()
|
||||||
|
}
|
||||||
|
|
@ -42,9 +42,13 @@ func (s *Storage) ReleaseNetTapAllocation(tapName string) error {
|
||||||
return errors.Wrap(err, "get alloc file path")
|
return errors.Wrap(err, "get alloc file path")
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Check what happens the file doesn't exist. It should not return an error.
|
|
||||||
err = os.Remove(allocFilePath)
|
err = os.Remove(allocFilePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if errors.Is(err, os.ErrNotExist) {
|
||||||
|
s.logger.Warn("Attempted to remove non-existent tap allocation", "tap-name", tapName)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
return errors.Wrap(err, "remove alloc file")
|
return errors.Wrap(err, "remove alloc file")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue