mirror of
https://github.com/1f349/shfs.git
synced 2024-11-12 22:31:32 +00:00
Create shfs project
This commit is contained in:
commit
702fed3374
7
README.md
Normal file
7
README.md
Normal file
@ -0,0 +1,7 @@
|
||||
# shfs
|
||||
|
||||
Sync Hash File System - allows syncing between devices and storing large files as references keyed by the file hash.
|
||||
|
||||
Mount on linux:
|
||||
|
||||
`mount -o port=<n>,mountport=<n>,nfsvers=3,noacl,tcp -t nfs localhost:/mount <mountpoint>`
|
15
go.mod
Normal file
15
go.mod
Normal file
@ -0,0 +1,15 @@
|
||||
module github.com/1f349/shfs
|
||||
|
||||
go 1.21.1
|
||||
|
||||
require (
|
||||
github.com/go-git/go-billy/v5 v5.5.0
|
||||
github.com/willscott/go-nfs v0.0.0-20230907145631-41b369691e46
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/google/uuid v1.3.1 // indirect
|
||||
github.com/hashicorp/golang-lru/v2 v2.0.5 // indirect
|
||||
github.com/rasky/go-xdr v0.0.0-20170124162913-1a41d1a06c93 // indirect
|
||||
github.com/willscott/go-nfs-client v0.0.0-20200605172546-271fa9065b33 // indirect
|
||||
)
|
21
go.sum
Normal file
21
go.sum
Normal file
@ -0,0 +1,21 @@
|
||||
github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+mTU=
|
||||
github.com/go-git/go-billy/v5 v5.5.0/go.mod h1:hmexnoNsr2SJU1Ju67OaNz5ASJY3+sHgFRpCtpDCKow=
|
||||
github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4=
|
||||
github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/hashicorp/golang-lru/v2 v2.0.5 h1:wW7h1TG88eUIJ2i69gaE3uNVtEPIagzhGvHgwfx2Vm4=
|
||||
github.com/hashicorp/golang-lru/v2 v2.0.5/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
|
||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/rasky/go-xdr v0.0.0-20170124162913-1a41d1a06c93 h1:UVArwN/wkKjMVhh2EQGC0tEc1+FqiLlvYXY5mQ2f8Wg=
|
||||
github.com/rasky/go-xdr v0.0.0-20170124162913-1a41d1a06c93/go.mod h1:Nfe4efndBz4TibWycNE+lqyJZiMX4ycx+QKV8Ta0f/o=
|
||||
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
|
||||
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
|
||||
github.com/willscott/go-nfs v0.0.0-20230907145631-41b369691e46 h1:9dp+1bZsWG82VUuGeMPIT5JWzWpenWF9eSe2/N/dbCA=
|
||||
github.com/willscott/go-nfs v0.0.0-20230907145631-41b369691e46/go.mod h1:1PiZswSlNu7GfHMWekF6rF1I94c8E0p+Cwbz7px1D14=
|
||||
github.com/willscott/go-nfs-client v0.0.0-20200605172546-271fa9065b33 h1:Wd8wdpRzPXskyHvZLyw7Wc1fp5oCE2mhBCj7bAiibUs=
|
||||
github.com/willscott/go-nfs-client v0.0.0-20200605172546-271fa9065b33/go.mod h1:cOUKSNty+RabZqKhm5yTJT5Vq/Fe83ZRWAJ5Kj8nRes=
|
||||
github.com/zema1/go-nfs-client v0.0.0-20200604081958-0cf942f0e0fe/go.mod h1:im3CVJ32XM3+E+2RhY0sa5IVJVQehUrX0oE1wX4xOwU=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
34
main.go
Normal file
34
main.go
Normal file
@ -0,0 +1,34 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net"
|
||||
|
||||
"github.com/go-git/go-billy/v5/memfs"
|
||||
nfs "github.com/willscott/go-nfs"
|
||||
nfshelper "github.com/willscott/go-nfs/helpers"
|
||||
)
|
||||
|
||||
func main() {
|
||||
listener, err := net.Listen("tcp", ":0")
|
||||
panicOnErr(err, "starting TCP listener")
|
||||
fmt.Printf("Server running at %s\n", listener.Addr())
|
||||
mem := memfs.New()
|
||||
f, err := mem.Create("hello.txt")
|
||||
panicOnErr(err, "creating file")
|
||||
_, err = f.Write([]byte("hello world"))
|
||||
panicOnErr(err, "writing data")
|
||||
f.Close()
|
||||
handler := nfshelper.NewNullAuthHandler(mem)
|
||||
cacheHelper := nfshelper.NewCachingHandler(handler, 1)
|
||||
panicOnErr(nfs.Serve(listener, cacheHelper), "serving nfs")
|
||||
}
|
||||
|
||||
func panicOnErr(err error, desc ...interface{}) {
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
log.Println(desc...)
|
||||
log.Panicln(err)
|
||||
}
|
Loading…
Reference in New Issue
Block a user