浏览代码

Added connection log for smb

Toby Chui 3 年之前
父节点
当前提交
f06967edb7
共有 2 个文件被更改,包括 8 次插入6 次删除
  1. 3 1
      mod/filesystem/abstractions/smbfs/smbfs.go
  2. 5 5
      mod/filesystem/filesystem.go

+ 3 - 1
mod/filesystem/abstractions/smbfs/smbfs.go

@@ -33,7 +33,9 @@ type ServerMessageBlockFileSystemAbstraction struct {
 }
 
 func NewServerMessageBlockFileSystemAbstraction(uuid string, hierarchy string, ipaddr string, rootShare string, username string, password string) (ServerMessageBlockFileSystemAbstraction, error) {
-	conn, err := net.Dial("tcp", ipaddr)
+	log.Println("[SMB-FS] Connecting to " + uuid + ":/ (" + ipaddr + ")")
+	nd := net.Dialer{Timeout: 10 * time.Second}
+	conn, err := nd.Dial("tcp", ipaddr)
 	if err != nil {
 		log.Println("[SMB-FS] Unable to connect to remote: ", err.Error())
 		return ServerMessageBlockFileSystemAbstraction{}, err

+ 5 - 5
mod/filesystem/filesystem.go

@@ -111,8 +111,8 @@ func NewFileSystemHandlersFromJSON(jsonContent []byte) ([]*FileSystemHandler, er
 	for _, option := range options {
 		thisHandler, err := NewFileSystemHandler(option)
 		if err != nil {
-			log.Println("Failed to create system handler for " + option.Name)
-			log.Println(err.Error())
+			log.Println("[File System] Failed to create system handler for " + option.Name)
+			//log.Println(err.Error())
 			continue
 		}
 		resultingHandlers = append(resultingHandlers, thisHandler)
@@ -149,7 +149,7 @@ func NewFileSystemHandler(option FileSystemOption) (*FileSystemHandler, error) {
 		dbp, err := db.NewDatabase(filepath.ToSlash(filepath.Join(filepath.Clean(option.Path), "aofs.db")), false)
 		if err != nil {
 			if option.Access != fsdef.FsReadOnly {
-				log.Println("[Filesystem] Invalid config: Trying to mount a read only path as read-write mount point. Changing " + option.Name + " mount point to READONLY.")
+				log.Println("[File System] Invalid config: Trying to mount a read only path as read-write mount point. Changing " + option.Name + " mount point to READONLY.")
 				option.Access = fsdef.FsReadOnly
 			}
 		} else {
@@ -226,7 +226,7 @@ func NewFileSystemHandler(option FileSystemOption) (*FileSystemHandler, error) {
 		}, nil
 	} else if option.Filesystem == "virtual" {
 		//Virtual filesystem, deprecated
-		log.Println("Deprecated file system type: Virtual")
+		log.Println("[File System] Deprecated file system type: Virtual")
 	}
 
 	return nil, errors.New("Not supported file system: " + fstype)
@@ -364,7 +364,7 @@ func (fsh *FileSystemHandler) Close() {
 	//Close the file system object
 	err := fsh.FileSystemAbstraction.Close()
 	if err != nil {
-		log.Println("Unable to close File System Abstraction for Handler: " + fsh.UUID + ". Skipping.")
+		log.Println("[File System]  Unable to close File System Abstraction for Handler: " + fsh.UUID + ". Skipping.")
 	}
 }