-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using stocks. #40
Comments
That can be for different reasons. |
Check packets from/to SOCKS server with |
Here you go |
It says "This file is not available, because the upload was interrupted.". |
Okay let me try again, http://ge.tt/1Cwgi8U2/v/0 and the proxy ips are 121.40.34.139:3128 and 31.184.242.173:3130 |
I do not see there SOCKS IP at all. Are you sure your code is correct? function createAgent() {
return new Socks.Agent({
proxy: {
ipaddress: '121.40.34.139',
port: 3128,
type: 5
}}
);
} Replace SOCKS IP with working one, if this SOCKS is dead already. |
I do see communications with |
var stock = ["121.40.34.139:3128", "31.184.242.173:3130"];
var http=require('http');
var Socks = require('socks');
var AgarioClient = require('./agario-client/agario-client.js');
var botnames = ["DrGoat"];
//pick a random array
function randomarray(array) {
return array[Math.floor(Math.random() * array.length)];
}
//Basic info for bot
function ExampleBot(bot_id) {
this.bot_id = bot_id; //ID of bot for logging
this.nickname = randomarray(botnames);//default nickname
this.verbose = true; //default logging enabled
this.interval_id = 0; //here we will store setInterval's ID
this.server = ''; //server address will be stored here
this.server_key = ''; //server key will be stored here
this.client = new AgarioClient('Bot ' + this.bot_id); //create new client
this.client.debug = 1; //lets set debug to 1
this.agent = ''
}
//Uses stock5 proxy
function createAgent() {
var dataaa = randomarray(stock).split(":")
return new Socks.Agent({
proxy: {
ipaddress: (dataaa[0]),
port: (dataaa[1]),
type: ('5')
}}
);
}
var agent = createAgent();
//Options for getFFAServer
var get_server_opt = {
region: 'EU-London', //server region
agent: agent //our agent
};
//Bot AI
ExampleBot.prototype = {
log: function(text) {
if(this.verbose) {
console.log(this.bot_id + ' says: ' + text);
}
},
connect: function(server, key) {
this.log('Connecting to ' + server + ' with key ' + key);
this.server = server;
this.server_key = key;
this.client.connect(server, key);
this.attachEvents();
},
attachEvents: function() {
var bot = this;
bot.client.on('connected', function() {
bot.log('Connected, spawning');
bot.client.spawn(bot.nickname);
bot.interval_id = setInterval(function(){bot.recalculateTarget()}, 100);
});
bot.client.on('connectionError', function(e) {
bot.log('Connection failed with reason: ' + e);
bot.log('Server address set to: ' + bot.server + ' key ' + bot.server_key);
});
bot.client.once('leaderBoardUpdate', function(old, leaders) {
var name_array = leaders.map(function(ball_id) {
return bot.client.balls[ball_id].name || 'unnamed'
});
bot.log('Joined server');
});
bot.client.on('lostMyBalls', function() {
bot.client.spawn(bot.nickname);
});
bot.client.on('reset', function() { //when client clears everything (connection lost?)
clearInterval(bot.interval_id);
});
},
recalculateTarget: function() {
var bot = this;
bot.client.moveTo(0, 0);
}
};
//launching bots below
//object of bots
var bots = {
'Alpha' : null,
'Bravo' : null,
'Charlie': null,
'Delta' : null,
'1' : null,
'2' : null,
'3': null,
'4' : null,
'5' : null
};
//searching party for bots in EU-London
function start() {
console.log('Requesting party server');
AgarioClient.servers.createParty({region: 'EU-London'}, function(srv) {
if(!srv.server) return console.log('Failed to request server (error=' + srv.error + ', error_source=' + srv.error_source + ')');
console.log('Engaging bots to party http://agar.io/#' + srv.key + ' on IP ' + srv.server);
for(var bot_id in bots) {
bots[bot_id] = new ExampleBot(bot_id);
bots[bot_id].agent = createAgent();
console.log('using agent ' + bots[bot_id].agent)
bots[bot_id].connect('ws://' + srv.server, srv.key);
}
});
}
startServer() |
I see there few problems.
So after "fixes" here is "working" code var stock = ["1.2.3.4:5678"];
var http=require('http');
var Socks = require('socks');
var AgarioClient = require('./agario-client/agario-client.js');
var botnames = ["DrGoat"];
//pick a random array
function randomarray(array) {
return array[Math.floor(Math.random() * array.length)];
}
//Basic info for bot
function ExampleBot(bot_id) {
this.bot_id = bot_id; //ID of bot for logging
this.nickname = randomarray(botnames);//default nickname
this.verbose = true; //default logging enabled
this.interval_id = 0; //here we will store setInterval's ID
this.server = ''; //server address will be stored here
this.server_key = ''; //server key will be stored here
this.client = new AgarioClient('Bot ' + this.bot_id); //create new client
this.client.debug = 1; //lets set debug to 1
this.agent = ''
}
//Uses stock5 proxy
function createAgent() {
var dataaa = randomarray(stock).split(":");
return new Socks.Agent({
proxy: {
ipaddress: (dataaa[0]),
port: (dataaa[1]),
type: 5
}}
);
}
var agent = createAgent();
//Options for getFFAServer
var get_server_opt = {
region: 'EU-London', //server region
agent: agent //our agent
};
//Bot AI
ExampleBot.prototype = {
log: function(text) {
if(this.verbose) {
console.log(this.bot_id + ' says: ' + text);
}
},
connect: function(server, key) {
this.log('Connecting to ' + server + ' with key ' + key);
this.server = server;
this.server_key = key;
this.client.connect(server, key);
this.attachEvents();
},
attachEvents: function() {
var bot = this;
bot.client.on('connected', function() {
bot.log('Connected, spawning');
bot.client.spawn(bot.nickname);
bot.interval_id = setInterval(function(){bot.recalculateTarget()}, 100);
});
bot.client.on('connectionError', function(e) {
bot.log('Connection failed with reason: ' + e);
bot.log('Server address set to: ' + bot.server + ' key ' + bot.server_key);
});
bot.client.once('leaderBoardUpdate', function(old, leaders) {
var name_array = leaders.map(function(ball_id) {
return bot.client.balls[ball_id].name || 'unnamed'
});
bot.log('Joined server');
bot.log('Leaders on server:' + name_array);
});
bot.client.on('lostMyBalls', function() {
bot.client.spawn(bot.nickname);
});
bot.client.on('reset', function() { //when client clears everything (connection lost?)
clearInterval(bot.interval_id);
});
},
recalculateTarget: function() {
var bot = this;
bot.client.moveTo(0, 0);
}
};
//launching bots below
//object of bots
var bots = {
'Alpha' : null
};
//searching party for bots in EU-London
function start() {
console.log('Requesting party server');
AgarioClient.servers.createParty({region: 'EU-London', agent: createAgent()}, function(srv) {
if(!srv.server) return console.log('Failed to request server (error=' + srv.error + ', error_source=' + srv.error_source + ')');
console.log('Engaging bots to party http://agar.io/#' + srv.key + ' on IP ' + srv.server);
for(var bot_id in bots) {
bots[bot_id] = new ExampleBot(bot_id);
bots[bot_id].agent = createAgent();
console.log('using agent ' + bots[bot_id].agent)
bots[bot_id].connect('ws://' + srv.server, srv.key);
}
});
}
start(); If you add more than one SOCKS, it will stop work. You need use same SOCKS for requesting server/key and connection. You need to fix that. |
Thanks for the help! How would I get different ips to join the same party? |
What i can think of is modifying function createAgent(socks) {
return new Socks.Agent({
proxy: socks
}
);
} Then rewrite function start() {
console.log('Requesting party server');
var socks = getNewSocksServer();
AgarioClient.servers.createParty({region: 'EU-London', agent: createAgent(socks)}, function(srv) {
if(!srv.server) return console.log('Failed to request server (error=' + srv.error + ', error_source=' + srv.error_source + ')');
console.log('Engaging bots to party http://agar.io/#' + srv.key + ' on IP ' + srv.server);
for(var bot_id in bots) {
bots[bot_id] = new ExampleBot(bot_id);
bots[bot_id].agent = createAgent(socks);
console.log('using agent ' + bots[bot_id].agent)
bots[bot_id].connect('ws://' + srv.server, srv.key);
}
});
} And making
Didn't tested, but i think you got the idea. You can even write |
I'm trying to include your stock5/proxy example into my project but I'm getting errors.
Bot : client created
using agent [object Object]
Connecting to ws://151.80.96.51:1507 with key X2TBE
Bot : connecting...
Bot : connection error: Error: connect ECONNREFUSED 151.80.96.51:1507
In other words the bot isn't connecting to the stock proxy.
code:
The text was updated successfully, but these errors were encountered: