SlnDmry commited on
Commit
f3dd969
·
verified ·
1 Parent(s): 0cd394c

Update bot.js

Browse files
Files changed (1) hide show
  1. bot.js +32 -1
bot.js CHANGED
@@ -8,6 +8,7 @@ const { GoalBlock, GoalXZ } = require("mineflayer-pathfinder").goals;
8
  const util = require("util");
9
  const { SocksProxyAgent } = require("socks-proxy-agent");
10
  const proxyChain = require("proxy-chain");
 
11
 
12
  const config = require("./settings.json");
13
  const loggers = require("./logging.js");
@@ -49,6 +50,19 @@ let bot = null;
49
 
50
  async function createBot() {
51
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  const newProxyUrl = await proxyChain.anonymizeProxy("socks4://176.88.166.215:1080");
53
  const agent = await new SocksProxyAgent(newProxyUrl);
54
  bot = await mineflayer.createBot({
@@ -57,7 +71,24 @@ async function createBot() {
57
  host: config.server.ip,
58
  port: config.server.port,
59
  version: config.server.version,
60
- agent
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  });
62
 
63
 
 
8
  const util = require("util");
9
  const { SocksProxyAgent } = require("socks-proxy-agent");
10
  const proxyChain = require("proxy-chain");
11
+ const socks = require("socks");
12
 
13
  const config = require("./settings.json");
14
  const loggers = require("./logging.js");
 
50
 
51
  async function createBot() {
52
 
53
+ const proxyOptions = {
54
+ proxy: {
55
+ host: '176.88.166.215', // SOCKS proxy IP'n
56
+ port: 1080, // SOCKS proxy portun
57
+ type: 4 // Kodundaki adrese göre SOCKS4 kullandığın için 4 yazıldı. (Eğer proxy SOCKS5 ise 5 yapmalısın)
58
+ },
59
+ command: 'connect',
60
+ destination: {
61
+ host: config.server.ip,
62
+ port: parseInt(config.server.port) || 25565
63
+ }
64
+ };
65
+
66
  const newProxyUrl = await proxyChain.anonymizeProxy("socks4://176.88.166.215:1080");
67
  const agent = await new SocksProxyAgent(newProxyUrl);
68
  bot = await mineflayer.createBot({
 
71
  host: config.server.ip,
72
  port: config.server.port,
73
  version: config.server.version,
74
+
75
+ connect: (client) => {
76
+ logger.info(`[Proxy] ${proxyOptions.proxy.host}:${proxyOptions.proxy.port} üzerinden tünel açılıyor...`);
77
+
78
+ SocksClient.createConnection(proxyOptions, (err, info) => {
79
+ if (err) {
80
+ logger.error(`[Proxy Hatası] Tünel bağlantısı başarısız: ${err.message}`);
81
+ // Bağlantı koptuğunda veya başarısız olduğunda sistemin yeniden denemesi için tetikliyoruz
82
+ if (bot) bot.emit('end');
83
+ return;
84
+ }
85
+
86
+ logger.info("[Proxy] Tünel başarıyla kuruldu, Minecraft protokolü sokete bağlanıyor.");
87
+ client.setSocket(info.socket);
88
+ client.emit('connect');
89
+ });
90
+ }
91
+
92
  });
93
 
94