froxy

package module
v0.0.0-...-95c1d2b Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2015 License: MIT Imports: 6 Imported by: 0

README

froxy

A Reverse File Proxy

##Dependencies The Froxy library depends only on the Go standard library. Go version 1.4 and above is suggested. The Froxy command uses spf13's Cobra and Viper, both of which have been vendored into the cmd/froxy directory.

##Installing and Building To install just the library run:

go get github.com/skriptble/froxy

To install the library and the froxy command run:

go get github.com/skriptble/froxy/...

##Testing Testing from a third party service can be achieved by starting this service, and pointing the remote endpoint at a server the third party controls or knows the contents of. The third party may then execute several requests to froxy, evaluating the responses are correct.

Testing the local proxy functionality requires the service to be running in an environment under the control of the tester. The tester should place files somewhere in the local environment, start the froxy service, pointing the local endpoint at the local environment. The tester may then execute several tests from another service or machine and validate the responses are correct.

Testing of the binary itself could be achieved with a shell script that runs and sets various flags and environment variables and ensuring the binary starts up correctly, with the FileSources initialized to the correct directory or URL. The application could also be refactored to allow testing of this functionality internally by setting the various flags and environment variables to an injectable struct or type.

Unit and Functional tests have been written for each component of the library. These tests cover most of the paths through each individual component. Integration tests between components have not been written.

##Architecture The main interface for this package is Proxy. Implementers should use that and a ProxyBuilder to construct the proxy, then pass file names and sources in to retrieve files from said sources. The Proxy will return a ReadCloser or an error.

The sources for files implement the FileSource interface. This interface is structured similarly to the http package's FileSystem, the main difference being the Open method returns an io.ReadCloser instead of an http.File. This is done so that an http.Response.Body does not need to wrapped in an implementation of http.File. Since this interface only has a single Open method, it is fairly trivial to add new types of file sources.

This package provides two FileSource implementations, one for the local file system, and another for a remote file system. The local file system implementation wraps the http.Dir implementation while the remote file system is written from scratch. The path for the local and URL for the remote are configurable.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NotFound = errors.New("File could not be found")

Functions

This section is empty.

Types

type Dir

type Dir string

Dir is just a wrapper around http.Dir.

func (Dir) Open

func (d Dir) Open(name string) (io.ReadCloser, error)

Open implements the Open method on the FileSource interface. This just wraps http.Dir's open method.

type FileSource

type FileSource interface {
	// Open takes a file name and returns a ReadCloser and an error.
	Open(name string) (io.ReadCloser, error)
}

FileSource is the interface used by the Proxy to retrieve files.

func NewRemote

func NewRemote(href url.URL) FileSource

NewRemote creates a new FileSource that retrieves files from the given url.

type Proxy

type Proxy interface {
	// RetrieveFile takes a name and the source and returns an io.ReadCloser
	// and an error. A nil ReadCloser or an error will result in a 404.
	RetrieveFile(name string, source string) (io.ReadCloser, error)
}

type ProxyBuilder

type ProxyBuilder interface {
	Proxy
	// AddFileSource takes a FileSource and the source name and adds it to the proxy
	// returning an error if a problem occurs.
	AddFileSource(FileSource, string) error
}

ProxyBuilder is the interface used to construct an implementation of a Proxy.

func NewProxy

func NewProxy() ProxyBuilder

Directories

