proplo

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2020 License: MIT Imports: 11 Imported by: 0

README

proplo

ProxyProtocol Logger daemon

Usage

$ proplo
proplo [local_host:port] [upstream_host:port]

Example

Run proplo on 127.0.0.1:9876 which proxy to 10.8.0.1:80.

$ proplo 127.0.0.1:9876 10.8.0.1:80
2020/02/25 00:52:07 [info] Upstream 10.8.0.1:80
2020/02/25 00:52:07 [info] Listening 127.0.0.1:9876

Try connect to proplo with Proxy Protocol and send some payloads.

$ telnet 127.0.0.1 9876
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
PROXY TCP4 192.168.1.1 172.16.0.1 9999 8888
GET / HTTP/1.0

proplo proxies the payloads to the upstream and outputs logs of the connection.

{"id":"e4640056-4811-4fce-9948-d00231cf5454","type":"connect","time":"2020-02-25T00:52:36.68708+09:00","client_addr":"192.168.1.1:9999","proxy_addr":"10.8.0.6:61424","upstream_addr":"10.8.0.1:80","status":"connected","client_at":"2020-02-25T00:52:17.000776+09:00","upstream_at":"2020-02-25T00:52:36.687079+09:00"}
{"id":"e4640056-4811-4fce-9948-d00231cf5454","type":"transfer","time":"2020-02-25T00:52:44.835855+09:00","src_addr":"10.8.0.1:80","proxy_addr":"10.8.0.6:61424","dest_addr":"192.168.1.1:9999","bytes":337,"duration":27.834918903,"error":null}
{"id":"e4640056-4811-4fce-9948-d00231cf5454","type":"transfer","time":"2020-02-25T00:52:44.836469+09:00","src_addr":"192.168.1.1:9999","proxy_addr":"10.8.0.6:61424","dest_addr":"10.8.0.1:80","bytes":18,"duration":27.835533649,"error":null}
Ignoring health check access

When you ignore health check accesses from specified CIDR, set -ignore-cidr flag.

proplo -ignore-cidr 192.168.0.0/24 ignores logging and proxying to upstream connect from 192.168.0.0/24.

LICENSE

MIT

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	PrintStatusInterval = time.Minute
	UpstreamTimeout     = 30 * time.Second
)

Functions

func Run

func Run(ctx context.Context, opt *Options) error

Run runs proplo

Types

type Dashboard added in v0.0.5

type Dashboard struct {
	LogStatuses map[string]*LogStatus
	// contains filtered or unexported fields
}

Dashboard is a log status storage.

func (*Dashboard) Post added in v0.0.5

func (d *Dashboard) Post(l *LogConnect)

func (*Dashboard) Print added in v0.0.5

func (d *Dashboard) Print() error

func (*Dashboard) Remove added in v0.0.5

func (d *Dashboard) Remove(id string)

type LogConnect

type LogConnect struct {
	Type         string    `json:"type"`
	Time         time.Time `json:"time"`
	ClientAddr   string    `json:"client_addr"`
	ProxyAddr    string    `json:"proxy_addr"`
	UpstreamAddr string    `json:"upstream_addr"`
	Status       string    `json:"status"`
	Error        error     `json:"error"`
	ClientAt     time.Time `json:"client_at"`
	UpstreamAt   time.Time `json:"upstream_at"`
	ID           string    `json:"id"`
}

LogConnect represents log at connected

func (*LogConnect) Print

func (l *LogConnect) Print(status string) error

Print prints a log message to STDOUT as JSON.

type LogDisconnect added in v0.0.5

type LogDisconnect struct {
	Type         string    `json:"type"`
	Time         time.Time `json:"time"`
	ClientAddr   string    `json:"client_addr"`
	ProxyAddr    string    `json:"proxy_addr"`
	UpstreamAddr string    `json:"upstream_addr"`
	Src          string    `json:"src"`
	Dest         string    `json:"dest"`
	Bytes        int64     `json:"bytes"`
	Duration     float64   `json:"duration"`
	Error        error     `json:"error"`
	ID           string    `json:"id"`
}

LogDisconnect represents log at disconnected

func (*LogDisconnect) Print added in v0.0.5

func (l *LogDisconnect) Print() error

Print prints a log message to STDOUT as JSON.

type LogStatus added in v0.0.5

type LogStatus struct {
	Type         string    `json:"type"`
	Time         time.Time `json:"time"`
	ClientAddr   string    `json:"client_addr"`
	ProxyAddr    string    `json:"proxy_addr"`
	UpstreamAddr string    `json:"upstream_addr"`
	ClientAt     time.Time `json:"client_at"`
	UpstreamAt   time.Time `json:"upstream_at"`
	Duration     float64   `json:"duration"`
	ID           string    `json:"id"`
}

LogStatus represents a log while in connecting.

func (*LogStatus) Print added in v0.0.5

func (l *LogStatus) Print() error

Print prints a log message to STDOUT as JSON.

type LogSummary added in v0.0.5

type LogSummary struct {
	Type        string    `json:"type"`
	Time        time.Time `json:"time"`
	Connections int       `json:"connections"`
}

LogSummary represents log message for summary of status.

func (*LogSummary) Print added in v0.0.5

func (l *LogSummary) Print() error

type Options added in v0.0.3

type Options struct {
	LocalAddr    string
	UpstreamAddr string
	IgnoreCIDR   string
	// contains filtered or unexported fields
}

func (*Options) Ignore added in v0.0.3

func (o *Options) Ignore(ip net.IP) bool

func (*Options) Validate added in v0.0.3

func (o *Options) Validate() error

Directories

Path Synopsis
cmd
proplo command

Jump to

Keyboard shortcuts

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