Skip to content

Commit

Permalink
dev
Browse files Browse the repository at this point in the history
  • Loading branch information
gzzhanghao committed Dec 26, 2019
1 parent 76cb5b4 commit a1997b2
Show file tree
Hide file tree
Showing 4 changed files with 2,633 additions and 22 deletions.
4 changes: 2 additions & 2 deletions .babelrc → babel.config.js
@@ -1,6 +1,6 @@
{
module.exports = {
presets: [
['@babel/preset-env', { targets: { node: '8' } }],
['@babel/preset-env', { targets: { node: '10' } }],
],
plugins: [
'@babel/plugin-proposal-class-properties',
Expand Down
19 changes: 9 additions & 10 deletions package.json
Expand Up @@ -17,28 +17,27 @@
},
"author": "Jason <jason.daurus@gmail.com>",
"license": "MIT",
"devDependencies": {
"@babel/cli": "^7.1.5",
"@babel/core": "^7.1.5",
"@babel/plugin-proposal-class-properties": "^7.1.0",
"@babel/plugin-proposal-export-default-from": "^7.0.0",
"@babel/preset-env": "^7.1.5",
"babel-eslint": "^10.0.1",
"eslint": "^5.9.0"
},
"dependencies": {
"chalk": "^2.4.1",
"chokidar": "^2.0.4",
"commander": "^2.19.0",
"es6-promisify": "^6.0.1",
"event-to-promise": "^0.8.0",
"http-parser-js": "^0.5.0",
"mkdirp": "^0.5.1",
"node-fetch": "^2.2.1",
"node-forge": "^0.7.6",
"pac-resolver": "^3.0.0",
"socks": "^2.2.2"
},
"devDependencies": {
"@babel/cli": "^7.1.5",
"@babel/core": "^7.1.5",
"@babel/plugin-proposal-class-properties": "^7.1.0",
"@babel/plugin-proposal-export-default-from": "^7.0.0",
"@babel/preset-env": "^7.1.5",
"babel-eslint": "^10.0.1",
"eslint": "^5.9.0"
},
"repository": {
"type": "git",
"url": "git+https://github.com/gzzhanghao/mocker.git"
Expand Down
15 changes: 5 additions & 10 deletions src/MockerServer.js
Expand Up @@ -4,7 +4,6 @@ import url from 'url'
import path from 'path'
import http from 'http'
import https from 'https'
import mkdirp from 'mkdirp'
import { Readable } from 'stream'
import tls, { TLSSocket } from 'tls'
import waitFor from 'event-to-promise'
Expand Down Expand Up @@ -232,19 +231,15 @@ function getRootCAKey(options) {
// noop
}
const ca = generateRootCAKey()
tryCall(() => mkdirp.sync(path.dirname(paths.cert)))
tryCall(() => mkdirp.sync(path.dirname(paths.key)))
tryCall(() => fs.writeFileSync(paths.cert, ca.cert, { mode: 0o600 }))
tryCall(() => fs.writeFileSync(paths.key, ca.key, { mode: 0o600 }))
return ca
}

function tryCall(cb) {
try {
cb()
fs.mkdirSync(path.dirname(paths.cert), { mode: 0o600, recursive: true })
fs.mkdirSync(path.dirname(paths.key), { mode: 0o600, recursive: true })
fs.writeFileSync(paths.cert, ca.cert, { mode: 0o600 })
fs.writeFileSync(paths.key, ca.key, { mode: 0o600 })
} catch (error) {
// noop
}
return ca
}

function getURL(req) {
Expand Down

0 comments on commit a1997b2

Please sign in to comment.