Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #60546 > unrolled thread

Re: How to determine whether client and server are on the same host

Started byWalter Hurry <walterhurry@lavabit.com>
First post2013-11-26 23:08 +0000
Last post2013-11-27 23:32 +0100
Articles 3 — 3 participants

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: How to determine whether client and server are on the same host Walter Hurry <walterhurry@lavabit.com> - 2013-11-26 23:08 +0000
    Re: How to determine whether client and server are on the same host Chris Angelico <rosuav@gmail.com> - 2013-11-27 10:15 +1100
    Re: How to determine whether client and server are on the same host Malte Forkel <malte.forkel@berlin.de> - 2013-11-27 23:32 +0100

#60546 — Re: How to determine whether client and server are on the same host

FromWalter Hurry <walterhurry@lavabit.com>
Date2013-11-26 23:08 +0000
SubjectRe: How to determine whether client and server are on the same host
Message-ID<l739kk$akt$1@news.albasani.net>
On Wed, 27 Nov 2013 09:56:13 +1100, Chris Angelico wrote:

> On Wed, Nov 27, 2013 at 4:26 AM, Malte Forkel <malte.forkel@berlin.de>
> wrote:
>> Thanks for the explanation. I guess I was hoping that I could use some
>> property of a connection created with telnetlib or its socket to find
>> out whether it was actually a host-local connection (i.e. a connection
>> to 'localhost', '127.xx.xx.xx' or '<local_host_name>').
>>
>> So its either your initial suggestion of taking a hint from the user or
>> comparing files on the server and the client.
> 
> You can still have a unique file, then; all you sacrifice is the random
> name generation. And you can of course recognize 127.x.y.z as local -
> it's just not the _only_ way to detect a local connection.
> 
> Since this is, presumably, an optimization, you could possibly just tell
> people that it'll run faster if they tell it 127.0.0.1 than if they tell
> it {whatever other IPs the server has}. That may end up sufficient.
> Otherwise, yeah, detect by filesystem with a manually-created file.

How about checking the MAC address of the local network card on the 
client, and then comparing that against a file on the server?

Easy enough with ifconfig and grep. I presume that there is also a way on 
Windows, but others will have to contribute that.

[toc] | [next] | [standalone]


#60550

FromChris Angelico <rosuav@gmail.com>
Date2013-11-27 10:15 +1100
Message-ID<mailman.3261.1385507758.18130.python-list@python.org>
In reply to#60546
On Wed, Nov 27, 2013 at 10:08 AM, Walter Hurry <walterhurry@lavabit.com> wrote:
> Easy enough with ifconfig and grep. I presume that there is also a way on
> Windows, but others will have to contribute that.

Since the server runs Linux, inability to run /sbin/ifconfig could
safely be interpreted as "we're not running on the server". But I
think this actually gains little over "is there a file called
/tmp/_this_is_malte_forkel_on_his_server_9515343_", which would be
fairly safe.

ChrisA

[toc] | [prev] | [next] | [standalone]


#60644

FromMalte Forkel <malte.forkel@berlin.de>
Date2013-11-27 23:32 +0100
Message-ID<mailman.3325.1385592004.18130.python-list@python.org>
In reply to#60546
Am 27.11.2013 00:15, schrieb Chris Angelico:
> Since the server runs Linux, inability to run /sbin/ifconfig could
> safely be interpreted as "we're not running on the server". But I
> think this actually gains little over "is there a file called
> /tmp/_this_is_malte_forkel_on_his_server_9515343_", which would be
> fairly safe.
> 
The server runs Linux, the client might be used under Windows as well.

I can't modify the server. So there is no way to create a file
/tmp/_this_is_malte_forkel_on_his_server_9515343 or to check whether it
exists on the server side.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web