Skip to content

Commit

Permalink
addressed format and removed commented codes
Browse files Browse the repository at this point in the history
  • Loading branch information
AJun01 committed Aug 19, 2024
1 parent d882d80 commit 234b4b9
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 41 deletions.
5 changes: 0 additions & 5 deletions lib/anonymizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ const cheerio = require('cheerio');
const { PassThrough } = require('stream');


// load anonymizerConfig
//const configPath = path.join(__dirname, 'anonymizerConfig.json');
//const anonymizationConfig = JSON.parse(fs.readFileSync(configPath, 'utf8'));

const emailRegex = /([a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6})/g;
const fullNameRegex = /\b([A-Z][a-z]+ [A-Z][a-z]+)\b/g;
const singleNameRegex = /\b([A-Z][a-z]+)\b/g;
Expand All @@ -20,7 +16,6 @@ const passwordRegex = /(?<=name="password"[\s\S]*?\r\n\r\n)([A-Za-z0-9]+[A-Za-z0
//default
let anonymizationEnabled = false;
let manualMode = false;
//let customAnonymizationRules = anonymizationConfig.customAnonymizationRules;

//functions
function anonymizeEmail(text) {
Expand Down
69 changes: 33 additions & 36 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ var timers=[];
var minDelay;//ms
var maxDelay;//ms
var isRandomDelay=false;

/**
* END of Properties section
* *************************
Expand Down Expand Up @@ -387,28 +386,28 @@ function createPipelinedRequest(cb){
* @param options Options for the request function
* @param cb Callback to handle response
* */
function request(options, cb) {
var _options = {};
if (isThrottled()) {
var host = options.host;
var port = options.port;
var path = options.path;
var method = options.method;
var proxyPort = process.pid % 60000;
_options.host = localProxyHost;
_options.port = proxyPort;
_options.method = method;
if (options.headers != null) {
_options.headers = options.headers;
} else {
_options.headers = {};
function request(options,cb){
var _options={};
if(isThrottled()){
var host=options.host;
var port=options.port;
var path=options.path;
var method=options.method;
var proxyPort=process.pid%60000;
_options.host=localProxyHost;
_options.port=proxyPort;
_options.method=method;
if(options.headers !=null){
_options.headers=options.headers;
}else{
_options.headers={};
}
_options.headers['host'] = host;
_options.headers['port'] = port;
_options.headers['path'] = path;
_options.headers['method'] = method;
} else {
_options = options;
_options.headers['host']=host;
_options.headers['port']=port;
_options.headers['path']=path;
_options.headers['method']=method;
}else{
_options=options;
}
if (anonymizer.isAnonymizationEnabled) {
_options = anonymizer.anonymizeRequest(_options);
Expand All @@ -417,33 +416,31 @@ function request(options, cb) {
if (options.port === "443" && !isThrottled()) {
_options['agent'] = gh.keepAliveAgentHttps;
protocol = https;
} else {
}
else {
_options['agent'] = gh.keepAliveAgentHttp;
protocol = http;
}

var req = protocol.request(_options, function (response) {
response.on('end', function () {
incrCounter(response.statusCode);
});

if (cb) {
if (cb) {
if(anonymizer.isAnonymizationEnabled) {
cb(anonymizer.anonymizeResponse(response));
}else {
cb(response)
}
}
}
if(anonymizer.isAnonymizationEnabled) {
cb(anonymizer.anonymizeResponse(response));
}else {
cb(response)
}
}
response.resume()
});

if(options.body){
req.write(options.body)
}
req.end();
return req;

}


var multiReqPointer;
/**
Expand Down

0 comments on commit 234b4b9

Please sign in to comment.