Skip to content

tlsproxy/pgproxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

package main

import (
	"crypto/tls"
	"fmt"
	"github.com/tlsproxy/pgproxy"
)

func main() {
	proxyConfig := &pgproxy.ProxyConfig{
		Src: "0.0.0.0:7777",
		Dst: "192.168.1.11:5432",
		HandleError: func(err error) {
			fmt.Printf("%+v", err)
		},
		HandleRead: func(b []byte, state tls.ConnectionState) error {
			return nil
		},
		HandleWrite: nil,
		HandleClientState: func(w tls.ConnectionState) error {
			return nil
		},
	}

	tlsConfig := &pgproxy.TlsConfig{
		ServerCert: "/ca/server.crt",
		ServerKey:  "/ca/server.key",
		CaCert:     "/ca/ca.crt",
	}

	proxy, err := pgproxy.NewProxy(proxyConfig, tlsConfig)
	if err != nil {
		panic(err)
	}

	err = proxy.Listen()
	if err != nil {
		panic(err)
	}
}

About

Offer TLS encryption terminates for PostgreSQL

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages