mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-04-27 22:39:41 +00:00
client.py: use persistent FURLs for our Node, to reduce spurious connection attempts (#26)
This commit is contained in:
parent
f3846da4ab
commit
59f4a5abe8
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
import os, sha, stat, time
|
import os, sha, stat, time
|
||||||
from foolscap import Referenceable
|
from foolscap import Referenceable, SturdyRef
|
||||||
from zope.interface import implements
|
from zope.interface import implements
|
||||||
from allmydata.interfaces import RIClient
|
from allmydata.interfaces import RIClient
|
||||||
from allmydata import node
|
from allmydata import node
|
||||||
@ -26,6 +26,7 @@ class Client(node.Node, Referenceable):
|
|||||||
WEBPORTFILE = "webport"
|
WEBPORTFILE = "webport"
|
||||||
INTRODUCER_FURL_FILE = "introducer.furl"
|
INTRODUCER_FURL_FILE = "introducer.furl"
|
||||||
GLOBAL_VDRIVE_FURL_FILE = "vdrive.furl"
|
GLOBAL_VDRIVE_FURL_FILE = "vdrive.furl"
|
||||||
|
MY_FURL_FILE = "myself.furl"
|
||||||
SUICIDE_PREVENTION_HOTLINE_FILE = "suicide_prevention_hotline"
|
SUICIDE_PREVENTION_HOTLINE_FILE = "suicide_prevention_hotline"
|
||||||
|
|
||||||
# we're pretty narrow-minded right now
|
# we're pretty narrow-minded right now
|
||||||
@ -43,7 +44,7 @@ class Client(node.Node, Referenceable):
|
|||||||
WEBPORTFILE = os.path.join(self.basedir, self.WEBPORTFILE)
|
WEBPORTFILE = os.path.join(self.basedir, self.WEBPORTFILE)
|
||||||
if os.path.exists(WEBPORTFILE):
|
if os.path.exists(WEBPORTFILE):
|
||||||
f = open(WEBPORTFILE, "r")
|
f = open(WEBPORTFILE, "r")
|
||||||
webport = f.read() # strports string
|
webport = f.read().strip() # strports string
|
||||||
f.close()
|
f.close()
|
||||||
self.add_service(WebishServer(webport))
|
self.add_service(WebishServer(webport))
|
||||||
|
|
||||||
@ -75,7 +76,18 @@ class Client(node.Node, Referenceable):
|
|||||||
|
|
||||||
def tub_ready(self):
|
def tub_ready(self):
|
||||||
self.log("tub_ready")
|
self.log("tub_ready")
|
||||||
self.my_furl = self.tub.registerReference(self)
|
|
||||||
|
my_old_name = None
|
||||||
|
MYSELF_FURL_PATH = os.path.join(self.basedir, self.MY_FURL_FILE)
|
||||||
|
if os.path.exists(MYSELF_FURL_PATH):
|
||||||
|
my_old_furl = open(MYSELF_FURL_PATH, "r").read().strip()
|
||||||
|
sturdy = SturdyRef(my_old_furl)
|
||||||
|
my_old_name = sturdy.name
|
||||||
|
|
||||||
|
self.my_furl = self.tub.registerReference(self, my_old_name)
|
||||||
|
f = open(MYSELF_FURL_PATH, "w")
|
||||||
|
f.write(self.my_furl)
|
||||||
|
f.close()
|
||||||
|
|
||||||
ic = IntroducerClient(self.tub, self.introducer_furl, self.my_furl)
|
ic = IntroducerClient(self.tub, self.introducer_furl, self.my_furl)
|
||||||
self.introducer_client = ic
|
self.introducer_client = ic
|
||||||
|
Loading…
x
Reference in New Issue
Block a user