go-proxyproto

A Go library implementation of the PROXY protocol, versions 1 and 2.

Github星跟蹤圖

go-proxyproto

Build Status
Coverage Status
Go Report Card

A Go library implementation of the PROXY protocol, versions 1 and 2,
which provides, as per specification:

(...) a convenient way to safely transport connection
information such as a client's address across multiple layers of NAT or TCP
proxies. It is designed to require little changes to existing components and
to limit the performance impact caused by the processing of the transported
information.

This library is to be used in one of or both proxy clients and proxy servers that need to support said protocol.
Both protocol versions, 1 (text-based) and 2 (binary-based) are supported.

Installation

$ go get -u github.com/pires/go-proxyproto

Usage

Client (TODO)

Server

package main

import (
	"log"
	"net"
	
	proxyproto "github.com/pires/go-proxyproto"
)

func main() {
	// Create a listener
	addr := "localhost:9876"
	list, err := net.Listen("tcp", addr)
	if err != nil {
		log.Fatalf("couldn't listen to %q: %q\n", addr, err.Error())
	}

	// Wrap listener in a proxyproto listener
	proxyListener := &proxyproto.Listener{Listener: list}
	defer proxyListener.Close()

	// Wait for a connection and accept it
	conn, err := proxyListener.Accept()
	defer conn.Close()

	// Print connection details
	if conn.LocalAddr() == nil {
		log.Fatal("couldn't retrieve local address")
	}
	log.Printf("local address: %q", conn.LocalAddr().String())

	if conn.RemoteAddr() == nil {
		log.Fatal("couldn't retrieve remote address")
	}
	log.Printf("remote address: %q", conn.RemoteAddr().String())
}

Documentation

http://godoc.org/github.com/pires/go-proxyproto

主要指標

概覽
名稱與所有者pires/go-proxyproto
主編程語言Go
編程語言Go (語言數: 1)
平台
許可證Apache License 2.0
所有者活动
創建於2016-08-26 19:08:54
推送於2025-05-15 17:20:41
最后一次提交
發布數19
最新版本名稱v0.8.1 (發布於 2025-05-03 14:33:43)
第一版名稱0.1.0 (發布於 )
用户参与
星數537
關注者數11
派生數117
提交數193
已啟用問題?
問題數51
打開的問題數8
拉請求數60
打開的拉請求數3
關閉的拉請求數13
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?