Skip to content

Commit 09e33a4

Browse files
committed
add forward https proxy
1 parent 3bbdc82 commit 09e33a4

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
- 支持`HTTP3`(dev分支,用于尝鲜测试),测试可以跟cloudflare CDN通信
1717
- 支持智能代理模式
1818
- 支持自定义User-Agent(UA)
19-
- 支持前置代理功能(目前支持的协议有http,socks5)
19+
- 支持前置代理功能(目前支持的协议有http,https,socks5)
2020

2121
### 协议分析
2222
- 简单的来讲就是把客户端请求的数据(头+Body),打包POST到php server,格式如下:
@@ -109,14 +109,17 @@ php-proxy.key文件,则使用内部预留的CA(也就是我自己生成的CA),
109109
}
110110
```
111111
14. v2.1.3版本,支持前置代理,当proxy配置为空时,不使用前置代理;这种代理只在连接到php server时使用,在智能代理模式中,直接连接是不经过前置代理的
112-
目前只支持httpsocks5协议,配置格式参考如下:
112+
目前只支持http,https,socks5协议,配置格式参考如下:
113113
```
114114
//http
115115
http://127.0.0.1:80
116116
http://koala:123456@127.0.0.1:80
117117
//socks5
118118
socks5://user:password@127.0.0.1:1080
119119
socks5://127.0.0.1:1080
120+
//https
121+
https://127.0.0.1:80
122+
https://koala:123456@127.0.0.1:80
120123
```
121124
```
122125
{

client.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@ func (cli *client) init_client() {
123123
TLSClientConfig: cli.tlsconfig,
124124
}
125125
if cli.urlproxy != nil {
126+
if cli.urlproxy.Scheme == "https" {
127+
//for connect https proxy server
128+
cli.tr.DialTLS = cli.DialTLS
129+
}
126130
cli.tr.Proxy = http.ProxyURL(cli.urlproxy)
127131
} else {
128132
cli.tr.Proxy = http.ProxyFromEnvironment
@@ -132,6 +136,7 @@ func (cli *client) init_client() {
132136
Transport: cli.tr,
133137
}
134138
}
139+
135140
func (cli *client) VerifyConnection(cs tls.ConnectionState) error {
136141
//
137142
cert := cs.PeerCertificates[0]
@@ -143,6 +148,14 @@ func (cli *client) VerifyConnection(cs tls.ConnectionState) error {
143148
}
144149
}
145150

151+
func (cli *client) DialTLS(network, addr string) (net.Conn, error) {
152+
tlsconfig := &tls.Config{
153+
InsecureSkipVerify: cli.cfg.Insecure,
154+
}
155+
conn, err := tls.Dial(network, addr, tlsconfig)
156+
return conn, err
157+
}
158+
146159
//for HTTPS Forward PROXY dialer(need test)
147160
func (cli *client) Dial(network, addr string) (c net.Conn, err error) {
148161
tlsconfig := &tls.Config{

0 commit comments

Comments
 (0)