-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
50 lines (45 loc) · 1.15 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main
import (
"crypto/md5"
"flag"
"fmt"
"io/ioutil"
"log"
"github.com/keybase/kbfs/dokan"
)
//could be flags
var volumeinfo = dokan.VolumeInformation{
VolumeName: "cryptfs",
VolumeSerialNumber: 0x1337,
FileSystemName: "cryptfs",
MaximumComponentLength: 0xff,
FileSystemFlags: dokan.FileSupportsEncryption,
}
func main() {
var dir, drive, key string
var err error
flag.StringVar(&dir, "dir", "", "Directory to mount")
flag.StringVar(&drive, "drive", "Q:", "Directory to mount")
flag.StringVar(&key, "key", "123456789qwertyu", "Directory to mount")
flag.Parse()
if dir == "" {
dir, err = ioutil.TempDir("", "")
if err != nil {
log.Fatal("unable to create dir for mount storage: ", err)
}
}
fmt.Println("Mount Dir: ", dir)
var myFileSystem dokan.FileSystem = &cryptfs{root: dir, key: keyTo16Byte(key)}
mp, err := dokan.Mount(&dokan.Config{FileSystem: myFileSystem, Path: drive})
if err != nil {
log.Fatal("Mount failed: ", err)
}
err = mp.BlockTillDone()
if err != nil {
log.Println("Filesystem exit: ", err)
}
}
func keyTo16Byte(key string) []byte {
v := md5.Sum([]byte(key))
return v[:]
}