more
This commit is contained in:
parent
4f17a4b0d1
commit
eefe4c024f
8
main.go
8
main.go
|
@ -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) {
|
||||||
|
|
Loading…
Reference in New Issue