Documentation
¶
Index ¶
- Constants
- func NewDVFSUniversalCertPool() (*x509.CertPool, error)
- type CNode
- type CacheHandler
- func (c *CacheHandler) ChangeDirectory(s string) error
- func (c *CacheHandler) ClearCache()
- func (c *CacheHandler) ClearTrash() (int, error)
- func (c *CacheHandler) CreateDirectory(s string) (*FileInfo, error)
- func (c *CacheHandler) CreateFile(s string) (*FileInfo, error)
- func (c *CacheHandler) DeleteFile(s string, recursive bool) error
- func (c *CacheHandler) DeleteFromTrash(name string) error
- func (c *CacheHandler) Download(s string) error
- func (c *CacheHandler) GetFileInfo() (*FileInfo, error)
- func (c *CacheHandler) InvalidateFileByFID(fid *domain.FID) (string, bool)
- func (c *CacheHandler) ListFiles() ([]*FileInfo, error)
- func (c *CacheHandler) Path() (string, error)
- func (c *CacheHandler) ReadFile(s string) ([]byte, error)
- func (c *CacheHandler) Refresh() error
- func (c *CacheHandler) RestoreFile(name string) (string, error)
- func (c *CacheHandler) Share(s string) error
- func (c *CacheHandler) ShowTrash() ([]*FileInfo, error)
- func (c *CacheHandler) TrashFile(name string, recursive bool) (string, error)
- func (c *CacheHandler) Unshare(s string) error
- func (c *CacheHandler) Upload(s string) error
- func (c *CacheHandler) VisualizeCache(indent string)
- type Client
- func (c *Client) AttachCacheHandler(cacheHandler *CacheHandler)
- func (c *Client) ChangeCurrentFID(fid *domain.FID)
- func (c *Client) ChangeDirectory(relative_path string) (domain.FID, error)
- func (c *Client) ClearTrash() (int, error)
- func (c *Client) Connect(serverAddress string) (*domain.FID, error)
- func (c *Client) CreateDirectory(name string) (*FileInfo, error)
- func (c *Client) CreateFile(name string) (*FileInfo, error)
- func (c *Client) DeleteFile(name string, recursive bool) error
- func (c *Client) DeleteFromTrash(name string) error
- func (c *Client) Disconnect()
- func (c *Client) Download(path string) error
- func (c *Client) DownloadFile(name string) error
- func (c *Client) GetFIDForPath(path string) (*domain.FID, error)
- func (c *Client) GetFileInfo() (*FileInfo, error)
- func (client *Client) GetRoots(msAddr string) ([]SharedRoot, error)
- func (c *Client) ListFiles() ([]*FileInfo, error)
- func (c *Client) ListFilesAt(dirFID *domain.FID) ([]*FileInfo, error)
- func (client *Client) NavigateToFileServer(msAddr string) (string, error)
- func (c *Client) Notify(format string, args ...interface{})
- func (c *Client) Path() (string, error)
- func (c *Client) ReRegister() error
- func (c *Client) ReadFile(name string) ([]byte, error)
- func (c *Client) Resolver() *DiscoveryResolver
- func (c *Client) RestoreFile(name string) (string, error)
- func (c *Client) SetNotifyWriter(w io.Writer)
- func (c *Client) SetRootPath(display_name, path string)
- func (c *Client) SetRootUser(root_user string)
- func (c *Client) Share(share_with string) error
- func (c *Client) ShowTrash() ([]*FileInfo, error)
- func (c *Client) TrashFile(name string, recursive bool) (string, error)
- func (c *Client) Unshare(unshare_with string) error
- func (c *Client) Upload(localPath string) (*domain.FID, error)
- func (c *Client) WriteFile(name string, data []byte) error
- type ClientOption
- type CobraCompleter
- type CobraHandler
- type DiscoveryOption
- type DiscoveryResolver
- func (d *DiscoveryResolver) FetchNodes(ctx context.Context) (map[string]string, error)
- func (d *DiscoveryResolver) Lookup(nodeName string) (string, error)
- func (d *DiscoveryResolver) ResolveMetaAddress(defaultPort string) (string, error)
- func (d *DiscoveryResolver) ResolveServerName(address string) string
- func (d *DiscoveryResolver) SetNodes(nodes []GistNode)
- type FileInfo
- type GistNode
- type SharedRoot
Constants ¶
const ( // DefaultGistURL points to the canonical machines.json published by the cluster. DefaultGistURL = "https://gist.githubusercontent.com/dvfs-iitgn/6eb8da397735b83f76b54af4cca64c83/raw/machines.json" // DefaultGistTimeout is the maximum duration to wait for a Gist response. DefaultGistTimeout = 8 * time.Second // DefaultCacheTTL is the duration after which cached entries are considered stale. DefaultCacheTTL = 5 * time.Minute )
const CacheDir = "./.cache"
const DownloadDir = "./Download"
const RootCAPEM = `` /* 2109-byte string literal not displayed */
RootCAPEM contains the public certificate of the 10-year offline DVFS Root CA. Embedded directly into the client binary; no external ca_cert file required.
Variables ¶
This section is empty.
Functions ¶
func NewDVFSUniversalCertPool ¶
NewDVFSUniversalCertPool creates an isolated x509.CertPool containing strictly the DVFS Root CA, completely ignoring the host operating system's root store. It uses the embedded RootCAPEM and also incorporates any local certs/ca.crt if found.
Types ¶
type CNode ¶
type CNode struct {
Name string
Type domain.InodeType // 0 for file, 1 for directory
Size uint64 // size of the file (for files)
// contains filtered or unexported fields
}
CNode represents a cached file or directory in the client, and are made to mirror the structure of the remote file system as it gets accessed. They are stored in a tree structure, with the root node representing the root directory of the remote file system. Each CNode has a name, type (file or directory), a map of children nodes (for directories), and a reference to its parent node. The client uses CNodes to cache metadata about files and directories, allowing for faster access and reduced network calls when navigating the file system or performing operations on files and directories.
type CacheHandler ¶
type CacheHandler struct {
// contains filtered or unexported fields
}
func NewCacheHandler ¶
func NewCacheHandler(c *Client, rootFID *domain.FID) *CacheHandler
func (*CacheHandler) ChangeDirectory ¶
func (c *CacheHandler) ChangeDirectory(s string) error
func (*CacheHandler) ClearCache ¶
func (c *CacheHandler) ClearCache()
func (*CacheHandler) ClearTrash ¶
func (c *CacheHandler) ClearTrash() (int, error)
func (*CacheHandler) CreateDirectory ¶
func (c *CacheHandler) CreateDirectory(s string) (*FileInfo, error)
func (*CacheHandler) CreateFile ¶
func (c *CacheHandler) CreateFile(s string) (*FileInfo, error)
func (*CacheHandler) DeleteFile ¶
func (c *CacheHandler) DeleteFile(s string, recursive bool) error
delete file/dir from server and update cache accordingly. If recursive is true, delete all contents of the directory as well
func (*CacheHandler) DeleteFromTrash ¶
func (c *CacheHandler) DeleteFromTrash(name string) error
func (*CacheHandler) Download ¶
func (c *CacheHandler) Download(s string) error
func (*CacheHandler) GetFileInfo ¶
func (c *CacheHandler) GetFileInfo() (*FileInfo, error)
func (*CacheHandler) InvalidateFileByFID ¶
func (c *CacheHandler) InvalidateFileByFID(fid *domain.FID) (string, bool)
InvalidateFileByFID clears cached content for a file and returns a display path.
func (*CacheHandler) ListFiles ¶
func (c *CacheHandler) ListFiles() ([]*FileInfo, error)
func (*CacheHandler) Path ¶
func (c *CacheHandler) Path() (string, error)
func (*CacheHandler) ReadFile ¶
func (c *CacheHandler) ReadFile(s string) ([]byte, error)
check for cache hit, if not then download file from server and update cache
func (*CacheHandler) Refresh ¶
func (c *CacheHandler) Refresh() error
Refresh synchronizes the current directory cache with server state.
func (*CacheHandler) RestoreFile ¶
func (c *CacheHandler) RestoreFile(name string) (string, error)
RestoreFile restores an item from server-side trash and updates cache if currently viewing trash.
func (*CacheHandler) Share ¶
func (c *CacheHandler) Share(s string) error
func (*CacheHandler) ShowTrash ¶
func (c *CacheHandler) ShowTrash() ([]*FileInfo, error)
func (*CacheHandler) TrashFile ¶
func (c *CacheHandler) TrashFile(name string, recursive bool) (string, error)
TrashFile moves a file/dir to server-side trash and updates the current cache view.
func (*CacheHandler) Unshare ¶
func (c *CacheHandler) Unshare(s string) error
func (*CacheHandler) Upload ¶
func (c *CacheHandler) Upload(s string) error
func (*CacheHandler) VisualizeCache ¶
func (c *CacheHandler) VisualizeCache(indent string)
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client provides basic VFS client functionality
func NewClient ¶
func NewClient(username string, opts ...ClientOption) *Client
NewClient creates a new VFS client using the hardcoded Root CA by default.
func (*Client) AttachCacheHandler ¶
func (c *Client) AttachCacheHandler(cacheHandler *CacheHandler)
AttachCacheHandler wires cache invalidation callbacks to the active cache handler.
func (*Client) ChangeCurrentFID ¶
func (*Client) ChangeDirectory ¶
CreateDirectory changes the current directory
func (*Client) ClearTrash ¶
ClearTrash permanently deletes every entry currently present in trash.
func (*Client) Connect ¶
Connect connects to a file server and gets user root and files/dir in the root
func (*Client) CreateDirectory ¶
CreateDirectory creates a new directory
func (*Client) CreateFile ¶
CreateFile creates a new file
func (*Client) DeleteFile ¶
DeleteFile deletes a file or directory by name in the current directory If recursive is true, non-empty directories will be deleted with all contents
func (*Client) DeleteFromTrash ¶
DeleteFromTrash permanently deletes a single file/directory currently in trash. Directories are always deleted recursively when deleting from trash.
func (*Client) Disconnect ¶
func (c *Client) Disconnect()
Disconnect gracefully unregisters the client from the fileserver, closes the gRPC connection, and shuts down the callback listener.
func (*Client) DownloadFile ¶
func (*Client) GetFIDForPath ¶
GetFIDForPath returns the FID of a path relative to current or root directory
func (*Client) GetFileInfo ¶
GetFileInfo gets information about user's current directory
func (*Client) GetRoots ¶
func (client *Client) GetRoots(msAddr string) ([]SharedRoot, error)
GetRoots gets the accessible roots to the user from the metaserver
func (*Client) ListFilesAt ¶
ListFilesAt lists files/directories for the provided directory FID. It does not change the client's current directory.
func (*Client) NavigateToFileServer ¶
NavigateToFileServer dials the meta server over TLS and navigates the client to the appropriate file server. selfAddr is the host:port that the meta server should store as this FS's address. If msAddr is empty this is a no-op.
func (*Client) Notify ¶
Notify prints a notification message. If a readline-aware writer is set it uses that (which redraws the prompt); otherwise it falls back to os.Stdout.
func (*Client) ReRegister ¶
ReRegister re-establishes the client session with the fileserver. This restores the server-side session (for callbacks) and verifies that the root FID hasn't changed.
func (*Client) Resolver ¶
func (c *Client) Resolver() *DiscoveryResolver
Resolver returns the client's discovery resolver.
func (*Client) RestoreFile ¶
RestoreFile restores a trashed file/directory (by name in .trash) back to its original location.
func (*Client) SetNotifyWriter ¶
SetNotifyWriter provides a readline-aware writer so notifications correctly redraw the prompt instead of overwriting it.
func (*Client) ShowTrash ¶
ShowTrash lists the user's trash contents without navigating into .trash.
func (*Client) TrashFile ¶
TrashFile moves a file or directory (by name in current directory) to the user's trash. If recursive is true, non-empty directories can be trashed.
type ClientOption ¶
type ClientOption func(*Client)
ClientOption configures optional client settings (primarily for testing).
func WithDiscovery ¶
func WithDiscovery(resolver *DiscoveryResolver) ClientOption
WithDiscovery attaches a custom DiscoveryResolver to the client.
func WithInsecure ¶
func WithInsecure() ClientOption
WithInsecure disables TLS verification (for local in-memory unit tests only).
func WithServerName ¶
func WithServerName(name string) ClientOption
WithServerName sets a custom TLS server name (SNI).
type CobraCompleter ¶
type CobraCompleter struct {
// contains filtered or unexported fields
}
CobraCompleter implements readline.Completer using the Cobra command tree
type CobraHandler ¶
type CobraHandler struct {
// contains filtered or unexported fields
}
CobraHandler handles commands using Cobra
func NewCobraHandler ¶
func NewCobraHandler(cacheHandler *CacheHandler) *CobraHandler
NewCobraHandler creates a new Cobra-based command handler
func (*CobraHandler) Start ¶
func (h *CobraHandler) Start() bool
Start begins the interactive command loop
type DiscoveryOption ¶
type DiscoveryOption func(*DiscoveryResolver)
DiscoveryOption configures a DiscoveryResolver.
func WithCacheFile ¶
func WithCacheFile(path string) DiscoveryOption
WithCacheFile overrides the local disk cache path.
func WithCacheTTL ¶
func WithCacheTTL(ttl time.Duration) DiscoveryOption
WithCacheTTL sets the time-to-live for cached discovery entries.
func WithGistURL ¶
func WithGistURL(url string) DiscoveryOption
WithGistURL overrides the default Gist URL.
func WithHTTPClient ¶
func WithHTTPClient(client *http.Client) DiscoveryOption
WithHTTPClient overrides the default HTTP client.
type DiscoveryResolver ¶
type DiscoveryResolver struct {
// contains filtered or unexported fields
}
DiscoveryResolver dynamically resolves cluster node hostnames to IPs and vice versa.
func NewDiscoveryResolver ¶
func NewDiscoveryResolver(opts ...DiscoveryOption) *DiscoveryResolver
NewDiscoveryResolver initializes a resolver with default or custom options.
func (*DiscoveryResolver) FetchNodes ¶
FetchNodes polls the GitHub Gist over HTTPS, updates memory caches, and persists to disk. If the network request fails, it falls back to the persisted disk cache.
func (*DiscoveryResolver) Lookup ¶
func (d *DiscoveryResolver) Lookup(nodeName string) (string, error)
Lookup returns the IP address for the given node identifier (e.g. "dvfs1"). If the cache is empty or stale, it attempts a live fetch.
func (*DiscoveryResolver) ResolveMetaAddress ¶
func (d *DiscoveryResolver) ResolveMetaAddress(defaultPort string) (string, error)
ResolveMetaAddress resolves the metaserver (dvfs1) IP and formats host:port.
func (*DiscoveryResolver) ResolveServerName ¶
func (d *DiscoveryResolver) ResolveServerName(address string) string
ResolveServerName determines the TLS SNI / SAN name to verify against. Given "10.0.171.38:50051", it extracts "10.0.171.38", checks if it maps to "dvfs1", and returns "dvfs1". For "127.0.0.1" or "localhost", it returns "localhost".
func (*DiscoveryResolver) SetNodes ¶
func (d *DiscoveryResolver) SetNodes(nodes []GistNode)
SetNodes manually sets node mappings (primarily for unit tests and local overrides).