update
This commit is contained in:
parent
7b1863109c
commit
ef751771d2
107 changed files with 9435 additions and 850 deletions
pkg/go-nfs/example/osview
37
pkg/go-nfs/example/osview/main.go
Normal file
37
pkg/go-nfs/example/osview/main.go
Normal file
|
@ -0,0 +1,37 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"os"
|
||||
|
||||
"github.com/willscott/memphis"
|
||||
|
||||
nfs "git.kmsign.ru/royalcat/tstor/pkg/go-nfs"
|
||||
"git.kmsign.ru/royalcat/tstor/pkg/go-nfs/helpers"
|
||||
nfshelper "git.kmsign.ru/royalcat/tstor/pkg/go-nfs/helpers"
|
||||
)
|
||||
|
||||
func main() {
|
||||
port := ""
|
||||
if len(os.Args) < 2 {
|
||||
fmt.Printf("Usage: osview </path/to/folder> [port]\n")
|
||||
return
|
||||
} else if len(os.Args) == 3 {
|
||||
port = os.Args[2]
|
||||
}
|
||||
|
||||
listener, err := net.Listen("tcp", ":"+port)
|
||||
if err != nil {
|
||||
fmt.Printf("Failed to listen: %v\n", err)
|
||||
return
|
||||
}
|
||||
fmt.Printf("Server running at %s\n", listener.Addr())
|
||||
|
||||
fs := memphis.FromOS(os.Args[1])
|
||||
bfs := helpers.WrapBillyFS(fs.AsBillyFS(0, 0))
|
||||
|
||||
handler := nfshelper.NewNullAuthHandler(bfs)
|
||||
cacheHelper := nfshelper.NewCachingHandler(handler, 1024)
|
||||
fmt.Printf("%v", nfs.Serve(listener, cacheHelper))
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue