Set IP sender on packets sent from Openfire

Hi to all.

I have this problem:

I have two openfire servers open on same machine. This machine has two network card, one has IP 10.11.9.1, and one has IP 10.11.4.29.

I edit the xml files of the servers (target: /openfire/conf/openfire.xml) for to do that each server is listening his network card:

first server:

**10.11.4.29**

second server:

10.11.9.1

Then, I have a client “user1” (user1@10.11.4.29) that is logged on first server and a client “user2” (user2@10.11.9.1) that is logged on second server.

Now, I have this question:

Is possible to set at application layer (so directly with Openfire) the IP sender of the packets sent from the users?

I want to set at application layer the IP 10.11.4.29 in the packets from user1@10.11.4.29

I want to set at application layer the IP 10.11.9.1 in the packets from user2@10.11.9.1

I ask this because if I do “sniffing” of packets with Wireshark on this machine I see that all packets sent from user1 or user2 have all as IP address 10.11.9.1.

Warning:

I don’t do this with routing table, but I must do it at application level. Do you know if is it possible?

I hope you understand my problem.

thank you in advance,

Crystal

Hi Crystal,

is this an Openfire issue or a client issue? You write “all packets sent from user1 or user2 have all as IP address 10.11.9.1.”. So I wonder if you want to run local clients. Usually one has remote clients and there this shouldn’t be an issue.

LG

Sorry,

I forget to say that user1 and user2 send packets to another server where is logged an user3.

I want that user1 speak with user3 and user2 speak with user3, but I want that the packets from user1 to user3 have IP 10.11.4.29 and packets from user2 to user3 have IP 10.11.9.1.

Instead, now, packets that arrive to user3 have all same IP: 10.11.9.1.

I must doing it directly with Openfire (by application layer).

Is it possible? Do you understand now?

I hope yes.

Thank you very much.

Hi Crystal,

this should be possible. Java offers two (to keep it simply) Socket() methods:

public Socket(InetAddress address, int port)

public Socket(InetAddress address, int port, InetAddress localAddr, int localPort)

While it it usually fine to let Java or the OS decide which IP address to use there are always some reasons to use a special source address.

I just wanted to create an issue, but there is already an issue to get this fixed, see http://www.igniterealtime.org/issues/browse/JM-1064 - I did create this more than one a year ago.

So you may want to fix this and compile Openfire for yourself.

LG

Hi,

I see your example. But I have a problem, I don’t know Java language very much.

Where must I insert this code?

thank you for you answer, this is exactly what I want!

Hi,

there are only a few java files which contain “Socket(” so it should be quite easy to find them. Insert the code within JM-1064 as shown, between “new Socket()” and “socket.connect()”. There are some documents in the Openfire Developers forum about downloading the source and compiling it.

LG

This Java files that you say are all in the directory lib of Openfire?

So, you think that is sufficient to insert only this code:

// get interface address to bind
String interfaceName = JiveGlobals.getXMLProperty(“network.interface”);
SocketAddress bindInterface = null;
bindInterface = new InetSocketAddress(interfaceName, 0);
// bind to interface,
socket.bind(bindInterface);

for do that?

thank you very much…

Crystal

I’m trying for to open this .jar files, but I don’t know as can I open it.

I have Eclipse software but it don’t open this file.

Can you help me about edit this file?

thank you…

Hi Crystal,

read http://www.igniterealtime.org/community/community/developers/openfire_dev?view=d ocuments - there are http://www.igniterealtime.org/community/docs/DOC-1020 and
http://www.igniterealtime.org/community/docs/DOC-1022

These documents should help you to setup Eclipse and Openfire. You need to download the source code, either as .zip or from SVN.

You can open .jar files with “jar”, “7zip”, … but they do contain .class files (compiled .java files) and are thus not the right place to modify something.

LG