domain setup

This commit is contained in:
adrapier03
2026-07-05 19:49:37 +07:00
parent 1274bd5a03
commit 620a3de21c
8 changed files with 313 additions and 42 deletions
+95 -10
View File
@@ -23,8 +23,9 @@ const config = JSON.parse(readFileSync(join(__dirname, 'config.json'), 'utf8'));
// ============================================================================
class TempmailClient {
constructor(apiUrl) {
constructor(apiUrl, domain) {
this.apiUrl = apiUrl;
this.domain = domain;
this.sessionId = null;
}
@@ -48,13 +49,19 @@ class TempmailClient {
async createInbox() {
await this.initSession();
const response = await fetch(`${this.apiUrl}/inboxes`, {
const headers = {
'Content-Type': 'application/json',
'x-session-id': this.sessionId
};
const options = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-session-id': this.sessionId
}
});
headers
};
if (this.domain) {
options.body = JSON.stringify({ domain: this.domain });
}
const response = await fetch(`${this.apiUrl}/inboxes`, options);
if (!response.ok) {
throw new Error(`Tempmail API error: ${response.status}`);
@@ -219,7 +226,7 @@ class CaptchaSolver {
class MimoRegistration {
constructor(config) {
this.config = config;
this.tempmail = new TempmailClient(config.tempmail.apiUrl);
this.tempmail = new TempmailClient(config.tempmail.apiUrl, config.tempmail.domain);
this.captcha = new CaptchaSolver(config.captcha.apiKey);
this.browser = null;
this.page = null;
@@ -249,9 +256,15 @@ class MimoRegistration {
console.log(` ↳ CPU/Mem : ${fp.hardwareConcurrency} cores / ${fp.deviceMemory} GB`);
console.log(` ↳ GPU : ${fp.webgl.renderer.substring(0, 70)}…`);
const proxyConfig = parseProxy(config.proxy);
if (proxyConfig) {
console.log(` ↳ Proxy : ${proxyConfig.server}`);
}
this.browser = await chromium.launch({
headless: config.browser.headless,
channel: 'chrome',
proxy: proxyConfig,
args: [
// Hindari flag --headless yg kelihatan, dan window-size konsisten dgn viewport
`--window-size=${fp.viewport.width},${fp.viewport.height}`,
@@ -2007,6 +2020,33 @@ async function main() {
} else if (config.registration && config.registration.count) {
count = parseInt(config.registration.count, 10) || 1;
}
const proxyArgIndex = process.argv.indexOf('--proxy');
let proxyList = [];
if (proxyArgIndex !== -1) {
const nextArg = process.argv[proxyArgIndex + 1];
// if nextArg is another flag or empty, assume default proxy.txt
let proxyPath = 'proxy.txt';
if (nextArg && !nextArg.startsWith('-')) {
proxyPath = nextArg;
}
// Check if the parameter is a file path that exists, or default proxy.txt exists
const { existsSync } = await import('fs');
const resolvedPath = join(__dirname, proxyPath);
if (existsSync(resolvedPath)) {
proxyList = loadProxyList(resolvedPath);
console.log(`Loaded ${proxyList.length} proxies from ${proxyPath}`);
} else if (nextArg && !nextArg.startsWith('-')) {
// Direct proxy string instead of file
proxyList = [nextArg];
} else {
// Default file doesn't exist either
console.log(`Proxy option enabled but ${proxyPath} not found.`);
}
} else if (config.proxy) {
proxyList = [config.proxy];
}
console.log(`Starting loop to create ${count} account(s)...`);
@@ -2018,7 +2058,12 @@ async function main() {
console.log(` [Loop ${i + 1}/${count}] Starting Auto-Registration`);
console.log('='.repeat(70));
const registration = new MimoRegistration(config);
const iterConfig = JSON.parse(JSON.stringify(config));
if (proxyList.length > 0) {
iterConfig.proxy = proxyList[i % proxyList.length];
}
const registration = new MimoRegistration(iterConfig);
try {
const result = await registration.run();
@@ -2082,4 +2127,44 @@ if (import.meta.url === `file:///${process.argv[1].replace(/\\/g, '/')}` ||
main();
}
export { MimoRegistration, TempmailClient, CaptchaSolver };
function loadProxyList(filePath) {
try {
const { readFileSync } = require('fs'); // or use fs import
} catch (e) {}
// Since we already import readFileSync from 'fs' at the top of this file, we can use it directly
try {
const content = readFileSync(filePath, 'utf8');
return content
.split(/\r?\n/)
.map(line => line.trim())
.filter(line => line && !line.startsWith('#'));
} catch (e) {
console.error(`Error loading proxy list: ${e.message}`);
return [];
}
}
function parseProxy(proxyStr) {
if (!proxyStr) return undefined;
let formatted = proxyStr.trim();
if (!/^https?:\/\//i.test(formatted) && !/^socks[45]:\/\//i.test(formatted)) {
formatted = 'http://' + formatted;
}
try {
const url = new URL(formatted);
const proxyObj = {
server: `${url.protocol}//${url.host}`,
};
if (url.username) {
proxyObj.username = decodeURIComponent(url.username);
}
if (url.password) {
proxyObj.password = decodeURIComponent(url.password);
}
return proxyObj;
} catch (e) {
return { server: proxyStr };
}
}
export { MimoRegistration, TempmailClient, CaptchaSolver, parseProxy, loadProxyList };