This package entails a server implementation for NFS v4 in pure go. It is heavily based on the works of https://github.com/smallfz/libnfs-go and allows to expose a virtual file system https://github.com/kuleuven/vfs over NFS v4.
Protocols v4.0, v4.1 and v4.2 are supported. RFC 7530, RFC 5661 and RFC 8276 are largely implemented. The current implementation has minimal server state, only a list of active clients is kept. No file locking is supported. The implemented authentication mechanism is AUTH_FLAVOR_UNIX, so that the client sends uid/gid/groups information to the server. It is possible to provide each user a different virtual file system.
The following operations are required by the RFCs but we didn't implement them:
OP4_BACKCHANNEL_CTLOP4_BIND_CONN_TO_SESSIONOP4_FREE_STATEIDOP4_ILLEGALOP4_LOCKOP4_LOCKTOP4_LOCKUOP4_SET_SSVOP4_TEST_STATEID
The following operations are optional by the RFCs and we didn't implement them:
OP4_ALLOCATEOP4_CLONEOP4_COPYOP4_COPY_NOTIFYOP4_DEALLOCATEOP4_DELEGPURGEOP4_DELEGRETURNOP4_GETDEVICEINFOOP4_GET_DIR_DELEGATIONOP4_IO_ADVISEOP4_LAYOUTCOMMITOP4_LAYOUTERROROP4_LAYOUTGETOP4_LAYOUTRETURNOP4_LAYOUTSTATSOP4_OFFLOAD_CANCELOP4_OFFLOAD_STATUSOP4_OPENATTROP4_READ_PLUSOP4_SEEKOP4_WANT_DELEGATIONOP4_WRITE_SAME
clockprovides a global clock used whenever the current time is needed. It cachestime.Now()since it is expensive to call frequently.loggerprovides a global logger that can be adapted for different logging needs.xdrhandles decoding and encoding of the NFS protocol messages.msgcontains the definitions of the NFS protocol messages.bufpoolmanages a pool of buffers for efficient memory allocation.clientsmanages the state of all NFS clients. A client can have one or multiple sessions. In case of NFS v4.0, we map a client ip to a single session.workermanages the combination of a session and user credentials, and maps it to a single virtual file system and state (open files). If a worker is idle for 5 minutes, it will be discarded and the virtual file system will be closed.
See cmd/nfs4go/example.go for an example exposing /srv over NFS v4.