heproxy

package module
v0.0.0-...-59443bb Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2015 License: AGPL-3.0 Imports: 12 Imported by: 0

README

heproxy

An HTTP -> HTTPS proxy, in the spirit of HTTPS Everywhere, which actually just uses the same rulesets as HTTPS Everywhere.

NOTE: This is pretty experimental. Expect there to be bugs

Installation

heproxy is currently in development, and I haven't thought about things like "releases" yet. For the brave, a simple:

$ go get github.com/apg/heproxy/cmd/heproxy

will work.

Usage

There's not much to it. If you're already using HTTPS Everywhere in your browser, but just want to make sure your lynx, curl and wget connections are secured when possible, do the following:

$ heproxy -listen :9999 &

Then set the http_proxy environment variable:

$ export http_proxy=http://localhost:9999

Magic will now happen whenever you use an HTTP client that supports the http_proxy environment variable.

Contributing and Feedback

It's possible that heproxy has bugs, and/or does something it shouldn't be, and/or has lots of room for improvement. If you'd like to fix or contribute something, please fork and submit a pull request, or open an issue.

If you have any other feedback, feel free to email me at the below address.

Authors

Andrew Gwozdziewycz web@apgwoz.com

Copyleft

Copyright 2015, Andrew Gwozdziewycz, web@apgwoz.com Licensed under the GNU AGPLv3. See LICENSE for more details.

The rulesets are Copyright HTTPS Everywhere Authors under the GPLv2.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEmptyPattern = errors.New("Empty pattern")

ErrPattern is returned as the error when a pattern is empty, but shouldn't be.

Functions

func NewHEProxy

func NewHEProxy(rw Rewriter) *httputil.ReverseProxy

NewHEProxy returns a new proxy which maps a request to an HTTPS url if available

Types

type Exclusion

type Exclusion struct {
	Pattern string
	// contains filtered or unexported fields
}

Exclusion represents a URL pattern which should not be rewritten.

func (*Exclusion) UnmarshalXML

func (e *Exclusion) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML unmarshals and compiles a regular expression pulled out of the XML.

type LinearRewriter

type LinearRewriter struct {
	// contains filtered or unexported fields
}

LinearRewriter holds rulesets for remapping URLs

func (*LinearRewriter) Rewrite

func (r *LinearRewriter) Rewrite(u *url.URL) *url.URL

Rewrite returns a new URL based on the contained rulesets

type Rewriter

type Rewriter interface {
	Rewrite(*url.URL) *url.URL
}

Rewriter rewrites url to a new url

func NewLinearRewriter

func NewLinearRewriter(rs []*RuleSet) Rewriter

NewLinearRewriter returns a Remapper which can remap URLs based on the RuleSets

func NewTrieRewriter

func NewTrieRewriter(rss []*RuleSet) Rewriter

NewTrieRewriter returns a TrieRewriter for remapping urls.

type Rule

type Rule struct {
	From string
	To   string
	// contains filtered or unexported fields
}

Rule represents a rewritten URL.

func (*Rule) Apply

func (r *Rule) Apply(old *url.URL) (new *url.URL, found bool)

Apply attempts to apply rule to given url

func (*Rule) UnmarshalXML

func (r *Rule) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML unmarshals and compiles a regular expression pulled out of the XML.

type RuleSet

type RuleSet struct {
	Name       string       `xml:"name,attr"`
	Targets    []*Target    `xml:"target"`
	Exclusions []*Exclusion `xml:"exclusion"`
	Rules      []*Rule      `xml:"rule"`
}

RuleSet represents a site, mapping from hostnames to HTTPS urls.

func NewRuleSet

func NewRuleSet(r io.Reader) (*RuleSet, error)

NewRuleSet returns a RuleSet read from `r`

func ReadRuleSets

func ReadRuleSets(baseDir string) []*RuleSet

ReadRuleSets iterates through a directory and returns a slice of rulesets.

func (*RuleSet) Excludes

func (r *RuleSet) Excludes(url *url.URL) bool

Excludes tests to see if url is excluded by this Ruleset

func (*RuleSet) Includes

func (r *RuleSet) Includes(u *url.URL) bool

Includes tests to see if url is included by this RuleSet

func (*RuleSet) Rewrite

func (r *RuleSet) Rewrite(url *url.URL) *url.URL

Rewrite attempts to rewrite the url.

type Target

type Target struct {
	Host string `xml:"host,attr"`
}

Target represents a set of hostnames, potentially with wildcards.

type TrieRewriter

type TrieRewriter struct {
	// contains filtered or unexported fields
}

TrieRewriter utilizes a trie tree for rewriting urls based on rulesets

func (*TrieRewriter) Rewrite

func (t *TrieRewriter) Rewrite(u *url.URL) *url.URL

Rewrite returns a new URL based on the contained rulesets

Directories

Path Synopsis
Godeps
_workspace/src/github.com/glenn-brown/golang-pkg-pcre/src/pkg/pcre
This package provides access to the Perl Compatible Regular Expresion library, PCRE.
This package provides access to the Perl Compatible Regular Expresion library, PCRE.
cmd

Jump to

Keyboard shortcuts

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