driveimpl
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Overview¶
Package driveimpl provides an implementation of package drive.
Index¶
- type FileServer
- func (s *FileServer) AddShareLocked(share, path string)
- func (s *FileServer) Addr() string
- func (s *FileServer) ClearSharesLocked()
- func (s *FileServer) Close() error
- func (s *FileServer) LockShares()
- func (s *FileServer) Serve() error
- func (s *FileServer) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (s *FileServer) SetShares(shares map[string]string)
- func (s *FileServer) UnlockShares()
- type FileSystemForLocal
- type FileSystemForRemote
Constants¶
This section is empty.
Variables¶
This section is empty.
Functions¶
This section is empty.
Types¶
typeFileServer¶
type FileServer struct {// contains filtered or unexported fields}FileServer is a standalone WebDAV server that dynamically serves up shares.It's typically used in a separate process from the actual Taildrive server toserve up files as an unprivileged user.
funcNewFileServer¶
func NewFileServer() (*FileServer,error)
NewFileServer constructs a FileServer.
The server attempts to listen at a random address on 127.0.0.1.The listen address is available via the Addr() method.
The server has to be told about shares before it can serve them. This isaccomplished either by calling SetShares(), or locking the shares withLockShares(), clearing them with ClearSharesLocked(), adding themindividually with AddShareLocked(), and finally unlocking them withUnlockShares().
The server doesn't actually process requests until the Serve() method iscalled.
func (*FileServer)AddShareLocked¶
func (s *FileServer) AddShareLocked(share, pathstring)
AddShareLocked adds a share to the map of shares, assuming that LockShares()has been called first.
func (*FileServer)Addr¶
func (s *FileServer) Addr()string
Addr returns the address at which this FileServer is listening. Thisincludes the secret token in front of the address, delimited by a pipe |.
func (*FileServer)ClearSharesLocked¶
func (s *FileServer) ClearSharesLocked()
ClearSharesLocked clears the map of shares, assuming that LockShares() hasbeen called first.
func (*FileServer)Close¶
func (s *FileServer) Close()error
func (*FileServer)LockShares¶
func (s *FileServer) LockShares()
LockShares locks the map of shares in preparation for manipulating it.
func (*FileServer)Serve¶
func (s *FileServer) Serve()error
Serve() starts serving files and blocks until it encounters a fatal error.
func (*FileServer)ServeHTTP¶
func (s *FileServer) ServeHTTP(whttp.ResponseWriter, r *http.Request)
ServeHTTP implements the http.Handler interface. This requires a secrettoken in the path in order to prevent Mark-of-the-Web (MOTW) bypass attacksof the below sort:
- Attacker with write access to the share puts a malicious file viahttp://100.100.100.100:8080/<tailnet>/<machine>/</share>/bad.exe
- Attacker then induces victim to visithttp://localhost:[PORT]/<share>/bad.exe
- Because that is loaded from localhost, it does not get the MOTWthereby bypasses some OS-level security.
The path on this file server is actually not as above, but ratherhttp://localhost:[PORT]/<secretToken>/<share>/bad.exe. Unless the attackercan discover the secretToken, the attacker cannot craft a localhost URL thatwill work.
func (*FileServer)SetShares¶
func (s *FileServer) SetShares(shares map[string]string)
SetShares sets the full map of shares to the new value, mapping name->path.
func (*FileServer)UnlockShares¶
func (s *FileServer) UnlockShares()
UnlockShares unlocks the map of shares.
typeFileSystemForLocal¶
type FileSystemForLocal struct {// contains filtered or unexported fields}FileSystemForLocal is the Taildrive filesystem exposed to local clients. Itprovides a unified WebDAV interface to remote Taildrive shares on other nodes.
funcNewFileSystemForLocal¶
func NewFileSystemForLocal(logflogger.Logf) *FileSystemForLocal
NewFileSystemForLocal starts serving a filesystem for local clients.Inbound connections must be handed to HandleConn.
func (*FileSystemForLocal)Close¶
func (s *FileSystemForLocal) Close()error
Close() stops serving the WebDAV content
func (*FileSystemForLocal)HandleConn¶
HandleConn handles connections from local WebDAV clients
func (*FileSystemForLocal)SetRemotes¶
func (s *FileSystemForLocal) SetRemotes(domainstring, remotes []*drive.Remote, transporthttp.RoundTripper)
SetRemotes sets the complete set of remotes on the given tailnet domainusing a map of name -> url. If transport is specified, that transportwill be used to connect to these remotes.
typeFileSystemForRemote¶
type FileSystemForRemote struct {// contains filtered or unexported fields}FileSystemForRemote implements drive.FileSystemForRemote.
funcNewFileSystemForRemote¶
func NewFileSystemForRemote(logflogger.Logf) *FileSystemForRemote
func (*FileSystemForRemote)Close¶
func (s *FileSystemForRemote) Close()error
Close() implements drive.FileSystemForRemote.
func (*FileSystemForRemote)ServeHTTPWithPerms¶
func (s *FileSystemForRemote) ServeHTTPWithPerms(permissionsdrive.Permissions, whttp.ResponseWriter, r *http.Request)
ServeHTTPWithPerms implements drive.FileSystemForRemote.
func (*FileSystemForRemote)SetFileServerAddr¶
func (s *FileSystemForRemote) SetFileServerAddr(addrstring)
SetFileServerAddr implements drive.FileSystemForRemote.
func (*FileSystemForRemote)SetShares¶
func (s *FileSystemForRemote) SetShares(shares []*drive.Share)
SetShares implements drive.FileSystemForRemote. Shares must be sortedaccording to drive.CompareShares.
Source Files¶
Directories¶
| Path | Synopsis |
|---|---|
Package compositedav provides an http.Handler that composes multiple WebDAV services into a single WebDAV service that presents each of them as its own folder. | Package compositedav provides an http.Handler that composes multiple WebDAV services into a single WebDAV service that presents each of them as its own folder. |
Package dirfs provides a webdav.FileSystem that looks like a read-only directory containing only subdirectories. | Package dirfs provides a webdav.FileSystem that looks like a read-only directory containing only subdirectories. |
Package shared contains types and functions shared by different drive packages. | Package shared contains types and functions shared by different drive packages. |