Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9a97fb9
commit 7289c3c
Showing
32 changed files
with
1,256 additions
and
498 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,8 @@ | ||
#!/usr/bin/env node | ||
|
||
const path = require('path') | ||
const { red } = require('chalk') | ||
const { log } = require('../lib/utils') | ||
const { HTTPParser } = require('http-parser-js') | ||
|
||
process.on('uncaughtException', error => { | ||
log(red('Uncaught exception'), '\n', error.stack) | ||
}) | ||
|
||
process.on('unhandledRejection', error => { | ||
log(red('Unhandled rejection'), '\n', error.stack) | ||
}) | ||
|
||
HTTPParser.encoding = 'utf-8' | ||
process.binding('http_parser').HTTPParser = HTTPParser | ||
|
||
const commander = require('commander') | ||
const pkg = require('../package.json') | ||
|
||
commander | ||
.version(pkg.version) | ||
.arguments('[entry]') | ||
.option('-p, --port <port>', 'proxy server port', 8123) | ||
.option('-u, --upstream <proxy>', 'upstream options', 'direct') | ||
.option('-e, --encoding [encoding]', 'http parser encoding', 'utf-8') | ||
.option('-k, --key <path>', 'ssl private key path', 'ssl/key.pem') | ||
.option('-c, --cert <path>', 'ssl certificate path', 'ssl/cert.pem') | ||
.action((entry, args) => { | ||
const { createServer } = require('..') | ||
|
||
HTTPParser.encoding = args.encoding | ||
|
||
const server = createServer({ | ||
cert: path.resolve(args.cert), | ||
key: path.resolve(args.key), | ||
entry: path.resolve(entry || 'lib'), | ||
upstream: args.upstream, | ||
}) | ||
|
||
server.listen(parseInt(args.port)) | ||
}) | ||
|
||
commander.parse(process.argv) | ||
require('../lib/cli') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"compilerOptions": { | ||
"baseUrl": ".", | ||
"paths": { | ||
"@/*": ["src/*"] | ||
} | ||
}, | ||
"include": [ | ||
"src/**/*" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.