This commit is contained in:
Jeff Becker 2019-01-19 08:34:32 -05:00
parent 4f17a4b0d1
commit eefe4c024f
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05
1 changed files with 4 additions and 4 deletions

View File

@ -3,8 +3,8 @@ package main
import ( import (
"crypto/tls" "crypto/tls"
"fmt" "fmt"
"golang.org/x/net/context"
"golang.org/x/net/proxy" "golang.org/x/net/proxy"
"io"
"net" "net"
"net/http" "net/http"
"os" "os"
@ -33,7 +33,7 @@ func (h *httpProxyHandler) dialOut(addr string) (net.Conn, error) {
return net.Dial("tcp", addr) return net.Dial("tcp", addr)
} }
func (h *httpProxyHandler) ServeHTTP(w http.ResposneWriter, r *http.Request) { func (h *httpProxyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if r.Method == http.MethodConnect { if r.Method == http.MethodConnect {
outConn, err := h.dialOut(r.Host) outConn, err := h.dialOut(r.Host)
if err != nil { if err != nil {
@ -71,12 +71,12 @@ func main() {
if usehttp { if usehttp {
serv := &http.Server{ serv := &http.Server{
Addr: args[1], Addr: args[1],
Handler: &proxyHandler{ Handler: &httpProxyHandler{
upstream: upstream, upstream: upstream,
}, },
TLSNextProto: make(map[string]func(*http.Server, *tls.Conn, http.Handler)), TLSNextProto: make(map[string]func(*http.Server, *tls.Conn, http.Handler)),
} }
http.ListenAndServe(proxyHandler, args[1]) serv.ListenAndServe()
} else { } else {
serv, err := socks5.New(&socks5.Config{ serv, err := socks5.New(&socks5.Config{
Dial: func(addr string) (net.Conn, error) { Dial: func(addr string) (net.Conn, error) {