Documentation ¶
Index ¶
- Constants
- Variables
- func GenerateCert(tmpl *x509.Certificate, rootCA *x509.Certificate, rootKey *MyRootKey) (*tls.Certificate, error)
- func GenerateCertBlock() (*pem.Block, *pem.Block, error)
- func GenerateTemplate(host string, expireDays int) (*x509.Certificate, error)
- func NewDefaultProxyServer(addr string, proxy IProxy) (*http.Server, error)
- func OutPutRuleExample(path string) error
- func OutputDefaultCertAndPrivKey(path string) error
- type DefaultCertManagement
- type DefaultHttpsProxy
- type ForwardRule
- type ForwardRuleConfig
- type ICertManagement
- type IProxy
- type IRule
- type MyRootCa
- type MyRootKey
- type Option
- type RuleConfig
Constants ¶
View Source
const ForwardRuleExample = `forwardRules:
- name: example
matchPath: example.com/app
targetPath: http://localhost/app
`
Variables ¶
View Source
var ( DefaultRootCaPem = []byte(` -----BEGIN CERTIFICATE----- MIICBTCCAaqgAwIBAgIBATAKBggqhkjOPQQDAjBaMQ4wDAYDVQQGEwVDaGluYTEO MAwGA1UECBMFSHViZWkxDjAMBgNVBAcTBVd1aGFuMRAwDgYDVQQKEwdGb3J3YXJk MRYwFAYDVQQDDA1odHRwc19mb3J3YXJkMB4XDTIxMDYyNDA4MDAwOVoXDTQyMDYy NDA4MDAwOVowWjEOMAwGA1UEBhMFQ2hpbmExDjAMBgNVBAgTBUh1YmVpMQ4wDAYD VQQHEwVXdWhhbjEQMA4GA1UEChMHRm9yd2FyZDEWMBQGA1UEAwwNaHR0cHNfZm9y d2FyZDBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABPFLTsXmrzLUSG4/B+Q2KXjt 2mfsoFO6j0b/QHzNTgZVpUUbmaWOAme4H/04IFJNBF2m7DDu3i/DYNUnTKq8Kkqj YTBfMA4GA1UdDwEB/wQEAwIBBjAdBgNVHSUEFjAUBggrBgEFBQcDAgYIKwYBBQUH AwEwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUYydnnTxNzOTfHCrYBXIbLNtu L9AwCgYIKoZIzj0EAwIDSQAwRgIhAKERFge+CagR612vwYqhve56ygcu7lQ70IVU QRLFAIZvAiEAvEyNzS8TQsH/uHFBL8rKc4Aa0gzWfR+AdjeupJKpXNo= -----END CERTIFICATE----- `) DefaultRootKeyPem = []byte(` -----BEGIN EC PRIVATE KEY----- MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQg7cPbPqTj7OtURNYe m74YVgMh4hqNeO6lXTeQIInKeAyhRANCAATxS07F5q8y1EhuPwfkNil47dpn7KBT uo9G/0B8zU4GVaVFG5mljgJnuB/9OCBSTQRdpuww7t4vw2DVJ0yqvCpK -----END EC PRIVATE KEY----- `) )
View Source
var TunnelEstablishedResponseLine = []byte("HTTP/1.1 200 Connection established\r\n\r\n")
Functions ¶
func GenerateCert ¶
func GenerateCert(tmpl *x509.Certificate, rootCA *x509.Certificate, rootKey *MyRootKey) (*tls.Certificate, error)
func GenerateTemplate ¶
func GenerateTemplate(host string, expireDays int) (*x509.Certificate, error)
generate certificate template
func NewDefaultProxyServer ¶
func OutPutRuleExample ¶
Types ¶
type DefaultCertManagement ¶
type DefaultCertManagement struct {
// contains filtered or unexported fields
}
func NewDefaultCertManagement ¶
func NewDefaultCertManagement(modifyOpts ...Option) (*DefaultCertManagement, error)
func NewDefaultCertManagementFromFile ¶
func NewDefaultCertManagementFromFile(ca, key string) (*DefaultCertManagement, error)
func (*DefaultCertManagement) AddCert ¶
func (c *DefaultCertManagement) AddCert(host string, cert *tls.Certificate) error
func (*DefaultCertManagement) GetCert ¶
func (c *DefaultCertManagement) GetCert(host string) (*tls.Certificate, error)
type DefaultHttpsProxy ¶
type DefaultHttpsProxy struct {
// contains filtered or unexported fields
}
func NewDefaultHttpsProxy ¶
func NewDefaultHttpsProxy(rules []IRule) (*DefaultHttpsProxy, error)
func (*DefaultHttpsProxy) ServeHTTP ¶
func (p *DefaultHttpsProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request)
type ForwardRule ¶
type ForwardRule struct {
// contains filtered or unexported fields
}
func NewForwardRule ¶
func NewForwardRule(certManagement ICertManagement, rules ...ForwardRuleConfig) (*ForwardRule, error)
func NewForwardRuleFromConf ¶
func NewForwardRuleFromConf(certManagement ICertManagement, fileName string) (*ForwardRule, error)
func (*ForwardRule) Handle ¶
func (r *ForwardRule) Handle(rw http.ResponseWriter, req *http.Request) error
type ForwardRuleConfig ¶
type ICertManagement ¶
type ICertManagement interface { GetCert(string) (*tls.Certificate, error) AddCert(string, *tls.Certificate) error }
type MyRootCa ¶
type MyRootCa struct { Ca *x509.Certificate Bytes *[]byte }
type RuleConfig ¶
type RuleConfig struct {
ForwardRules []ForwardRuleConfig `yaml:"forwardRules"`
}
Click to show internal directories.
Click to hide internal directories.