Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# luminator

[![Dependencies][dependencies-badge]][dependencies]
[![Build][build-badge]][build]
[![License][license-badge]][license]
[![PRs Welcome][prs-badge]][prs]
Expand Down Expand Up @@ -331,7 +330,7 @@ const proxyrack: Proxyrack = new Proxyrack({
username: "tictactrip",
password: "secret",
host: 'megaproxy.rotating.proxyrack.net',
port: 222,
ports: [222],
},
strategy: EStrategyMode.CHANGE_IP_EVERY_REQUESTS,
});
Expand Down Expand Up @@ -409,8 +408,6 @@ Run using yarn run `<script>` command.

GPL-3.0 © [Tictactrip](https://www.tictactrip.eu)

[dependencies-badge]: https://img.shields.io/david/tictactrip/luminator
[dependencies]: https://img.shields.io/david/tictactrip/luminator
[build-badge]: https://github.com/tictactrip/luminator/workflows/Test/badge.svg
[build]: https://github.com/tictactrip/luminator/actions?query=workflow%3ATest+branch%3Amaster
[license-badge]: https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square
Expand Down
2 changes: 1 addition & 1 deletion __tests__/unit/proxyrack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('Proxyrack', () => {
proxy: {
...proxy,
host: 'megaproxy.rotating.proxyrack.net',
port: 222,
ports: [222],
},
strategy: EStrategyMode.CHANGE_IP_EVERY_REQUESTS,
});
Expand Down
9 changes: 2 additions & 7 deletions src/classes/providers/proxyrack/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,8 @@ export class Proxyrack extends Base {
password: this.config.proxy.password,
});

let port: number;
if (this.config.strategy === EStrategyMode.CHANGE_IP_EVERY_REQUESTS) {
port = this.config.proxy.port;
} else {
const randomArrayIndex: number = Math.floor(Math.random() * (this.config.proxy.ports.length - 1));
port = this.config.proxy.ports[randomArrayIndex];
}
const randomArrayIndex: number = Math.floor(Math.random() * (this.config.proxy.ports.length - 1));
const port = this.config.proxy.ports[randomArrayIndex];

const proxy = {
host: this.config.proxy.host,
Expand Down
30 changes: 5 additions & 25 deletions src/classes/providers/proxyrack/types.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
import { AxiosRequestConfig } from 'axios';
import { EStrategyMode } from '../base/types';

type TProxyrackProviderConfigStrategyChangeIpEveryRequest = {
username: string;
password: string;
host: string;
port: number;
};

type TProxyrackProviderConfigStrategyManual = {
type TProxyrackProviderConfig = {
username: string;
password: string;
host: string;
Expand All @@ -19,22 +12,9 @@ interface IProxyrackCommonConfig {
axiosConfig?: AxiosRequestConfig;
}

interface IProxyrackConfigStategyChangeIpEveryRequest extends IProxyrackCommonConfig {
proxy: TProxyrackProviderConfigStrategyChangeIpEveryRequest;
strategy: EStrategyMode.CHANGE_IP_EVERY_REQUESTS;
interface TProxyrackConfig extends IProxyrackCommonConfig {
proxy: TProxyrackProviderConfig;
strategy: EStrategyMode.MANUAL | EStrategyMode.CHANGE_IP_EVERY_REQUESTS;
}

interface IProxyrackConfigStategyManual extends IProxyrackCommonConfig {
proxy: TProxyrackProviderConfigStrategyManual;
strategy: EStrategyMode.MANUAL;
}

type TProxyrackConfig = IProxyrackConfigStategyChangeIpEveryRequest | IProxyrackConfigStategyManual;

export {
TProxyrackConfig,
IProxyrackConfigStategyChangeIpEveryRequest,
IProxyrackConfigStategyManual,
TProxyrackProviderConfigStrategyManual,
TProxyrackProviderConfigStrategyChangeIpEveryRequest,
};
export { TProxyrackConfig, TProxyrackProviderConfig };