Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'matches': 0.07; 'socket': 0.07; 'subject:same': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'rfc': 0.09; 'subject:How': 0.10; 'random': 0.14; "wouldn't": 0.14; "'localhost',": 0.16; "computer's": 0.16; 'confuse': 0.16; 'hint': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; "someone's": 0.16; 'things...': 0.16; 'trying': 0.19; 'machine': 0.22; 'creating': 0.23; 'header:User-Agent:1': 0.23; 'comparing': 0.24; 'either.': 0.24; 'instance,': 0.24; 'recognize': 0.24; 'initial': 0.24; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; "doesn't": 0.30; "i'm": 0.30; "skip:' 10": 0.31; 'file': 0.32; '(i.e.': 0.33; 'addresses': 0.33; 'guess': 0.33; 'subject:the': 0.34; 'could': 0.34; "can't": 0.35; 'connection': 0.35; 'created': 0.35; 'no,': 0.35; 'but': 0.35; 'house,': 0.36; 'thanks': 0.36; 'application': 0.37; 'two': 0.37; 'server': 0.38; 'connections': 0.38; 'to:addr:python-list': 0.38; 'files': 0.38; 'does': 0.39; 'itself': 0.39; 'to:addr:python.org': 0.39; 'either': 0.39; 'received:org': 0.40; 'worry': 0.60; 'back': 0.62; 'name': 0.63; 'such': 0.63; 'taking': 0.65; 'talking': 0.65; 'internet': 0.71; 'received:93': 0.72; 'hoping': 0.75 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Malte Forkel Subject: Re: How to determine whether client and server are on the same host Date: Tue, 26 Nov 2013 18:26:20 +0100 References: <7wfvqkrqvb.fsf@benfinney.id.au> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: p5ddb24f4.dip0.t-ipconnect.de User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.1.1 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 28 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1385486790 news.xs4all.nl 15999 [2001:888:2000:d::a6]:44531 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:60530 Am 26.11.2013 13:26, schrieb Chris Angelico: > If you deliberately create a file with a random name, the chances of > one existing with the same name on the client are infinitesimal unless > someone's deliberately trying to confuse things... in which case I > wouldn't worry about it. > I wouldn't, either. But the server is an existing application that I can't extend. It does not support creating a file with a random name. > No, because there's no such thing as a "local connection". For > instance, I have two internet connections at my house, and I can > telnet out on one of them and back in on the other - but both > connections are NATted, so the machine itself doesn't have an IP that > matches what I'm talking about here. I could have a socket connection > from w.x.y.z port 12345 to a.b.c.d port 80, and there's no way > telnetlib would recognize that as coming back to the same computer, > because this computer's IP addresses are all RFC 1918 ones (127.0.0.1, > 192.168.0.19, 192.168.2.2). > 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 ''). So its either your initial suggestion of taking a hint from the user or comparing files on the server and the client.