raisedragon / pircbotx

Automatically exported from code.google.com/p/pircbotx
0 stars 0 forks source link

Bind to IP #49

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
On a multi-ip system, users may want to make sure the IRC bot connects to the 
IRC server on a certain IP address.

Could you please add this functionality, It would make my bot complete.

Original issue reported on code.google.com by flur0w...@gmail.com on 7 Nov 2011 at 8:40

GoogleCodeExporter commented 9 years ago
Sorry, could not mark as Enhancement, would be great if you could fix that for 
me.

Original comment by flur0w...@gmail.com on 7 Nov 2011 at 8:41

GoogleCodeExporter commented 9 years ago
I just tested it, you can put in an IP address and it will connect. You just 
have to convert it to a string. Eg 

bot.connect("89.16.176.16");

Connects to one of Freenode's IRC servers. Creating overrides accepting 
InetAddresses will just complicate things more

Original comment by Lord.Qua...@gmail.com on 9 Nov 2011 at 1:02

GoogleCodeExporter commented 9 years ago
I want to see if you'll take a look at this again, I don't think this is true 
what you're saying. What you said is for when you want to connect to a remote 
IP address. What this was requesting was the ability to choose what local IP 
address the socket is bound to.

The requested change would be to allow us to pass in, in some way, the local 
address that we want the socket to bind to. 

The example I have is that my server has 4 different IP addresses assign to it:
172.16.1.59
172.16.1.60
172.16.1.61
172.16.1.62

.59 is my default IP address, this is what it will bind to in the current code. 
What I would prefer to have is the ability to specify the localaddress that 
gets passed into the connect function. If you look at lines 317 and 319 of 
PircBotX.java, you could modify the two functions there to use the version that 
allows you to specify the local address. Both SocketFactory.CreateSocket() and 
Socket() have versions that allow this.

Any chance you can reopen this and implement it?

Original comment by rpast...@contre.us on 16 Feb 2012 at 10:05

GoogleCodeExporter commented 9 years ago
Ah, I didn't think that's what you meant. That does seem useful those who have 
multi-homed servers

While I would of preferred to make you pass in a socket factory or something 
apparently there's not an easily available one that's provided by default with 
the JDK.

I decided to use the inetAddress that's already in the bot to represent the 
local address of the socket. If you set it with setInetAddress before 
connecting the socket will be created there

Added in Revision 80583f49180e

Original comment by Lord.Qua...@gmail.com on 17 Feb 2012 at 2:08