SimpleXMLRPCServer and client address

Jean-Michel Pichavant jeanmichel at sequans.com
Thu Feb 11 14:34:16 CET 2010


Stephen Hansen wrote:
> On Wed, Feb 10, 2010 at 5:36 PM, Jean-Michel Pichavant 
> <jeanmichel at sequans.com <mailto:jeanmichel at sequans.com>> wrote:
>
>     I don't know exactly what you are trying to do, but if your server
>     requires informations from the client, it would be better to ask
>     explicitly the client for those informations.
>     For instance, if a method requires te client IP address, then the
>     IP address is definitely a parameter of the method.
>
>
> I can't answer the OP, as I don't know the answer to his specific 
> question-- but er, asking a client to provide one's IP address is not 
> really a very workable solution. There's no way to really determine 
> your own IP address in a reliable way.
>
> All the usual methods (e.g., 
> socket.gethostbyname(socket.gethostname())) can fail and/or be wrong 
> in some not terribly uncommon situations. The only reliable way to get 
> such a piece of information is to connect to a server, and ask that 
> server what address you were connecting to them as. Even then, that IP 
> may not be the same as an IP you use to connect to say, a different 
> server (on a different network)
>
> --S
You're probably right.
But my point covered only the fact that if a method needs something it 
should ask it explicitly throught parameters, not taking the opportunity 
to guess it since it happens that it's a xmlrpc server and that the 
information could be deduced from the client IP address.

My feeling is that the OP needed something else than the client IP 
address, and was trying at the server side to map client IPs with the 
data he effectively needs. I could be wrong though.

JM







More information about the Python-list mailing list