Path Synopsis
cmd
froxy/Godeps/_workspace/src/github.com/kr/pretty
Package pretty provides pretty-printing for Go values.
Package pretty provides pretty-printing for Go values.
froxy/Godeps/_workspace/src/github.com/kr/text
Package text provides rudimentary functions for manipulating text in paragraphs.
Package text provides rudimentary functions for manipulating text in paragraphs.
froxy/Godeps/_workspace/src/github.com/kr/text/colwriter
Package colwriter provides a write filter that formats input lines in multiple columns.
Package colwriter provides a write filter that formats input lines in multiple columns.
froxy/Godeps/_workspace/src/github.com/kr/text/mc
Command mc prints in multiple columns.
Command mc prints in multiple columns.
froxy/Godeps/_workspace/src/github.com/magiconair/properties
Package properties provides functions for reading and writing ISO-8859-1 and UTF-8 encoded .properties files and has support for recursive property expansion.
Package properties provides functions for reading and writing ISO-8859-1 and UTF-8 encoded .properties files and has support for recursive property expansion.
froxy/Godeps/_workspace/src/github.com/mitchellh/mapstructure
The mapstructure package exposes functionality to convert an abitrary map[string]interface{} into a native Go structure.
The mapstructure package exposes functionality to convert an abitrary map[string]interface{} into a native Go structure.
froxy/Godeps/_workspace/src/github.com/spf13/cobra
Package cobra is a commander providing a simple interface to create powerful modern CLI interfaces.
Package cobra is a commander providing a simple interface to create powerful modern CLI interfaces.
froxy/Godeps/_workspace/src/github.com/spf13/pflag
pflag is a drop-in replacement for Go's flag package, implementing POSIX/GNU-style --flags.
pflag is a drop-in replacement for Go's flag package, implementing POSIX/GNU-style --flags.
froxy/Godeps/_workspace/src/github.com/xordataexchange/crypt/backend
Package backend provides the K/V store interface for crypt backends.
Package backend provides the K/V store interface for crypt backends.
froxy/Godeps/_workspace/src/github.com/xordataexchange/crypt/encoding/secconf
Package secconf implements secconf encoding as specified in the following format: base64(gpg(gzip(data)))
Package secconf implements secconf encoding as specified in the following format: base64(gpg(gzip(data)))
froxy/Godeps/_workspace/src/golang.org/x/crypto/cast5
Package cast5 implements CAST5, as defined in RFC 2144.
Package cast5 implements CAST5, as defined in RFC 2144.
froxy/Godeps/_workspace/src/golang.org/x/crypto/openpgp
Package openpgp implements high level operations on OpenPGP messages.
Package openpgp implements high level operations on OpenPGP messages.
froxy/Godeps/_workspace/src/golang.org/x/crypto/openpgp/armor
Package armor implements OpenPGP ASCII Armor, see RFC 4880.
Package armor implements OpenPGP ASCII Armor, see RFC 4880.
froxy/Godeps/_workspace/src/golang.org/x/crypto/openpgp/clearsign
Package clearsign generates and processes OpenPGP, clear-signed data.
Package clearsign generates and processes OpenPGP, clear-signed data.
froxy/Godeps/_workspace/src/golang.org/x/crypto/openpgp/elgamal
Package elgamal implements ElGamal encryption, suitable for OpenPGP, as specified in "A Public-Key Cryptosystem and a Signature Scheme Based on Discrete Logarithms," IEEE Transactions on Information Theory, v.
Package elgamal implements ElGamal encryption, suitable for OpenPGP, as specified in "A Public-Key Cryptosystem and a Signature Scheme Based on Discrete Logarithms," IEEE Transactions on Information Theory, v.
froxy/Godeps/_workspace/src/golang.org/x/crypto/openpgp/errors
Package errors contains common error types for the OpenPGP packages.
Package errors contains common error types for the OpenPGP packages.
froxy/Godeps/_workspace/src/golang.org/x/crypto/openpgp/packet
Package packet implements parsing and serialization of OpenPGP packets, as specified in RFC 4880.
Package packet implements parsing and serialization of OpenPGP packets, as specified in RFC 4880.
froxy/Godeps/_workspace/src/golang.org/x/crypto/openpgp/s2k
Package s2k implements the various OpenPGP string-to-key transforms as specified in RFC 4800 section 3.7.1.
Package s2k implements the various OpenPGP string-to-key transforms as specified in RFC 4800 section 3.7.1.
froxy/Godeps/_workspace/src/gopkg.in/yaml.v2
Package yaml implements YAML support for the Go language.
Package yaml implements YAML support for the Go language.

Jump to

Keyboard shortcuts

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