dphx

package module
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2016 License: BSD-3-Clause Imports: 9 Imported by: 0

README

dphx

Build Status

An SSH client that provides a tunnel to the remote network via a local SOCKS 5 server.

Designed to be managed as an unprivileged system service and work all the time at the background. Will only establish connection to SSH host if needed (i.e. when SOCKS request arrives) and disconnect automatically after some inactivity period. At the same time, SOCKS server is always listening for requests, and will manage SSH connection appropriately.

Remote DNS resolution is supported.

First SSH connection happens on first SOCKS request (requiring it to exist, but everything is proxified right now, so that would be any request).

Installation

GitHub Releases

The simplest way to install this software is to download a binary for your system from the GitHub Releases.

Go tools

To install via Go toolchain, use the following command:

go get github.com/MOZGIII/dphx/cmd/dphx

Config

Config is loaded from the process environment.

A sample settings file along with options description and example values is listed below.

# SSH server address.
export DPHX_SSH_ADDR='example.net'

# SSH username.
export DPHX_SSH_USER='user'

# SSH password (optional).
export DPHX_SSH_PASSWORD='password'

# SSH public key files list (optional).
export DPHX_SSH_PUBLIC_KEYS='/home/me/.ssh/id_rsa,/home/me/.ssh/other_id_rsa'

# SSH agent address, usually a unix socket.
# Defaults to $SSH_AUTH_SOCK value.
export DPHX_SSH_AGENT='/run/user/1337/keyring-blah/ssh'

# SOCKS5 server bind address (optional).
# Defaults to "127.0.0.1:1080".
export DPHX_SOCKS_ADDR='0.0.0.0:1080'

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListenAndServe

func ListenAndServe(network, addr string) error

ListenAndServe starts the SOCKS server.

func PrintEnv

func PrintEnv()

PrintEnv pirnts current environment.

func Run

func Run()

Run initializes config and starts SOCKS server.

func SSHDial

func SSHDial(ctx context.Context, network, addr string) (net.Conn, error)

SSHDial does dial via SSH connection to a remote server.

func SetEnv

func SetEnv()

SetEnv loads current env config.

func SetSSHConfigDefaults

func SetSSHConfigDefaults(sshConfig *SSHConfig)

SetSSHConfigDefaults adds default values that can only be set at runtime.

Types

type AppConfig

type AppConfig struct {
	SSH       SSHConfig
	LocalAddr string `envconfig:"SOCKS_ADDR" default:"127.0.0.1:1080"`
}

AppConfig loads and saves config.

type CountingSSHClient

type CountingSSHClient struct {
	*ssh.Client
}

func NewCountingSSHClient

func NewCountingSSHClient(sshClient *ssh.Client) *CountingSSHClient

func (CountingSSHClient) Dial

func (c CountingSSHClient) Dial(network, addr string) (net.Conn, error)

type EmptyResolver

type EmptyResolver struct{}

func (EmptyResolver) Resolve

func (EmptyResolver) Resolve(ctx context.Context, name string) (context.Context, net.IP, error)

type SSHConfig

type SSHConfig struct {
	ServerAddr string   `envconfig:"ADDR"`
	Username   string   `envconfig:"USER"`
	Password   string   `envconfig:"PASSWORD"`
	PublicKeys []string `envconfig:"PUBLIC_KEYS"`
	AgentAddr  string   `envconfig:"AGENT"`
}

SSHConfig stores configuration for SSH client

func (SSHConfig) AuthMethods

func (s SSHConfig) AuthMethods() ([]ssh.AuthMethod, error)

AuthMethods creates ssh.AuthMethod objects from current configuration.

func (SSHConfig) ClientConfig

func (s SSHConfig) ClientConfig() (*ssh.ClientConfig, error)

ClientConfig creates ssh.ClientConfig object from current configuration.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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