diff --git a/compy.go b/compy.go index 9e65c34..0d0b19b 100644 --- a/compy.go +++ b/compy.go @@ -32,7 +32,7 @@ var ( func main() { flag.Parse() - p := proxy.New(*host, cert) + p := proxy.New(*host, *cert) if (*ca == "") != (*caKey == "") { log.Fatalln("must specify both CA certificate and key") diff --git a/proxy/proxy.go b/proxy/proxy.go index dda49ab..30f44aa 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -24,14 +24,14 @@ type Proxy struct { user string pass string host string - cert *string + cert string } type Transcoder interface { Transcode(*ResponseWriter, *ResponseReader, http.Header) error } -func New(host string, cert *string) *Proxy { +func New(host string, cert string) *Proxy { p := &Proxy{ transcoders: make(map[string]Transcoder), ml: nil, @@ -48,12 +48,12 @@ func (p *Proxy) EnableMitm(ca, key string) error { } var config *tls.Config - if p.cert != nil { + if p.cert != "" { roots, err := x509.SystemCertPool() if err != nil { return err } - pem, err := ioutil.ReadFile(*p.cert) + pem, err := ioutil.ReadFile(p.cert) if err != nil { return err } @@ -168,12 +168,12 @@ func (p *Proxy) handleLocalRequest(w http.ResponseWriter, r *http.Request) error `, read, written, float64(written)/float64(read)*100)) return nil } else if r.Method == "GET" && r.URL.Path == "/cacert" { - if p.cert == nil { + if p.cert == "" { http.NotFound(w, r) return nil } w.Header().Set("Content-Type", "application/x-x509-ca-cert") - http.ServeFile(w, r, *p.cert) + http.ServeFile(w, r, p.cert) return nil } else { w.WriteHeader(http.StatusNotImplemented)