mirror of
https://github.com/alibaba/anyproxy.git
synced 2025-04-23 15:31:26 +00:00
Merge branch 'guox191-download_cer'
This commit is contained in:
commit
1c3184b044
3
.gitignore
vendored
3
.gitignore
vendored
@ -34,4 +34,5 @@ test/report
|
|||||||
*.tgz
|
*.tgz
|
||||||
doc_compiled.md
|
doc_compiled.md
|
||||||
docs-md/cn/doc.md
|
docs-md/cn/doc.md
|
||||||
docs-md/en/doc.md
|
docs-md/en/doc.md
|
||||||
|
docs/gitbook/gitbook-plugin-livereload/
|
@ -827,6 +827,8 @@ module.exports = {
|
|||||||
* 设置 -> 安全性与位置信息 -> 加密与凭据 -> 从存储设备安装。找到你下载的证书文件,进行安装
|
* 设置 -> 安全性与位置信息 -> 加密与凭据 -> 从存储设备安装。找到你下载的证书文件,进行安装
|
||||||
* 设置 -> 安全 -> 从SD卡安装证书。找到你下载的证书文件,进行安装
|
* 设置 -> 安全 -> 从SD卡安装证书。找到你下载的证书文件,进行安装
|
||||||
|
|
||||||
|
不同安卓系统支持安装的证书文件类型不尽相同,大多支持安装拓展名为 .crt 的证书文件,少部分仅支持 .cer 文件(已知如 OPPO R15),AnyProxy 提供了多种类型的证书文件,可在下载安装时选择。
|
||||||
|
|
||||||
### 配置iOS/Android系统代理
|
### 配置iOS/Android系统代理
|
||||||
|
|
||||||
* 代理服务器都在wifi设置中配置
|
* 代理服务器都在wifi设置中配置
|
||||||
|
@ -628,6 +628,8 @@ module.exports = {
|
|||||||
* 设置 -> 安全性与位置信息 -> 加密与凭据 -> 从存储设备安装。找到你下载的证书文件,进行安装
|
* 设置 -> 安全性与位置信息 -> 加密与凭据 -> 从存储设备安装。找到你下载的证书文件,进行安装
|
||||||
* 设置 -> 安全 -> 从SD卡安装证书。找到你下载的证书文件,进行安装
|
* 设置 -> 安全 -> 从SD卡安装证书。找到你下载的证书文件,进行安装
|
||||||
|
|
||||||
|
不同安卓系统支持安装的证书文件类型不尽相同,大多支持安装拓展名为 .crt 的证书文件,少部分仅支持 .cer 文件(已知如 OPPO R15),AnyProxy 提供了多种类型的证书文件,可在下载安装时选择。
|
||||||
|
|
||||||
### 配置iOS/Android系统代理
|
### 配置iOS/Android系统代理
|
||||||
|
|
||||||
* 代理服务器都在wifi设置中配置
|
* 代理服务器都在wifi设置中配置
|
||||||
|
@ -809,6 +809,8 @@ install :
|
|||||||
|
|
||||||
* Besides installing root CA, you have to "turn on" the certificate for web manually in *settings - general - about - Certificate Trust Settings*. Otherwire, safari will not trust the root CA generated by AnyProxy.
|
* Besides installing root CA, you have to "turn on" the certificate for web manually in *settings - general - about - Certificate Trust Settings*. Otherwire, safari will not trust the root CA generated by AnyProxy.
|
||||||
|
|
||||||
|
<img src="https://zos.alipayobjects.com/rmsportal/hVWkXHrzHmOKOtCKGUWx.png" width="500" />
|
||||||
|
|
||||||
### trust root CA in Android
|
### trust root CA in Android
|
||||||
First of all, you need to download the root CA by clicking *Root CA* in web ui, and then scan the QR code.
|
First of all, you need to download the root CA by clicking *Root CA* in web ui, and then scan the QR code.
|
||||||
Installing CA in Android could be different based on the system, we list some common steps as below, but you can find the right way in you system with similar menu path.
|
Installing CA in Android could be different based on the system, we list some common steps as below, but you can find the right way in you system with similar menu path.
|
||||||
@ -818,7 +820,7 @@ Installing CA in Android could be different based on the system, we list some co
|
|||||||
* Settings -> Security & Location > Encryption & credentials -> Install from storage, and find your CA file to install
|
* Settings -> Security & Location > Encryption & credentials -> Install from storage, and find your CA file to install
|
||||||
* Settings -> Security -> Install from SD card, and find you CA file to install
|
* Settings -> Security -> Install from SD card, and find you CA file to install
|
||||||
|
|
||||||
<img src="https://zos.alipayobjects.com/rmsportal/hVWkXHrzHmOKOtCKGUWx.png" width="500" />
|
There are several file extensions of CA file which may not be compatible with all kinds of Android phones. `.crt` file is the most popular, while a few systems could only use .cer file such as OPPO R15. In AnyProxy, you can choose the type of certificate you need before installing.
|
||||||
|
|
||||||
### config iOS/Android proxy server
|
### config iOS/Android proxy server
|
||||||
|
|
||||||
|
@ -610,6 +610,8 @@ install :
|
|||||||
|
|
||||||
* Besides installing root CA, you have to "turn on" the certificate for web manually in *settings - general - about - Certificate Trust Settings*. Otherwire, safari will not trust the root CA generated by AnyProxy.
|
* Besides installing root CA, you have to "turn on" the certificate for web manually in *settings - general - about - Certificate Trust Settings*. Otherwire, safari will not trust the root CA generated by AnyProxy.
|
||||||
|
|
||||||
|
<img src="https://zos.alipayobjects.com/rmsportal/hVWkXHrzHmOKOtCKGUWx.png" width="500" />
|
||||||
|
|
||||||
### trust root CA in Android
|
### trust root CA in Android
|
||||||
First of all, you need to download the root CA by clicking *Root CA* in web ui, and then scan the QR code.
|
First of all, you need to download the root CA by clicking *Root CA* in web ui, and then scan the QR code.
|
||||||
Installing CA in Android could be different based on the system, we list some common steps as below, but you can find the right way in you system with similar menu path.
|
Installing CA in Android could be different based on the system, we list some common steps as below, but you can find the right way in you system with similar menu path.
|
||||||
@ -619,7 +621,7 @@ Installing CA in Android could be different based on the system, we list some co
|
|||||||
* Settings -> Security & Location > Encryption & credentials -> Install from storage, and find your CA file to install
|
* Settings -> Security & Location > Encryption & credentials -> Install from storage, and find your CA file to install
|
||||||
* Settings -> Security -> Install from SD card, and find you CA file to install
|
* Settings -> Security -> Install from SD card, and find you CA file to install
|
||||||
|
|
||||||
<img src="https://zos.alipayobjects.com/rmsportal/hVWkXHrzHmOKOtCKGUWx.png" width="500" />
|
There are several file extensions of CA file which may not be compatible with all kinds of Android phones. `.crt` file is the most popular, while a few systems could only use .cer file such as OPPO R15. In AnyProxy, you can choose the type of certificate you need before installing.
|
||||||
|
|
||||||
### config iOS/Android proxy server
|
### config iOS/Android proxy server
|
||||||
|
|
||||||
|
@ -1561,6 +1561,7 @@ newResponse.body += <span class="hljs-string">'--from anyproxy--'</spa
|
|||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
<p>不同安卓系统支持安装的证书文件类型不尽相同,大多支持安装拓展名为 .crt 的证书文件,少部分仅支持 .cer 文件(已知如 OPPO R15),AnyProxy 提供了多种类型的证书文件,可在下载安装时选择。</p>
|
||||||
<h3 id="配置iosandroid系统代理">配置iOS/Android系统代理</h3>
|
<h3 id="配置iosandroid系统代理">配置iOS/Android系统代理</h3>
|
||||||
<ul>
|
<ul>
|
||||||
<li><p>代理服务器都在wifi设置中配置</p>
|
<li><p>代理服务器都在wifi设置中配置</p>
|
||||||
@ -1658,7 +1659,7 @@ newResponse.body += <span class="hljs-string">'--from anyproxy--'</spa
|
|||||||
<script>
|
<script>
|
||||||
var gitbook = gitbook || [];
|
var gitbook = gitbook || [];
|
||||||
gitbook.push(function() {
|
gitbook.push(function() {
|
||||||
gitbook.page.hasChanged({"page":{"title":"简介","level":"1.1","depth":1,"next":{"title":"快速开始","level":"1.2","depth":1,"anchor":"#快速开始","path":"README.md","ref":"README.md#快速开始","articles":[{"title":"安装","level":"1.2.1","depth":2,"anchor":"#安装","path":"README.md","ref":"README.md#安装","articles":[]},{"title":"启动","level":"1.2.2","depth":2,"anchor":"#启动","path":"README.md","ref":"README.md#启动","articles":[]},{"title":"其他命令","level":"1.2.3","depth":2,"anchor":"#其他命令","path":"README.md","ref":"README.md#其他命令","articles":[]},{"title":"作为npm模块启动","level":"1.2.4","depth":2,"anchor":"#作为npm模块使用","path":"README.md","ref":"README.md#作为npm模块使用","articles":[]}]},"dir":"ltr"},"config":{"plugins":[],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"livereload":{},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"AnyProxy","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"AnyProxy","language":"cn","gitbook":"*","description":"A fully configurable http/https proxy in NodeJS"},"file":{"path":"README.md","mtime":"2019-03-24T13:17:35.024Z","type":"markdown"},"gitbook":{"version":"3.2.2","time":"2019-03-24T13:17:35.950Z"},"basePath":".","book":{"language":"cn"}});
|
gitbook.page.hasChanged({"page":{"title":"简介","level":"1.1","depth":1,"next":{"title":"快速开始","level":"1.2","depth":1,"anchor":"#快速开始","path":"README.md","ref":"README.md#快速开始","articles":[{"title":"安装","level":"1.2.1","depth":2,"anchor":"#安装","path":"README.md","ref":"README.md#安装","articles":[]},{"title":"启动","level":"1.2.2","depth":2,"anchor":"#启动","path":"README.md","ref":"README.md#启动","articles":[]},{"title":"其他命令","level":"1.2.3","depth":2,"anchor":"#其他命令","path":"README.md","ref":"README.md#其他命令","articles":[]},{"title":"作为npm模块启动","level":"1.2.4","depth":2,"anchor":"#作为npm模块使用","path":"README.md","ref":"README.md#作为npm模块使用","articles":[]}]},"dir":"ltr"},"config":{"plugins":[],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"livereload":{},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"AnyProxy","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"AnyProxy","language":"cn","gitbook":"*","description":"A fully configurable http/https proxy in NodeJS"},"file":{"path":"README.md","mtime":"2019-03-26T12:49:35.827Z","type":"markdown"},"gitbook":{"version":"3.2.2","time":"2019-03-26T12:49:36.852Z"},"basePath":".","book":{"language":"cn"}});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</div>
|
</div>
|
||||||
|
File diff suppressed because one or more lines are too long
@ -628,6 +628,8 @@ module.exports = {
|
|||||||
* 设置 -> 安全性与位置信息 -> 加密与凭据 -> 从存储设备安装。找到你下载的证书文件,进行安装
|
* 设置 -> 安全性与位置信息 -> 加密与凭据 -> 从存储设备安装。找到你下载的证书文件,进行安装
|
||||||
* 设置 -> 安全 -> 从SD卡安装证书。找到你下载的证书文件,进行安装
|
* 设置 -> 安全 -> 从SD卡安装证书。找到你下载的证书文件,进行安装
|
||||||
|
|
||||||
|
不同安卓系统支持安装的证书文件类型不尽相同,大多支持安装拓展名为 .crt 的证书文件,少部分仅支持 .cer 文件(已知如 OPPO R15),AnyProxy 提供了多种类型的证书文件,可在下载安装时选择。
|
||||||
|
|
||||||
### 配置iOS/Android系统代理
|
### 配置iOS/Android系统代理
|
||||||
|
|
||||||
* 代理服务器都在wifi设置中配置
|
* 代理服务器都在wifi设置中配置
|
||||||
|
@ -1532,6 +1532,7 @@ newResponse.body += <span class="hljs-string">'--from anyproxy--'</spa
|
|||||||
<ul>
|
<ul>
|
||||||
<li>Besides installing root CA, you have to "turn on" the certificate for web manually in <em>settings - general - about - Certificate Trust Settings</em>. Otherwire, safari will not trust the root CA generated by AnyProxy.</li>
|
<li>Besides installing root CA, you have to "turn on" the certificate for web manually in <em>settings - general - about - Certificate Trust Settings</em>. Otherwire, safari will not trust the root CA generated by AnyProxy.</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
<p><img src="https://zos.alipayobjects.com/rmsportal/hVWkXHrzHmOKOtCKGUWx.png" width="500"></p>
|
||||||
<h3 id="trust-root-ca-in-android">trust root CA in Android</h3>
|
<h3 id="trust-root-ca-in-android">trust root CA in Android</h3>
|
||||||
<p>First of all, you need to download the root CA by clicking <em>Root CA</em> in web ui, and then scan the QR code.
|
<p>First of all, you need to download the root CA by clicking <em>Root CA</em> in web ui, and then scan the QR code.
|
||||||
Installing CA in Android could be different based on the system, we list some common steps as below, but you can find the right way in you system with similar menu path.</p>
|
Installing CA in Android could be different based on the system, we list some common steps as below, but you can find the right way in you system with similar menu path.</p>
|
||||||
@ -1543,7 +1544,7 @@ Installing CA in Android could be different based on the system, we list some co
|
|||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p><img src="https://zos.alipayobjects.com/rmsportal/hVWkXHrzHmOKOtCKGUWx.png" width="500"></p>
|
<p>There are several file extensions of CA file which may not be compatible with all kinds of Android phones. <code>.crt</code> file is the most popular, while a few systems could only use .cer file such as OPPO R15. In AnyProxy, you can choose the type of certificate you need before installing.</p>
|
||||||
<h3 id="config-iosandroid-proxy-server">config iOS/Android proxy server</h3>
|
<h3 id="config-iosandroid-proxy-server">config iOS/Android proxy server</h3>
|
||||||
<ul>
|
<ul>
|
||||||
<li><p>proxy settings are placed in wifi setting</p>
|
<li><p>proxy settings are placed in wifi setting</p>
|
||||||
@ -1646,7 +1647,7 @@ You can change the request with rule of course. For this scenario, all you need
|
|||||||
<script>
|
<script>
|
||||||
var gitbook = gitbook || [];
|
var gitbook = gitbook || [];
|
||||||
gitbook.push(function() {
|
gitbook.push(function() {
|
||||||
gitbook.page.hasChanged({"page":{"title":"Introduction","level":"1.1","depth":1,"next":{"title":"Getting-Start","level":"1.2","depth":1,"anchor":"#getting-start","path":"README.md","ref":"README.md#getting-start","articles":[{"title":"Install","level":"1.2.1","depth":2,"anchor":"#install","path":"README.md","ref":"README.md#install","articles":[]},{"title":"Launch","level":"1.2.2","depth":2,"anchor":"#launch","path":"README.md","ref":"README.md#launch","articles":[]},{"title":"Options","level":"1.2.3","depth":2,"anchor":"#options","path":"README.md","ref":"README.md#options","articles":[]},{"title":"As Node Module","level":"1.2.4","depth":2,"anchor":"#use-anyproxy-as-an-npm-module","path":"README.md","ref":"README.md#use-anyproxy-as-an-npm-module","articles":[]}]},"dir":"ltr"},"config":{"plugins":[],"styles":{"website":"styles/website.css"},"pluginsConfig":{"livereload":{},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"AnyProxy","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"AnyProxy","language":"en","gitbook":"*","description":"A fully configurable http/https proxy in NodeJS"},"file":{"path":"README.md","mtime":"2019-03-24T13:17:35.025Z","type":"markdown"},"gitbook":{"version":"3.2.2","time":"2019-03-24T13:17:35.950Z"},"basePath":".","book":{"language":"en"}});
|
gitbook.page.hasChanged({"page":{"title":"Introduction","level":"1.1","depth":1,"next":{"title":"Getting-Start","level":"1.2","depth":1,"anchor":"#getting-start","path":"README.md","ref":"README.md#getting-start","articles":[{"title":"Install","level":"1.2.1","depth":2,"anchor":"#install","path":"README.md","ref":"README.md#install","articles":[]},{"title":"Launch","level":"1.2.2","depth":2,"anchor":"#launch","path":"README.md","ref":"README.md#launch","articles":[]},{"title":"Options","level":"1.2.3","depth":2,"anchor":"#options","path":"README.md","ref":"README.md#options","articles":[]},{"title":"As Node Module","level":"1.2.4","depth":2,"anchor":"#use-anyproxy-as-an-npm-module","path":"README.md","ref":"README.md#use-anyproxy-as-an-npm-module","articles":[]}]},"dir":"ltr"},"config":{"plugins":[],"styles":{"website":"styles/website.css"},"pluginsConfig":{"livereload":{},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"AnyProxy","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"AnyProxy","language":"en","gitbook":"*","description":"A fully configurable http/https proxy in NodeJS"},"file":{"path":"README.md","mtime":"2019-03-26T12:49:35.828Z","type":"markdown"},"gitbook":{"version":"3.2.2","time":"2019-03-26T12:49:36.852Z"},"basePath":".","book":{"language":"en"}});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</div>
|
</div>
|
||||||
|
File diff suppressed because one or more lines are too long
@ -610,6 +610,8 @@ install :
|
|||||||
|
|
||||||
* Besides installing root CA, you have to "turn on" the certificate for web manually in *settings - general - about - Certificate Trust Settings*. Otherwire, safari will not trust the root CA generated by AnyProxy.
|
* Besides installing root CA, you have to "turn on" the certificate for web manually in *settings - general - about - Certificate Trust Settings*. Otherwire, safari will not trust the root CA generated by AnyProxy.
|
||||||
|
|
||||||
|
<img src="https://zos.alipayobjects.com/rmsportal/hVWkXHrzHmOKOtCKGUWx.png" width="500" />
|
||||||
|
|
||||||
### trust root CA in Android
|
### trust root CA in Android
|
||||||
First of all, you need to download the root CA by clicking *Root CA* in web ui, and then scan the QR code.
|
First of all, you need to download the root CA by clicking *Root CA* in web ui, and then scan the QR code.
|
||||||
Installing CA in Android could be different based on the system, we list some common steps as below, but you can find the right way in you system with similar menu path.
|
Installing CA in Android could be different based on the system, we list some common steps as below, but you can find the right way in you system with similar menu path.
|
||||||
@ -619,7 +621,7 @@ Installing CA in Android could be different based on the system, we list some co
|
|||||||
* Settings -> Security & Location > Encryption & credentials -> Install from storage, and find your CA file to install
|
* Settings -> Security & Location > Encryption & credentials -> Install from storage, and find your CA file to install
|
||||||
* Settings -> Security -> Install from SD card, and find you CA file to install
|
* Settings -> Security -> Install from SD card, and find you CA file to install
|
||||||
|
|
||||||
<img src="https://zos.alipayobjects.com/rmsportal/hVWkXHrzHmOKOtCKGUWx.png" width="500" />
|
There are several file extensions of CA file which may not be compatible with all kinds of Android phones. `.crt` file is the most popular, while a few systems could only use .cer file such as OPPO R15. In AnyProxy, you can choose the type of certificate you need before installing.
|
||||||
|
|
||||||
### config iOS/Android proxy server
|
### config iOS/Android proxy server
|
||||||
|
|
||||||
|
File diff suppressed because one or more lines are too long
@ -1,7 +1,5 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const DEFAULT_WEB_PORT = 8002; // port for web interface
|
|
||||||
|
|
||||||
const express = require('express'),
|
const express = require('express'),
|
||||||
url = require('url'),
|
url = require('url'),
|
||||||
bodyParser = require('body-parser'),
|
bodyParser = require('body-parser'),
|
||||||
@ -14,11 +12,16 @@ const express = require('express'),
|
|||||||
wsServer = require('./wsServer'),
|
wsServer = require('./wsServer'),
|
||||||
juicer = require('juicer'),
|
juicer = require('juicer'),
|
||||||
ip = require('ip'),
|
ip = require('ip'),
|
||||||
compress = require('compression');
|
compress = require('compression'),
|
||||||
|
pug = require('pug');
|
||||||
|
|
||||||
|
const DEFAULT_WEB_PORT = 8002; // port for web interface
|
||||||
|
|
||||||
const packageJson = require('../package.json');
|
const packageJson = require('../package.json');
|
||||||
|
|
||||||
const MAX_CONTENT_SIZE = 1024 * 2000; // 2000kb
|
const MAX_CONTENT_SIZE = 1024 * 2000; // 2000kb
|
||||||
|
|
||||||
|
const certFileTypes = ['crt', 'cer', 'pem', 'der'];
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
@ -198,12 +201,18 @@ class webInterface extends events.EventEmitter {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.get('/downloadCrt', (req, res) => {
|
||||||
|
const pageFn = pug.compileFile(path.join(__dirname, '../resource/cert_download.pug'));
|
||||||
|
res.end(pageFn({ ua: req.get('user-agent') }));
|
||||||
|
});
|
||||||
|
|
||||||
app.get('/fetchCrtFile', (req, res) => {
|
app.get('/fetchCrtFile', (req, res) => {
|
||||||
res.setHeader('Access-Control-Allow-Origin', '*');
|
res.setHeader('Access-Control-Allow-Origin', '*');
|
||||||
const _crtFilePath = certMgr.getRootCAFilePath();
|
const _crtFilePath = certMgr.getRootCAFilePath();
|
||||||
if (_crtFilePath) {
|
if (_crtFilePath) {
|
||||||
|
const fileType = certFileTypes.indexOf(req.query.type) !== -1 ? req.query.type : 'crt';
|
||||||
res.setHeader('Content-Type', 'application/x-x509-ca-cert');
|
res.setHeader('Content-Type', 'application/x-x509-ca-cert');
|
||||||
res.setHeader('Content-Disposition', 'attachment; filename="rootCA.crt"');
|
res.setHeader('Content-Disposition', `attachment; filename="rootCA.${fileType}"`);
|
||||||
res.end(fs.readFileSync(_crtFilePath, { encoding: null }));
|
res.end(fs.readFileSync(_crtFilePath, { encoding: null }));
|
||||||
} else {
|
} else {
|
||||||
res.setHeader('Content-Type', 'text/html');
|
res.setHeader('Content-Type', 'text/html');
|
||||||
@ -211,25 +220,11 @@ class webInterface extends events.EventEmitter {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//make qr code
|
|
||||||
app.get('/qr', (req, res) => {
|
|
||||||
res.setHeader('Access-Control-Allow-Origin', '*');
|
|
||||||
res.setHeader('Content-Type', 'text/html');
|
|
||||||
|
|
||||||
const qr = qrCode.qrcode(4, 'M');
|
|
||||||
const targetUrl = req.protocol + '://' + req.get('host');
|
|
||||||
qr.addData(targetUrl);
|
|
||||||
qr.make();
|
|
||||||
const qrImageTag = qr.createImgTag(4);
|
|
||||||
const resDom = '<a href="__url"> __img <br> click or scan qr code to start client </a>'.replace(/__url/, targetUrl).replace(/__img/, qrImageTag);
|
|
||||||
res.end(resDom);
|
|
||||||
});
|
|
||||||
|
|
||||||
app.get('/api/getQrCode', (req, res) => {
|
app.get('/api/getQrCode', (req, res) => {
|
||||||
res.setHeader('Access-Control-Allow-Origin', '*');
|
res.setHeader('Access-Control-Allow-Origin', '*');
|
||||||
|
|
||||||
const qr = qrCode.qrcode(4, 'M');
|
const qr = qrCode.qrcode(4, 'M');
|
||||||
const targetUrl = req.protocol + '://' + req.get('host') + '/fetchCrtFile';
|
const targetUrl = req.protocol + '://' + req.get('host') + '/downloadCrt';
|
||||||
const isRootCAFileExists = certMgr.isRootCAFileExists();
|
const isRootCAFileExists = certMgr.isRootCAFileExists();
|
||||||
|
|
||||||
qr.addData(targetUrl);
|
qr.addData(targetUrl);
|
||||||
|
91
resource/cert_download.pug
Normal file
91
resource/cert_download.pug
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
doctype html
|
||||||
|
html(lang="en")
|
||||||
|
head
|
||||||
|
title Download rootCA
|
||||||
|
meta(name='viewport', content='initial-scale=1, maximum-scale=0.5, minimum-scale=1, user-scalable=no')
|
||||||
|
style.
|
||||||
|
body {
|
||||||
|
color: #666;
|
||||||
|
line-height: 1.5;
|
||||||
|
font-size: 16px;
|
||||||
|
font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Helvetica,PingFang SC,Hiragino Sans GB,Microsoft YaHei,SimSun,sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
body * {
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.logo {
|
||||||
|
font-size: 36px;
|
||||||
|
margin-bottom: 40px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.any {
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.proxy {
|
||||||
|
font-weight: 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
.title {
|
||||||
|
font-weight: bold;
|
||||||
|
margin: 20px 0 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button {
|
||||||
|
text-align: center;
|
||||||
|
padding: 4px 15px 5px 15px;
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 500;
|
||||||
|
border-radius: 4px;
|
||||||
|
height: 32px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
display: block;
|
||||||
|
text-decoration: none;
|
||||||
|
border-color: #108ee9;
|
||||||
|
color: rgba(0, 0, 0, .65);
|
||||||
|
background-color: #fff;
|
||||||
|
border-style: solid;
|
||||||
|
border-width: 1px;
|
||||||
|
border-style: solid;
|
||||||
|
border-color: #d9d9d9;
|
||||||
|
}
|
||||||
|
|
||||||
|
.primary {
|
||||||
|
color: #fff;
|
||||||
|
background-color: #108ee9;
|
||||||
|
border-color: #108ee9;
|
||||||
|
}
|
||||||
|
|
||||||
|
.more {
|
||||||
|
text-align: center;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content {
|
||||||
|
word-break: break-all;
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 1.2;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
body
|
||||||
|
.logo
|
||||||
|
span.any Any
|
||||||
|
span.proxy Proxy
|
||||||
|
.title Download:
|
||||||
|
.content Select a CA file to download, the .crt file is commonly used.
|
||||||
|
a(href="/fetchCrtFile?type=crt").button.primary rootCA.crt
|
||||||
|
a(href="/fetchCrtFile?type=cer").button rootCA.cer
|
||||||
|
.more More
|
||||||
|
.buttons(style='display: none')
|
||||||
|
a(href="/fetchCrtFile?type=pem").button rootCA.pem
|
||||||
|
a(href="/fetchCrtFile?type=der").button rootCA.der
|
||||||
|
.title User-Agent:
|
||||||
|
.content #{ua}
|
||||||
|
script(type='text/javascript').
|
||||||
|
window.document.querySelector('.more').addEventListener('click', function (e) {
|
||||||
|
e.target.style.display = 'none';
|
||||||
|
window.document.querySelector('.buttons').style.display = 'block';
|
||||||
|
});
|
30
test/spec_lib/webInterface.js
Normal file
30
test/spec_lib/webInterface.js
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
const WebInterface = require('../../lib/webInterface.js');
|
||||||
|
const Recorder = require('../../lib/recorder');
|
||||||
|
const { directGet } = require('../util/HttpUtil.js');
|
||||||
|
|
||||||
|
describe('WebInterface server', () => {
|
||||||
|
let webServer = null;
|
||||||
|
const webHost = 'http://127.0.0.1:8002'
|
||||||
|
|
||||||
|
beforeAll(() => {
|
||||||
|
const recorder = new Recorder();
|
||||||
|
webServer = new WebInterface({
|
||||||
|
webPort: 8002,
|
||||||
|
}, recorder);
|
||||||
|
});
|
||||||
|
|
||||||
|
afterAll(() => {
|
||||||
|
webServer.close();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should response qrcode string in /getQrCode', done => {
|
||||||
|
directGet(`${webHost}/api/getQrCode`)
|
||||||
|
.then(res => {
|
||||||
|
const body = JSON.parse(res.body);
|
||||||
|
expect(body.qrImgDom).toMatch('<img src="data:image/');
|
||||||
|
expect(body.url).toBe(`${webHost}/downloadCrt`);
|
||||||
|
done();
|
||||||
|
})
|
||||||
|
.catch(done);
|
||||||
|
});
|
||||||
|
});
|
@ -62,7 +62,7 @@ class DownloadRootCA extends React.Component {
|
|||||||
const content = (
|
const content = (
|
||||||
<div className={Style.qrCodeWrapper} >
|
<div className={Style.qrCodeWrapper} >
|
||||||
<div dangerouslySetInnerHTML={imgDomContent} />
|
<div dangerouslySetInnerHTML={imgDomContent} />
|
||||||
<span>Scan to download rootCA.crt to your Phone</span>
|
<span>Scan to download rootCA to your Phone</span>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user