https://github.com/ganevdev/proxy-simple-test
Simple proxy testing.
https://github.com/ganevdev/proxy-simple-test
Last synced: 10 months ago
JSON representation
Simple proxy testing.
- Host: GitHub
- URL: https://github.com/ganevdev/proxy-simple-test
- Owner: ganevdev
- License: mit
- Created: 2019-02-14T20:17:24.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-04-08T09:31:41.000Z (almost 7 years ago)
- Last Synced: 2025-03-14T06:47:59.273Z (11 months ago)
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/proxy-simple-test
- Size: 32.2 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Proxy Simple Test
[](https://travis-ci.com/Ganevru/proxy-simple-test)
[](http://npm.im/proxy-simple-test)
Simple proxy testing.
All work is done by [node-tunnel](https://github.com/koichik/node-tunnel) and [got](https://github.com/sindresorhus/got) - this is a great library that can do a lot, use it if you need more.
In order to make an object from a proxy string, I use my library - [split-proxy](https://github.com/Ganevru/split-proxy)
`proxy-simple-test` - always returns `true` if test is passed or `false` if not.
The first argument is a proxy as a string or as an object (use what is convenient for you).
The second argument is the webpage to check.
The third argument is optional; it checks the body of the response to a specific text.
`inBody` - if body of the answer has this text then the test is passed.
`notInBody` - if body of the answer has this text then the test is NOT passed.
If third argument is a string, then it is automatically considered as `inBody`.
The test never passes if the response code is NOT `200`.
It is not necessary to use a proxy with `login` and `password`.
At the moment - only HTTP over HTTP tunneling.
## Install
```bash
npm i proxy-simple-test
```
## Examples
Proxy string:
```js
const proxySimpleTest = require('proxy-simple-test');
(async () => {
await proxySimpleTest(
'123.123.2.42:8080@superLogin:superPassword',
'www.example.com',
{ inBody: '
Example Domain
', notInBody: '404
' }
);
})();
// return true or false
```
The third argument can be a string, then it will automatically be used as `inBody`.
```js
const proxySimpleTest = require('proxy-simple-test');
(async () => {
await proxySimpleTest(
'123.123.2.42:8080@superLogin:superPassword',
'www.example.com',
'
Example Domain
'
);
})();
// return true or false
```
Proxy string, without defining text from the body, in this case returns `true` if response code is `200`:
```js
const proxySimpleTest = require('proxy-simple-test');
(async () => {
await proxySimpleTest(
'123.123.2.42:8080@superLogin:superPassword',
'www.example.com'
);
})();
// return true or false
```
Proxy object:
```js
const proxySimpleTest = require('proxy-simple-test');
(async () => {
await proxySimpleTest(
{
ipAddress: '123.123.2.42',
port: 8080,
login: 'superLogin',
password: 'superPassword'
},
'www.example.com',
{ inBody: '
Example Domain
', notInBody: '404
' }
);
})();
// return true or false
```
Proxy object, another format, instead of `login` and `password`, you can write a `loginPass`, and instead of the `ipAddress` and `port` - `ipAddressPort`:
```js
const proxySimpleTest = require('proxy-simple-test');
(async () => {
await proxySimpleTest(
{
ipAddressPort: '123.123.2.42:8080',
loginPass: 'superLogin:superPassword'
},
'www.example.com',
{ inBody: '
Example Domain
', notInBody: '404
' }
);
})();
// return true or false
```
Proxy object, another format:
```js
const proxySimpleTest = require('proxy-simple-test');
(async () => {
await proxySimpleTest(
{
ipAddress: '123.123.2.42',
port: 8080,
loginPass: 'superLogin:superPassword'
},
'www.example.com',
{ inBody: '
Example Domain
', notInBody: '404
' }
);
})();
// return true or false
```
Of course, you can use without a password and login:
```js
const proxySimpleTest = require('proxy-simple-test');
(async () => {
await proxySimpleTest(
{
ipAddress: '123.123.2.42',
port: 8080
},
'www.example.com',
{ inBody: '
Example Domain
', notInBody: '404
' }
);
})();
// return true or false
```