• Stars
    star
    651
  • Rank 69,175 (Top 2 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created over 4 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

golang NFSv3 server

Golang Network File Server

NFSv3 protocol implementation in pure Golang.

Current Status:

  • Minimally tested
  • Mounts, read-only and read-write support

Usage

The most interesting demo is currently in example/osview.

Start the server go run ./example/osview ..

The local folder at . will be the initial view in the mount. mutations to metadata or contents will be stored purely in memory and not written back to the OS. When run, this demo will print the port it is listening on.

The mount can be accessed using a command similar to mount -o port=<n>,mountport=<n> -t nfs localhost:/mount <mountpoint> (For Mac users)

or

mount -o port=<n>,mountport=<n>,nfsvers=3,noacl,tcp -t nfs localhost:/mount <mountpoint> (For Linux users)

API

The NFS server runs on a net.Listener to export a file system to NFS clients. Usage is structured similarly to many other golang network servers.

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)
}

Notes

  • Ports are typically determined through portmap. The need for running portmap (which is the only part that needs a privileged listening port) can be avoided through specific mount options. e.g. mount -o port=n,mountport=n -t nfs host:/mount /localmount

  • This server currently uses billy to provide a file system abstraction layer. There are some edges of the NFS protocol which do not translate to this abstraction.

    • NFS expects access to an inode or equivalent unique identifier to reference files in a file system. These are considered opaque identifiers here, which means they will not work as expected in cases of hard linking.
    • The billy abstraction layer does not extend to exposing uid and gid ownership of files. If ownership is important to your file system, you will need to ensure that the os.FileInfo meets additional constraints. In particular, the Sys() escape hatch is queried by this library, and if your file system populates a syscall.Stat_t concrete struct, the ownership specified in that object will be used.
  • Relevant RFCS: 5531 - RPC protocol, 1813 - NFSv3, 1094 - NFS

More Repositories

1

goturn

A golang TURN dialer
Go
36
star
2

activist

activist.js is a drop-in library for resilience to network interference
JavaScript
30
star
3

ip2country

A standalone ip -> country lookup table. Prebuilt & Redistributable.
JavaScript
22
star
4

pintos

Extensions to the Stanford pintos code base providing alternative assignments.
C
15
star
5

ChromeProxy

A Chrome extension to easily toggle proxy settings
JavaScript
15
star
6

DriveCode

Chrome Text editor linked to Google Drive
JavaScript
15
star
7

onionproxy

A proxy for allowing a public IP address to host a service actually provided by a hidden backend.
Go
14
star
8

gosendmail

Outbound mail sender with dkim StartTLS
Go
12
star
9

onionservice

like http.createServer(), but for onions.
JavaScript
11
star
10

sp3

(SP)^3: A Simple, Practical, and Safe Packet Spoofing Protocol
Go
9
star
11

carbs

πŸ” A Car (read-only) BlockStore
Go
8
star
12

webrtc-adapter

Commonjs adapter.js browser compatibility shim for webRTC
JavaScript
8
star
13

geosub

Geographic based subscription service
Python
6
star
14

rappor

Javascript implementation of the RAPPOR algorithm
JavaScript
5
star
15

venstream

Ven-diagram-esque Intersection & Union transformation for node.js streams
JavaScript
5
star
16

HangoutReceptionist

Chrome Extension which automatically joins hangouts it is invited to.
JavaScript
4
star
17

e2e

NPM package for End-to-End OpenPGP Library
JavaScript
4
star
18

calmnetviz

Processing network usage visualization
Java
4
star
19

OneBusHome

Passive Deployment of OneBusAway
JavaScript
3
star
20

clockOS

ClockOS manual and software
Arduino
3
star
21

wasm-adl

A WASM wrapper for IPLD ADLs
Go
3
star
22

libp2p-probe

probe a libp2p host to see what protocols it speaks
Go
3
star
23

launchpadd

Automatically exported from code.google.com/p/launchpadd
C
2
star
24

pautils

Commandline Utilities for controlling pulse audio
C
2
star
25

connecttor

Node Tor Dependency
JavaScript
2
star
26

ChromeIcon

Attach custom icons to chrome profiles
Objective-C
2
star
27

talexmpp

XMPP shim for Talek
Go
2
star
28

p2pbr

peer to peer broadcast roulette
Objective-C
2
star
29

map-stream-concurrent

like map-stream, but with a specified degree of parallelism.
JavaScript
2
star
30

Porcupine

Kernel module opcode fuzzer
Assembly
2
star
31

cfc

JavaScript
1
star
32

go-selfish-bitswap-client

A minimal bitswap client
Go
1
star
33

go-netroute

crossplatform interface to routing tables
Go
1
star
34

zipfian

Zipf Distribution Generation for Node.js
JavaScript
1
star
35

memphis

A golang memory FS
Go
1
star
36

http-cid-data

example of an http provider of content addressed data
1
star
37

browser-libp2p-pubsub

Experimental in-browser messaging
JavaScript
1
star
38

OneSwarmDirectoryServer

Directory Server to support OneSwarm clients in finding Exit Nodes.
Java
1
star
39

rc3-badges

badges from RC3
HTML
1
star
40

js-rle

RLE+ encoding/decoding
JavaScript
1
star
41

freedom-oauth-relay

A static oAuth redirection URL, which allows oAuth for web apps loaded from an uncertain origin.
JavaScript
1
star
42

2fsigil

A small browser extension indicating if the current site supports 2fa
JavaScript
1
star
43

godmpe

Munging of Windows PE files
Go
1
star
44

oonimap

grab slices of ooni data
JavaScript
1
star
45

traas2

v2 of trace route as a service
Go
1
star