|
@@ -24,15 +24,16 @@ import (
|
|
|
*/
|
|
|
|
|
|
type ServerMessageBlockFileSystemAbstraction struct {
|
|
|
- UUID string
|
|
|
- Hierarchy string
|
|
|
- root string
|
|
|
- ipaddr string
|
|
|
- user string
|
|
|
- pass string
|
|
|
- conn *net.Conn
|
|
|
- session *smb2.Session
|
|
|
- share *smb2.Share
|
|
|
+ UUID string
|
|
|
+ Hierarchy string
|
|
|
+ root string
|
|
|
+ ipaddr string
|
|
|
+ user string
|
|
|
+ pass string
|
|
|
+ conn *net.Conn
|
|
|
+ session *smb2.Session
|
|
|
+ share *smb2.Share
|
|
|
+ tickerChan chan bool
|
|
|
}
|
|
|
|
|
|
func NewServerMessageBlockFileSystemAbstraction(uuid string, hierarchy string, ipaddr string, rootShare string, username string, password string) (ServerMessageBlockFileSystemAbstraction, error) {
|
|
@@ -64,21 +65,22 @@ func NewServerMessageBlockFileSystemAbstraction(uuid string, hierarchy string, i
|
|
|
return ServerMessageBlockFileSystemAbstraction{}, err
|
|
|
}
|
|
|
|
|
|
+ done := make(chan bool)
|
|
|
fsAbstraction := ServerMessageBlockFileSystemAbstraction{
|
|
|
- UUID: uuid,
|
|
|
- Hierarchy: hierarchy,
|
|
|
- root: rootShare,
|
|
|
- ipaddr: ipaddr,
|
|
|
- user: username,
|
|
|
- pass: password,
|
|
|
- conn: &conn,
|
|
|
- session: s,
|
|
|
- share: fs,
|
|
|
+ UUID: uuid,
|
|
|
+ Hierarchy: hierarchy,
|
|
|
+ root: rootShare,
|
|
|
+ ipaddr: ipaddr,
|
|
|
+ user: username,
|
|
|
+ pass: password,
|
|
|
+ conn: &conn,
|
|
|
+ session: s,
|
|
|
+ share: fs,
|
|
|
+ tickerChan: done,
|
|
|
}
|
|
|
|
|
|
//Create a ticker to check for renewing conncetion once an hour
|
|
|
ticker := time.NewTicker(1 * time.Hour)
|
|
|
- done := make(chan bool)
|
|
|
go func(s *ServerMessageBlockFileSystemAbstraction) {
|
|
|
for {
|
|
|
select {
|
|
@@ -176,6 +178,7 @@ func (a ServerMessageBlockFileSystemAbstraction) Stat(filename string) (os.FileI
|
|
|
return a.share.Stat(filename)
|
|
|
}
|
|
|
func (a ServerMessageBlockFileSystemAbstraction) Close() error {
|
|
|
+ a.tickerChan <- true
|
|
|
a.share.Umount()
|
|
|
a.session.Logoff()
|
|
|
conn := *(a.conn)
|