Skip to content
This repository was archived by the owner on Dec 5, 2025. It is now read-only.

Commit c78a8fc

Browse files
committed
Update v2.3
Added EasyMC Support Added Proxy Scraper Added Proxy Checker Added Support for 1.20.1 Fixed Some Minor Bugs
1 parent 218be60 commit c78a8fc

File tree

9 files changed

+462
-129
lines changed

9 files changed

+462
-129
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ TrafficerMC has a variety of features. Some of them are:
2525
- [Theme](#theme)
2626
- Linear Delay
2727
- Auto Reconnect
28+
- EasyMC Support
2829
- and way more!
2930

3031
#### Minecraft Version 1.8.x - 1.20

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.2
1+
2.3

assets/js/botMain.js

Lines changed: 128 additions & 106 deletions
Large diffs are not rendered by default.

assets/js/cf.js

Lines changed: 126 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const ProxyAgent = require('proxy-agent')
55
const botApi = new EventEmitter()
66
const fetch = require('node-fetch')
77
const fs = require('fs')
8-
const currentVersion = "2.2"
8+
const currentVersion = "2.3"
99
let stopBot = false
1010

1111
//bot connect method
@@ -105,6 +105,7 @@ function getBotInfo(botName, n) {
105105
username: unm ? unm : salt(10),
106106
version: idBotVersion.value,
107107
auth: idAuthType.value,
108+
easyMcToken: idAltToken.value,
108109
onMsaCode: function(data) {
109110
const code = data.user_code
110111
sendLog(`<li> <img src="./assets/icons/app/code.svg" class="icon-sm" style="filter: brightness(0) saturate(100%) invert(28%) sepia(100%) saturate(359%) hue-rotate(172deg) brightness(93%) contrast(89%)">[${botName}] First time signing in. Please authenticate now: To sign in, use a web browser to open the page <b style="cursor: pointer; color: blue;" onClick="shell.openExternal('https://www.microsoft.com/link')">https://www.microsoft.com/link</b> and enter the code: ${code} <img src="./assets/icons/app/clipboard.svg" onclick="navigator.clipboard.writeText('${code}')" style="cursor: pointer; filter: brightness(0) invert(1);" height="16px;"> to authenticate. </li>`)
@@ -118,6 +119,7 @@ function getBotInfo(botName, n) {
118119
username: unm ? unm : salt(10),
119120
version: idBotVersion.value,
120121
auth: idAuthType.value,
122+
easyMcToken: idAltToken.value,
121123
onMsaCode: function(data) {
122124
const code = data.user_code
123125
sendLog(`<li> <img src="./assets/icons/app/code.svg" class="icon-sm" style="filter: brightness(0) saturate(100%) invert(28%) sepia(100%) saturate(359%) hue-rotate(172deg) brightness(93%) contrast(89%)">[${botName}] First time signing in. Please authenticate now: To sign in, use a web browser to open the page <b style="cursor: pointer; color: blue;" onClick="shell.openExternal('https://www.microsoft.com/link')">https://www.microsoft.com/link</b> and enter the code: ${code} <img src="./assets/icons/app/clipboard.svg" onclick="navigator.clipboard.writeText('${code}')" style="cursor: pointer; filter: brightness(0) invert(1);" height="16px;"> to authenticate. </li>`)
@@ -129,7 +131,7 @@ function getBotInfo(botName, n) {
129131

130132
//get proxy from file with line number
131133
function getProxy(n) {
132-
const file = fs.readFileSync(idProxyFilePath.files[0].path)
134+
const file = idProxylist.value
133135
const lines = file.toString().split(/\r?\n/)
134136
const rnd = Math.floor(Math.random() * lines.length)
135137

@@ -187,14 +189,22 @@ function errBot(name) {
187189
updateBotCount()
188190
}
189191

190-
//console logs
192+
// logs info to chat
191193
function sendLog(log) {
192194
if(!log) return;
193195
const b = document.createElement("li")
194196
b.innerHTML = log
195197
idChatBox.appendChild(b)
196198
idChatBox.scrollTop = idChatBox.scrollHeight
197199
}
200+
// logs info to proxy logs
201+
function proxyLog(log) {
202+
if(!log) return;
203+
const b = document.createElement("li")
204+
b.innerHTML = log
205+
idProxyLogs.appendChild(b)
206+
idProxyLogs.scrollTop = idProxyLogs.scrollHeight
207+
}
198208

199209
//execute command all bots
200210
async function exeAll(command, ...args) {
@@ -324,6 +334,115 @@ function selectedList() {
324334
return list;
325335
}
326336

337+
function checkAuth() {
338+
const selectElement = document.getElementById('botAuthType');
339+
const selectedValue = selectElement.value;
340+
const easymcDiv = document.getElementById('easymcDiv');
341+
const usernameDiv = document.getElementById('usernameDiv');
342+
343+
if (selectedValue === "easymc") {
344+
easymcDiv.style.display = 'block';
345+
usernameDiv.style.display = 'none';
346+
document.getElementById('botUsename').value = '';
347+
} else {
348+
easymcDiv.style.display = 'none';
349+
usernameDiv.style.display = 'block';
350+
}
351+
}
352+
async function easyMcAuth (client, options) {
353+
const fetchOptions = {
354+
method: 'POST',
355+
headers: { 'Content-Type': 'application/json' },
356+
body: `{"token":"${options.easyMcToken}"}`
357+
}
358+
try {
359+
const res = await fetch('https://api.easymc.io/v1/token/redeem', fetchOptions)
360+
const resJson = await res.json()
361+
if (resJson.error) throw new Error(`EasyMC: ${resJson.error}`)
362+
if (!resJson) throw new Error('Empty response from EasyMC.')
363+
if (resJson.session?.length !== 43 || resJson.mcName?.length < 3 || resJson.uuid?.length !== 36) throw new Error('Invalid response from EasyMC.')
364+
const session = {
365+
accessToken: resJson.session,
366+
selectedProfile: {
367+
name: resJson.mcName,
368+
id: resJson.uuid
369+
}
370+
}
371+
options.haveCredentials = true
372+
client.session = session
373+
options.username = client.username = session.selectedProfile.name
374+
options.accessToken = session.accessToken
375+
client.emit('session', session)
376+
} catch (error) {
377+
client.emit('error', error)
378+
return
379+
}
380+
options.connect(client)
381+
}
382+
383+
function createBot(options) {
384+
if (options.auth === 'easymc') {
385+
if (options.easyMcToken?.length !== 20) {
386+
throw new Error('EasyMC authentication requires an alt token. See https://easymc.io/get .')
387+
}
388+
options.auth = easyMcAuth
389+
options.sessionServer ||= 'https://sessionserver.easymc.io'
390+
options.username = Buffer.alloc(0)
391+
}
392+
393+
return mineflayer.createBot(options)
394+
}
395+
396+
async function scrapeProxy() {
397+
try {
398+
const items = await fetchList(`https://raw.githubusercontent.com/RattlesHyper/proxy/main/socks${idScrapeProtocol.value}`);
399+
for (var i = 0; i < items.length; i++) {
400+
let link = items[i]
401+
proxyLog("Requesting proxy from " + link)
402+
fetchList(link)
403+
.then(items => {
404+
let proxies = "";
405+
proxyLog("Proxy fetched " + items.length)
406+
items.forEach(proxy => {
407+
proxies += proxy+"\n"
408+
});
409+
idProxylist.value += proxies
410+
})
411+
.catch(error => {
412+
proxyLog(error);
413+
});
414+
}
415+
} catch (error) {
416+
proxyLog(error);
417+
}
418+
}
419+
420+
async function fetchList(link) {
421+
const fetchOptions = {
422+
method: 'GET',
423+
headers: { 'Content-Type': 'application/json' },
424+
body: null
425+
};
426+
427+
try {
428+
const res = await fetch(link, fetchOptions);
429+
const text = await res.text();
430+
const lines = text.toString().split(/\r?\n/);
431+
let items = new Array;
432+
433+
for (var i = 0; i < lines.length; i++) {
434+
let line = lines[i]
435+
if (line === "") continue;
436+
items.push(line);
437+
}
438+
return items
439+
440+
} catch (error) {
441+
proxyLog(error);
442+
return;
443+
}
444+
}
445+
327446
module.exports = {
328447
getBotInfo,
329448
connectBot,
@@ -333,6 +452,7 @@ module.exports = {
333452
rmPlayer,
334453
errBot,
335454
sendLog,
455+
proxyLog,
336456
exeAll,
337457
startScript,
338458
checkVer,
@@ -341,6 +461,9 @@ module.exports = {
341461
createPopup,
342462
formatText,
343463
selectedList,
464+
checkAuth,
465+
createBot,
466+
scrapeProxy,
344467
mineflayer,
345468
botApi
346469
}

assets/js/htmlcontrol.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,15 @@ function openTab(tabName) {
8686
}
8787
document.getElementById(tabName).style.display = "block";
8888
event.currentTarget.classList.add("active");
89+
}
90+
91+
function removeDuplicateLines() {
92+
const text = idProxylist.value
93+
const lines = text.split('\n');
94+
const uniqueLines = new Set();
95+
for (const line of lines) {
96+
uniqueLines.add(line);
97+
}
98+
const result = Array.from(uniqueLines).join('\n');
99+
idProxylist.value = result;
89100
}

assets/plugins/proxychecker.js

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
const mc = require('minecraft-protocol')
2+
const socks = require('socks').SocksClient
3+
const ProxyAgent = require('proxy-agent')
4+
const path = require('path')
5+
const { createPopup } = require('../js/cf')
6+
const { salt, delay , proxyLog } = require(path.join(__dirname, ".." , "js", "cf.js"))
7+
process.NODE_TLS_REJECT_UNAUTHORIZED = "0"
8+
9+
let proxyList = "";
10+
let stopCheck = false;
11+
12+
async function checkProxy(proxies) {
13+
start(proxies)
14+
idStopCheck.addEventListener('click', () => {
15+
stop()
16+
})
17+
const lines = proxyList.toString().split(/\r?\n/)
18+
for (var i = 0; i < lines.length; i++) {
19+
if(stopCheck) break;
20+
checkMain(lines[i].split(':')[0], lines[i].split(':')[1])
21+
idCheckCount.innerHTML = i + 1 + "/" + lines.length
22+
await delay(idproxyCheckDelay.value ? idproxyCheckDelay.value : 100)
23+
}
24+
}
25+
26+
function checkMain(proxyHost, proxyPort) {
27+
var serverHost = idIp.value.split(':')[0] ? idIp.value.split(':')[0] : "localhost";
28+
var serverPort = idIp.value.split(':')[1] ? idIp.value.split(':')[1] : 25565;
29+
var options = {
30+
connect: client => {
31+
socks.createConnection({
32+
proxy: {
33+
host: proxyHost,
34+
port: parseInt(proxyPort),
35+
type: parseInt(idProxyCheckProtocol.value)
36+
},
37+
command: 'connect',
38+
destination: {
39+
host: serverHost,
40+
port: parseInt(serverPort)
41+
}
42+
}, (err, info) => {
43+
if (err) {return;}
44+
client.setSocket(info.socket);
45+
client.emit('connect')
46+
})
47+
},
48+
agent: new ProxyAgent({ protocol: `socks${parseInt(idProxyCheckProtocol.value)}`, host: proxyHost, port: proxyPort }),
49+
host: serverHost,
50+
port: serverPort,
51+
username: salt(15),
52+
version: idBotVersion.value
53+
}
54+
var bot = mc.createClient(options);
55+
bot.once('connect', ()=> {
56+
addProxy(`${proxyHost}:${proxyPort}`)
57+
bot.end()
58+
});
59+
bot.on('error', (err) => {
60+
proxyLog('Proxy Error: '+ err.message)
61+
});
62+
setTimeout(() => {
63+
bot.end()
64+
proxyLog("Proxy Timeout: " + proxyHost + ":" + proxyPort)
65+
}, idProxyTimeout.value ? idProxyTimeout.value : 1000);
66+
}
67+
68+
function stop() {
69+
stopCheck = true
70+
const lines = proxyList.toString().split(/\r?\n/)
71+
idCheckCount.innerHTML = "0/" + lines.length
72+
idProxyDownbar.style.display = "none"
73+
createPopup("Stopped checking")
74+
}
75+
76+
function start(proxies) {
77+
stopCheck = false
78+
proxyList = proxies;
79+
idProxylist.value = "";
80+
idProxyDownbar.style.removeProperty("display");
81+
createPopup("Started Checking")
82+
}
83+
84+
function addProxy(proxy) {
85+
idProxylist.value += proxy + "\n"
86+
proxyLog("Added: " + proxy);
87+
}
88+
89+
module.exports = {
90+
checkProxy
91+
}

assets/style/style.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,9 @@ ul li {
250250
.mu-4 {
251251
margin-top: 1rem;
252252
}
253+
.mu-2 {
254+
margin-top: 0.5rem;
255+
}
253256
.p-4 {
254257
padding: 1rem;
255258
}

0 commit comments

Comments
 (0)