Categorygithub.com/go-compile/localrelay
modulepackage
1.4.1
Repository: https://github.com/go-compile/localrelay.git
Documentation: pkg.go.dev

# README

LocalRelay

GitHub release Go Report Card go.dev reference Docker Size Docker Version GitHub Workflow Status

A cross platform CLI & lib which acts as a reverse proxy allowing the destination address to be customised and allows the use of a SOCKS5 proxy. Supporting both raw TCP connections and HTTP/HTTPS connections with options such as; IP locking, Certificate pinning. This app allows you to host services e.g. Nextcloud on Tor and access it on your mobile or laptop anywhere.

Use Cases

If you self host a service for example; Bitwarden, Nextcloud, Syncthing, Grafana, Gitea... You may not want to expose your public IP address to the internet. Especially considering some self-hosted platforms such as Plex has been exploited with code execution vulnerabilities. You may consider to protect it behind Tor (however this isn't full proof).

Access your local or remote services securely over Tor without needing to port forward.

Many apps such as Nextcloud, Termis and Bitwarden do not allow you to specify a proxy when connecting to your self-hosted server. Localrelay allows you to host a local reverse proxy on your devices loopback. This relay then encrypts the outgoing traffic through your set SOCKS5 proxy (Tor: 127.0.0.1:9050).

When at home connect locally, when away connect over Tor. Securely connect remotely over Tor without port forwarding AND when at home connect directly with high speeds.

This Repository

This repository contains the library written in Go, for it's cross platform capabilities, and contains the CLI application which can be ran on all major operating systems including Android via Termux.

For examples of API usage visit examples/.

Library Features

Min Go version: v1.17

  • Create relays with custom remote address
  • Proxy remote address through SOCKS5 proxy
  • Close relay concurrently
  • Verbose logging with custom output (io.Writer)
  • Multiple failover proxies for TCP relay
  • Failovers for TCP relays
  • Select which remote will connect via a proxy
  • HTTP relay
    • Http to https
    • Header modification
    • Useragent spoofing
    • Accept language spoofing
    • Proxy using socks5
  • Metrics
    • Upload/Download
    • Total connections
    • Active connections
    • Dialler: successes/failures
    • Concurrent safe
    • Dialler 10 point average response time
      • When using Tor this is the circuit build time

Privacy Proxies

Proxy your services whilst stripping personal information such as User-Agent, accept language or even cookies. Route the traffic through Tor to access the service anywhere in the word even behind a firewall.

Relay spoofing useragent & using Tor

Relay spoofing useragent & accept language

CLI Usage

This is a basic overview, view the wiki for more detailed information.

Create Relay

To run a relay you must first create a relay config, this allows for permanent storage of relay configuration and easy management. You can create as many of these as you like.

Syntax

# Create a simple TCP relay
localrelay new <relay_name> -host <bind_addr> -destination <remote_addr>

# Create HTTP relay
localrelay new <relay_name> -host <bind_addr> -destination <remote_addr> -http

# Create HTTPS relay
localrelay new <relay_name> -host <bind_addr> -destination <remote_addr> -https -certificate=cert.pem key=key.pem

# Use proxy
localrelay new <relay_name> -host <bind_addr> -destination <remote_addr> -proxy <proxy_url>

# Set custom output config file
localrelay new <relay_name> -host <bind_addr> -destination <remote_addr> -output ./config.toml

# Create a failover TCP relay
localrelay new <relay_name> -host <bind_addr> -destination <remote_addr_(1)>,<remote_addr_(2)> -failover

Examples

# Create a simple TCP relay
localrelay new example.com -host 127.0.0.1:8080 -destination example.com:80

# Create HTTP relay
localrelay new example.com -host 127.0.0.1:8080 -destination http://example.com -http

# Create HTTPS relay
localrelay new example.com -host 127.0.0.1:8080 -destination https://example.com -https -certificate=cert.pem key=key.pem

# Create a TCP relay and store it in the config dir to auto start on system boot (daemon required)
sudo localrelay new example.com -host 127.0.0.1:8080 -destination example.com:80 -store

# Use proxy
localrelay new onion -host 127.0.0.1:8080 -destination 2gzyxa5ihm7nsggfxnu52rck2vv4rvmdlkiu3zzui5du4xyclen53wid.onion:80 -proxy socks5://127.0.0.1:9050

# Create a failover TCP relay with one remote accessed via Tor
localrelay new onion -host 127.0.0.1:8080 -destination 192.168.1.240:80,2gzyxa5ihm7nsggfxnu52rck2vv4rvmdlkiu3zzui5du4xyclen53wid.onion:80 -failover -ignore_proxy=0 -proxy socks5://127.0.0.1:9050

localrelay status

Localrelay status

localrelay monitor

Localrelay status

# Packages

No description provided by the author
No description provided by the author

# Functions

HandleHTTP is to be used as the HTTP relay's handler set in the http.Server object.
New creates a new TCP relay.
NewLogger creates a new logging system.

# Constants

ProxyFailOverTCP acts like the TCP proxy however if it cannot connect it will use a failover address instead.
ProxyHTTP creates a HTTP server and forwards the traffic to either a HTTP or HTTPs server.
ProxyHTTPS is the same as HTTP but listens on TLS.
ProxyTCP is for raw TCP forwarding.
ProxyUDP forwards UDP traffic.
VERSION uses semantic versioning this version number is for the library not the CLI.

# Variables

ErrAddrNotMatch is returned when a server object has a addr which is not nil and does not equal the relay's address.
ErrFailConnect will be returned if the remote failed to dial.
ErrUnknownProxyType is returned when a relay has a proxy type which is invalid.
Timeout is only used when dialling without a proxy.

# Structs

Logger is used for logging debug information such as connections being created, dropped etc.
Metrics stores information such as bandwidth usage conn stats etc.
PooledConn allows meta data to be attached to a connection.
Relay represents a reverse proxy and all of its settings.

# Type aliases

ProxyType represents what type of proxy the relay is.