Skip to content
This repository was archived by the owner on Aug 2, 2018. It is now read-only.

Commit 77cf96a

Browse files
committed
通过http添加证书
1 parent 546fbc0 commit 77cf96a

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

README.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
## 如何使用
99

10-
- `certs/goproxy.crt`传到手机, 点击安装证书
10+
- 手机浏览器访问 `abc.com`安装证书 (或者将 `certs/goproxy.crt`传到手机, 点击安装证书)
1111
- 运行方法一: 在[release](https://github.com/sundy-li/wechat_brain/releases)页面下载对应的操作系统执行文件, 压缩后, 将`questions.data`文件下载到同一个目录
1212
- 运行方法二: 安装go环境后, clone本repo源码到对应`$GOPATH/src/github.com/sundy-li/`下, 进入源码目录后,执行 `go run cmd/main.go`
1313
- 手机wifi设置代理为pc的ip和端口,启动小程序王者头脑
@@ -17,15 +17,11 @@
1717
- 合并后,提交一个merge request给我,我将合并题库
1818
```
1919
## files为待合并文件,此脚本将合并files文件到当前的questions.data文件中
20-
➜ wechat_brain git:(master) ✗ files=`ls /data/tmp/questions*`
21-
➜ wechat_brain git:(master) ✗ echo $files
22-
/data/tmp/questions.data
20+
➜ wechat_brain git:(master) ✗ files="/data/tmp/questions.data"
2321
➜ wechat_brain git:(master) ✗ go run cmd/question_utils.go -a merge -fs "$files"
2422
2018/01/11 20:01:23 merged file /data/tmp/questions.data
2523
2018/01/11 20:01:23 merged 4286 questions
2624
2018/01/11 20:01:23 total questions => 4286
27-
➜ wechat_brain git:(master) ✗
28-
2925
```
3026

3127
## 运行示例

spider.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ func (s *spider) Init() {
4949
bs, _ := ioutil.ReadAll(req.Body)
5050
req.Body = ioutil.NopCloser(bytes.NewReader(bs))
5151
handleChooseReq(bs)
52+
} else if ctx.Req.URL.Hostname() == `abc.com` {
53+
resp = new(http.Response)
54+
resp.StatusCode = 200
55+
resp.Header = make(http.Header)
56+
resp.Header.Add("Content-Disposition", "attachment; filename=ca.crt")
57+
resp.Header.Add("Content-Type", "application/octet-stream")
58+
resp.Body = ioutil.NopCloser(bytes.NewReader(goproxy.CA_CERT))
5259
}
5360
return
5461
}

0 commit comments

Comments
 (0)