ctlsock

package
v1.4.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 18, 2018 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package ctlsock implements the control socket interface that can be activated by passing "-ctlsock" on the command line.

Index

Constants

View Source
const ReadBufSize = 5000

ReadBufSize is the size of the request read buffer. The longest possible path is 4096 bytes on Linux and 1024 on Mac OS X so 5000 bytes should be enough to hold the whole JSON request. This assumes that the path does not contain too many characters that had to be be escaped in JSON (for example, a null byte blows up to "\u0000"). We abort the connection if the request is bigger than this.

Variables

This section is empty.

Functions

func SanitizePath

func SanitizePath(path string) string

SanitizePath adapts filepath.Clean for FUSE paths.

  1. Leading slash(es) are dropped
  2. It returns "" instead of "."
  3. If the cleaned path points above CWD (start with ".."), an empty string is returned

See the TestSanitizePath testcases for examples.

func Serve

func Serve(sock net.Listener, fs Interface)

Serve serves incoming connections on "sock". This call blocks so you probably want to run it in a new goroutine.

Types

type Interface

type Interface interface {
	EncryptPath(string) (string, error)
	DecryptPath(string) (string, error)
}

Interface should be implemented by fusefrontend[_reverse]

type RequestStruct

type RequestStruct struct {
	EncryptPath string
	DecryptPath string
}

RequestStruct is sent by a client

type ResponseStruct

type ResponseStruct struct {
	// Result is the resulting decrypted or encrypted path. Empty on error.
	Result string
	// ErrNo is the error number as defined in errno.h.
	// 0 means success and -1 means that the error number is not known
	// (look at ErrText in this case).
	ErrNo int32
	// ErrText is a detailed error message.
	ErrText string
	// WarnText contains warnings that may have been encountered while
	// processing the message.
	WarnText string
}

ResponseStruct is sent by us as response to a request

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL