@@ -11,7 +11,7 @@ import (
1111 "time"
1212
1313 "github.com/golang/glog"
14- "github.com/jthomperoo/simple-proxy/proxy"
14+ my_proxy "github.com/jthomperoo/simple-proxy/proxy"
1515)
1616
1717var (
@@ -36,6 +36,8 @@ func main() {
3636 flag .StringVar (& bind , "bind" , "0.0.0.0" , "address to bind the proxy server to" )
3737 var port string
3838 flag .StringVar (& port , "port" , "8888" , "proxy port to listen on" )
39+ var socks5 string
40+ flag .StringVar (& socks5 , "socks5" , "" , "SOCKS5 proxy for tunneling" )
3941 var certPath string
4042 flag .StringVar (& certPath , "cert" , "" , "path to cert file" )
4143 var keyPath string
@@ -63,9 +65,11 @@ func main() {
6365 glog .Fatalf ("If using HTTPS protocol --cert and --key are required\n " )
6466 }
6567
68+ my_proxy .Socks5 = socks5
69+
6670 var handler http.Handler
6771 if basicAuth == "" {
68- handler = & proxy .ProxyHandler {
72+ handler = & my_proxy .ProxyHandler {
6973 Timeout : time .Duration (timeoutSecs ) * time .Second ,
7074 LogAuth : logAuth ,
7175 LogHeaders : logHeaders ,
@@ -75,7 +79,7 @@ func main() {
7579 if len (parts ) < 2 {
7680 glog .Fatalf ("Invalid basic auth provided, must be in format 'username:password', auth: %s\n " , basicAuth )
7781 }
78- handler = & proxy .ProxyHandler {
82+ handler = & my_proxy .ProxyHandler {
7983 Timeout : time .Duration (timeoutSecs ) * time .Second ,
8084 Username : & parts [0 ],
8185 Password : & parts [1 ],
@@ -93,6 +97,9 @@ func main() {
9397
9498 if protocol == httpProtocol {
9599 glog .V (0 ).Infoln ("Starting HTTP proxy..." )
100+ if socks5 != "" {
101+ glog .V (0 ).Infof ("Tunneling HTTP requests to SOCKS5 proxy: %s\n " , socks5 )
102+ }
96103 log .Fatal (server .ListenAndServe ())
97104 } else {
98105 glog .V (0 ).Infoln ("Starting HTTPS proxy..." )
0 commit comments