This repository has been archived by the owner on Oct 24, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
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
Showing
49 changed files
with
2,526 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/.idea | ||
/.boast.json | ||
/web/bindata_assetfs.go |
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,4 @@ | ||
build : | ||
# cd frontend; npm run build; cd - | ||
go-bindata-assetfs -pkg web assets/... ; mv bindata_assetfs.go web | ||
go build main.go |
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,72 @@ | ||
[中文](./README_zh.md) | ||
|
||
Boast | ||
========= | ||
|
||
"I want track all requests, and replay it easily." | ||
|
||
## Install | ||
|
||
Download the latest binary file from the [Releases](http://blog.phpor.me/boast) page. | ||
|
||
(darwin_amd64.tar.gz is for Mac OS X users) | ||
|
||
## Usage | ||
|
||
``` | ||
$ cat .boast.json | ||
{ | ||
"debug_addr": ":8079", | ||
"list": [ | ||
{ "url": "https://www.baidu.com/", "addr": ":8080" } | ||
{ "url": "https://github.com/", "addr": ":8081" } | ||
] | ||
} | ||
$ boast -c .boast.json | ||
$ boast --help | ||
Usage of boast: | ||
-c string | ||
config file path (default ".boast.json") | ||
``` | ||
|
||
``` | ||
HTTP Client Boast WebServer | ||
| GET http://localhost:8080/ | Record and Reverse Proxy | Response 200 OK | ||
| ---------------------------> | --------------------------> | ------┐ | ||
| | | | | ||
| | Record and Forward | <----┘ | ||
| <--------------------------- | <-------------------------- | | ||
┌----------------------------------------------------------------------------┐ | ||
| url: http://localhost:8081 | | ||
| ---------------------------------------------------------------------------| | ||
| All Transactions ┌ - - - - - - - - - - - - - - - - - - - - - - - ┐ | | ||
| ---------------------- | time: 10 hours ago Client: 127.0.0.1 | | | ||
| |GET / 200 OK 100 ms | | | | | ||
| ---------------------- | Request [ Replay ] | | | ||
| | - - - - - - - - - - - - | | | ||
| | GET http://localhost/ HTTP/1.1 | | | ||
| | User-Agent: curl/7.51.0 | | | ||
| | Accept: */* | | | ||
| | | | | ||
| | Response | | | ||
| | - - - - - - - - - - - - | | | ||
| | HTTP/1.1 200 OK | | | ||
| | X-Server: HTTPLab | | | ||
| | Date: Thu, 02 Mar 2017 02:25:27 GMT | | | ||
| | Content-Length: 13 | | | ||
| | Content-Type: text/plain; charset=utf-8 | | | ||
| | | | | ||
| | Hello, World | | | ||
| └ - - - - - - - - - - - - - - - - - - - - - - - ┘ | | ||
| | | ||
└----------------------------------------------------------------------------┘ | ||
``` | ||
|
||
## Warning | ||
|
||
DO NOT USE ON PRODUCTION! | ||
|
||
Boast is heavily inspired by [ngrok](https://github.com/inconshreveable/ngrok/). |
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,72 @@ | ||
[English](./README.md) | ||
|
||
Boast | ||
========= | ||
|
||
“我想跟踪所有访问我 Web 服务器的请求及返回数据。” | ||
|
||
## 安装 | ||
|
||
下载最新的[二进制](http://blog.phpor.me/boast)文件 | ||
|
||
## 使用 | ||
|
||
``` | ||
$ cat .boast.json | ||
{ | ||
"debug_addr": ":8079", | ||
"list": [ | ||
{ "url": "https://www.baidu.com/", "addr": ":8080" } | ||
{ "url": "https://github.com/", "addr": ":8081" } | ||
] | ||
} | ||
$ boast -c .boast.json | ||
$ boast --help | ||
Usage of boast: | ||
-c string | ||
config file path (default ".boast.json") | ||
``` | ||
|
||
## 整体架构 | ||
|
||
``` | ||
HTTP 客户端 Boast Web 服务器 | ||
| GET http://localhost:8080/ | 记录请求并进行反向代理 | Response 200 OK | ||
| ---------------------------> | --------------------------> | ------┐ | ||
| | | | | ||
| | 记录返回信息并转发给客户端 | <----┘ | ||
| <--------------------------- | <-------------------------- | | ||
┌----------------------------------------------------------------------------┐ | ||
| url: http://localhost:8081 | | ||
| ---------------------------------------------------------------------------| | ||
| All Transactions ┌ - - - - - - - - - - - - - - - - - - - - - - - ┐ | | ||
| ---------------------- | time: 10 hours ago Client: 127.0.0.1 | | | ||
| |GET / 200 OK 100 ms | | | | | ||
| ---------------------- | Request [ Replay ] | | | ||
| | - - - - - - - - - - - - | | | ||
| | GET http://localhost/ HTTP/1.1 | | | ||
| | User-Agent: curl/7.51.0 | | | ||
| | Accept: */* | | | ||
| | | | | ||
| | Response | | | ||
| | - - - - - - - - - - - - | | | ||
| | HTTP/1.1 200 OK | | | ||
| | X-Server: HTTPLab | | | ||
| | Date: Thu, 02 Mar 2017 02:25:27 GMT | | | ||
| | Content-Length: 13 | | | ||
| | Content-Type: text/plain; charset=utf-8 | | | ||
| | | | | ||
| | Hello, World | | | ||
| └ - - - - - - - - - - - - - - - - - - - - - - - ┘ | | ||
| | | ||
└----------------------------------------------------------------------------┘ | ||
``` | ||
|
||
## 警告 | ||
|
||
此产品严禁用于线上产品,只适用于开发、测试环境。 | ||
|
||
Boast 灵感源于 [ngrok](https://github.com/inconshreveable/ngrok/)。 |
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,2 @@ | ||
* | ||
!.gitignore |
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,42 @@ | ||
package config | ||
|
||
import ( | ||
"encoding/json" | ||
"flag" | ||
"io/ioutil" | ||
"log" | ||
"os" | ||
) | ||
|
||
type RvsPxy struct { | ||
URL string `json:"url"` | ||
Addr string `json:"addr"` | ||
} | ||
type JsonConfig struct { | ||
DebugAddr string `json:"debug_addr"` | ||
List []RvsPxy `json:"list"` | ||
} | ||
|
||
var Config JsonConfig | ||
|
||
func init() { | ||
// http://stackoverflow.com/questions/14249217/how-do-i-know-im-running-within-go-test | ||
if flag.Lookup("test.v") == nil { | ||
filePath := flag.String("c", ".boast.json", "config file path") | ||
flag.Parse() | ||
|
||
if _, err := os.Stat(*filePath); os.IsNotExist(err) { | ||
log.Fatal("config file: ", *filePath, " is not exist.") | ||
} | ||
|
||
if b, err := ioutil.ReadFile(*filePath); err != nil { | ||
log.Fatal("Read config error: ", err) | ||
} else { | ||
err := json.Unmarshal(b, &Config) | ||
if err != nil { | ||
log.Fatal("Parse json config error: ", err) | ||
} | ||
} | ||
|
||
} | ||
} |
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,13 @@ | ||
{ | ||
"presets": [ | ||
["es2015", { "modules": false }], | ||
"stage-2" | ||
], | ||
"plugins": ["transform-runtime"], | ||
"comments": false, | ||
"env": { | ||
"test": { | ||
"plugins": [ "istanbul" ] | ||
} | ||
} | ||
} |
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,9 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true |
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,3 @@ | ||
build/*.js | ||
config/*.js | ||
* |
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,27 @@ | ||
// http://eslint.org/docs/user-guide/configuring | ||
|
||
module.exports = { | ||
root: true, | ||
parser: 'babel-eslint', | ||
parserOptions: { | ||
sourceType: 'module' | ||
}, | ||
env: { | ||
browser: true, | ||
}, | ||
// https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style | ||
extends: 'standard', | ||
// required to lint *.vue files | ||
plugins: [ | ||
'html' | ||
], | ||
// add your custom rules here | ||
'rules': { | ||
// allow paren-less arrow functions | ||
'arrow-parens': 0, | ||
// allow async-await | ||
'generator-star-spacing': 0, | ||
// allow debugger during development | ||
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0 | ||
} | ||
} |
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,4 @@ | ||
.DS_Store | ||
node_modules/ | ||
dist/ | ||
npm-debug.log |
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,21 @@ | ||
# boast | ||
|
||
> A Vue.js project | ||
## Build Setup | ||
|
||
``` bash | ||
# install dependencies | ||
npm install | ||
|
||
# serve with hot reload at localhost:8080 | ||
npm run dev | ||
|
||
# build for production with minification | ||
npm run build | ||
|
||
# build for production and view the bundle analyzer report | ||
npm run build --report | ||
``` | ||
|
||
For detailed explanation on how things work, checkout the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader). |
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,40 @@ | ||
// https://github.com/shelljs/shelljs | ||
require('./check-versions')() | ||
|
||
process.env.NODE_ENV = 'production' | ||
|
||
var ora = require('ora') | ||
var path = require('path') | ||
var chalk = require('chalk') | ||
var shell = require('shelljs') | ||
var webpack = require('webpack') | ||
var config = require('../config') | ||
var webpackConfig = require('./webpack.prod.conf') | ||
|
||
var spinner = ora('building for production...') | ||
spinner.start() | ||
|
||
var assetsPath = path.join(config.build.assetsRoot, config.build.assetsSubDirectory) | ||
shell.rm('-rf', assetsPath) | ||
shell.mkdir('-p', assetsPath) | ||
shell.config.silent = true | ||
shell.cp('-R', 'static/*', assetsPath) | ||
shell.config.silent = false | ||
|
||
webpack(webpackConfig, function (err, stats) { | ||
spinner.stop() | ||
if (err) throw err | ||
process.stdout.write(stats.toString({ | ||
colors: true, | ||
modules: false, | ||
children: false, | ||
chunks: false, | ||
chunkModules: false | ||
}) + '\n\n') | ||
|
||
console.log(chalk.cyan(' Build complete.\n')) | ||
console.log(chalk.yellow( | ||
' Tip: built files are meant to be served over an HTTP server.\n' + | ||
' Opening index.html over file:// won\'t work.\n' | ||
)) | ||
}) |
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,45 @@ | ||
var chalk = require('chalk') | ||
var semver = require('semver') | ||
var packageConfig = require('../package.json') | ||
|
||
function exec (cmd) { | ||
return require('child_process').execSync(cmd).toString().trim() | ||
} | ||
|
||
var versionRequirements = [ | ||
{ | ||
name: 'node', | ||
currentVersion: semver.clean(process.version), | ||
versionRequirement: packageConfig.engines.node | ||
}, | ||
{ | ||
name: 'npm', | ||
currentVersion: exec('npm --version'), | ||
versionRequirement: packageConfig.engines.npm | ||
} | ||
] | ||
|
||
module.exports = function () { | ||
var warnings = [] | ||
for (var i = 0; i < versionRequirements.length; i++) { | ||
var mod = versionRequirements[i] | ||
if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) { | ||
warnings.push(mod.name + ': ' + | ||
chalk.red(mod.currentVersion) + ' should be ' + | ||
chalk.green(mod.versionRequirement) | ||
) | ||
} | ||
} | ||
|
||
if (warnings.length) { | ||
console.log('') | ||
console.log(chalk.yellow('To use this template, you must update following to modules:')) | ||
console.log() | ||
for (var i = 0; i < warnings.length; i++) { | ||
var warning = warnings[i] | ||
console.log(' ' + warning) | ||
} | ||
console.log() | ||
process.exit(1) | ||
} | ||
} |
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,9 @@ | ||
/* eslint-disable */ | ||
require('eventsource-polyfill') | ||
var hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true') | ||
|
||
hotClient.subscribe(function (event) { | ||
if (event.action === 'reload') { | ||
window.location.reload() | ||
} | ||
}) |
Oops, something went wrong.