This repository has been archived by the owner on Nov 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 82
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
36 changed files
with
619 additions
and
184 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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const toxy = require('..') | ||
const poisons = toxy.poisons | ||
|
||
const proxy = toxy() | ||
|
||
proxy | ||
.balance(['http://httpbin.org', 'http://httpbin.org']) | ||
|
||
proxy | ||
.all('/*') | ||
.poison(poisons.latency(1000)) | ||
|
||
proxy.listen(3000) | ||
console.log('Server listening on port:', 3000) |
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,16 @@ | ||
const toxy = require('..') | ||
|
||
const proxy = toxy() | ||
const rules = proxy.rules | ||
const poisons = proxy.poisons | ||
|
||
proxy | ||
.forward('http://httpbin.org') | ||
.poison(poisons.bandwidth({ bps: 1024 })) | ||
.withRule(rules.method('GET')) | ||
.withRule(rules.probability(90)) | ||
|
||
proxy.all('/*') | ||
|
||
proxy.listen(3000) | ||
console.log('Server listening on port:', 3000) |
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,16 @@ | ||
const express = require('express') | ||
const toxy = require('..') | ||
|
||
const proxy = toxy() | ||
|
||
proxy.forward('http://httpbin.org') | ||
proxy.all('/*') | ||
|
||
proxy.poison(toxy.poisons.latency(1000)) | ||
proxy.poison(toxy.poisons.bandwidth({ bps: 1024 })) | ||
|
||
const app = express() | ||
app.use(proxy.middleware()) | ||
|
||
app.listen(3000) | ||
console.log('Server listening on port:', 3000) |
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,39 @@ | ||
const toxy = require('..') | ||
|
||
const proxy = toxy() | ||
const rules = proxy.rules | ||
const poisons = proxy.poisons | ||
|
||
proxy | ||
.forward('http://httpbin.org') | ||
.rule(rules.probability(50)) | ||
.poison(poisons.slowOpen({ delay: 500 })) | ||
|
||
var route = proxy.get('/*') | ||
|
||
route | ||
.poison(poisons.latency({ jitter: 1000 })) | ||
|
||
route | ||
.poison(poisons.inject({ code: 502, body: 'Error!', headers: { 'X-Toxy-Poison': 'error' } })) | ||
.withRule(rules.probability(25)) | ||
|
||
route | ||
.poison(poisons.slowClose({ delay: 1000 })) | ||
.withRule(rules.probability(20)) | ||
|
||
route | ||
.poison(poisons.rateLimit({ limit: 2, threshold: 5000 })) | ||
.withRule(rules.probability(20)) | ||
|
||
route | ||
.poison(poisons.slowRead({ bps: 100 })) | ||
.withRule(rules.probability(35)) | ||
|
||
route | ||
.poison(poisons.abort()) | ||
.poisonRule(rules.probability(5)) // does the same as withRule() | ||
.poisonRule(rules.method('GET')) | ||
|
||
proxy.listen(3000) | ||
console.log('Server listening on port:', 3000) |
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,20 @@ | ||
const toxy = require('..') | ||
|
||
const proxy = toxy() | ||
const rules = proxy.rules | ||
const poisons = proxy.poisons | ||
|
||
proxy | ||
.forward('http://httpbin.org') | ||
.poison(poisons.inject({ | ||
code: 503, | ||
body: '{"error": "toxy injected error"}', | ||
headers: {'Content-Type': 'application/json'} | ||
})) | ||
.withRule(rules.method('GET')) | ||
.withRule(rules.probability(50)) | ||
|
||
proxy.all('/*') | ||
|
||
proxy.listen(3000) | ||
console.log('Server listening on port:', 3000) |
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,16 @@ | ||
const toxy = require('..') | ||
|
||
const proxy = toxy() | ||
const rules = proxy.rules | ||
const poisons = proxy.poisons | ||
|
||
proxy | ||
.forward('http://httpbin.org') | ||
.poison(poisons.latency({ jitter: 1000 })) | ||
.withRule(rules.method('GET')) | ||
.withRule(rules.probability(50)) | ||
|
||
proxy.all('/*') | ||
|
||
proxy.listen(3000) | ||
console.log('Server listening on port:', 3000) |
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,19 @@ | ||
const toxy = require('..') | ||
const poisons = toxy.poisons | ||
|
||
const proxy = toxy() | ||
|
||
proxy | ||
.forward('http://httpbin.org') | ||
|
||
proxy.use(function (req, res, next) { | ||
// mad science here... | ||
next() | ||
}) | ||
|
||
proxy | ||
.all('/*') | ||
.poison(poisons.latency(1000)) | ||
|
||
proxy.listen(3000) | ||
console.log('Server listening on port:', 3000) |
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,16 @@ | ||
const toxy = require('..') | ||
|
||
const proxy = toxy() | ||
const rules = proxy.rules | ||
const poisons = proxy.poisons | ||
|
||
proxy | ||
.forward('http://httpbin.org') | ||
.poison(poisons.rateLimit({ limit: 2, threshold: 5000 })) | ||
.withRule(rules.method('GET')) | ||
.withRule(rules.probability(90)) | ||
|
||
proxy.all('/*') | ||
|
||
proxy.listen(3000) | ||
console.log('Server listening on port:', 3000) |
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,32 @@ | ||
const toxy = require('..') | ||
const poisons = toxy.poisons | ||
const rules = toxy.rules | ||
|
||
const proxy = toxy() | ||
|
||
proxy | ||
.forward('http://httpbin.org') | ||
.poison(poisons.latency(1000)) | ||
.rule(rules.method('GET')) | ||
|
||
proxy | ||
.get('/ip') | ||
.poison(poisons.rateLimit({ limit: 1, threshold: 5000 })) | ||
|
||
proxy | ||
.get('/get') | ||
.poison(poisons.abort()) | ||
|
||
proxy | ||
.get('/image/*') | ||
.poison(poisons.bandwidth({ bps: 1024 })) | ||
|
||
proxy | ||
.post('/post') | ||
.poison(poisons.slowRead({ bps: 1024 })) | ||
|
||
proxy | ||
.all('/*') | ||
|
||
proxy.listen(3000) | ||
console.log('Server listening on port:', 3000) |
Oops, something went wrong.