Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

working on meaningful names

git-svn-id: svn://forre.st/undns@1195 470744a7-cac9-478e-843e-5ec1b25c69e8
  • Loading branch information...
commit b8428ccdace82a46e92f76a6071feafeca3711a0 1 parent 8ff0551
forrest authored
Showing with 230 additions and 0 deletions.
  1. +99 −0 notes
  2. +131 −0 p2p.py
View
99 notes
@@ -0,0 +1,99 @@
+obviously p2p ... no centralized point of control/failure
+ local peer discovery
+
+names - two options:
+ granted on a first-come first-serve basis
+ all random - a hash of a secret key, perhaps - or a public key! isn't that nice!
+ o.O tor already had that idea
+
+should there exist subdomains ... there doesn't really seem to be much point
+ * www.fashdfjkahsjkfdlhasdjkfhaslkj.tba.tld
+ * mail.fashdfjkahsjkfdlhasdjkfhaslkj.tba.tld
+ as opposed to
+ * qdshfjlhaorbwekfashfahfadshff.tba.tld
+ * mvbnsakljhgfiwkjefbajhsdfahah.tba.tld
+
+each name is associated with variable data
+ ofc it is variable, because otherwise there would be no disadvantage to just using ip addresses
+ current ip address
+ more than one for balancing
+ TTL?
+ something about geographical balancing, since it's not possible in the usual way
+
+update propagation
+ updates are numbered by the sender
+ an evil person could use the maximum number, messing everything up
+ perhaps a timestamp would be better to avoid that
+ systems could ignore ones with timestamps in the future
+ update contains a complete copy of the new data
+
+the key question is about whether names need to be recognizable
+ do they need to be remembered?
+ how often are urls typed?
+ do they have value anymore?
+ google chrome hiding urls would seem to confirm that their value is declining
+ but the pricing of popular ones (sex.com, i think it was) would seem to indicate that they have value
+ what about authentication of SSL certificates?
+ they can just use the new urls on the certs
+ problem if using same ip, like with virtual hosting
+
+registering a domain is equivalent to injecting it into the p2p net
+ you'd want to maintain a server to ensure that it stays - nodes may purge unused names
+
+the only thing that preserves ownership of a name is keeping the private key
+ a market for encryption devices would arise to secure the key
+ a protocol for establishing control if a key is compromised would be important
+ special message that turns control completely over to some central authority
+ the central authority can't be declared in the message
+ would give the 'bad guys' an option to turn it over to themselves ... duh
+ has to be established
+
+hmm ... how about ...
+idk what i was going to say there (i return after 8 hours) but i have one new idea:
+
+to ease conversion, we make all new domain names valid old domain names by buying a domain name and using it as a suffix
+ - then running a DNS server to resolve names
+ ties nicely into existing infrastructure
+ sadly, this is a very central point of failure.
+ it must only be a stopgap measure
+ no way to avoid this, so let's find a good registrar
+ preferably not US based
+ does sweden have any? o.O
+ is sweden even that good ...
+ on the good side, it avoids name conflicts - no need to establish our own TLD
+
+migration
+ 1. no attempt
+ names resolve through public dns and the central server
+ 2. some attempt - dns server changed to public server
+ many servers, not just one
+ ISPs might agree to do this
+ 3. complete - running the daemon
+ only way to completely ensure authenticity
+ daemon could run on a local router, usage would be automatic if it provided DNS server over DHCP
+
+p2p
+ bootstrapping
+ centralized point of failure ... ahh!
+ multiple sources
+ some peers addresses included
+ several http addresses that provide more included
+ no point in using new style addresses, they're just more vulnerable than others if not using a p2p resolver..
+ random pinging (:p)
+ might work on ipv4, not ipv6!
+ sharing
+
+status
+* going to use .undns.forre.st temporarily
+* twisted dns server
+
+* okay, meaningless names implementation is done, more or less
+
+meaningful names:
+
+* proof of work needed to avoid DOS and provide scarcity
+ * also needed to hold domain, otherwise it expires
+
+things learned from bitcoin:
+ * use an extensible protocol
+ * make rules explicit
View
131 p2p.py
@@ -0,0 +1,131 @@
+import random
+import sys
+import json
+import time
+
+from twisted.internet import reactor, defer, protocol
+from twisted.python import failure
+
+import pygame
+d = pygame.display.set_mode((512, 512))
+def get_coords(o):
+ a = hash(o)
+ a, x = divmod(a, 512)
+ a, y = divmod(a, 512)
+ return (x, y)
+def circle(c, pos, r):
+ pygame.draw.circle(d, c, pos, r)
+ pygame.display.update()
+def line(c, a, b):
+ pygame.draw.line(d, c, a, b)
+ pygame.display.update()
+
+
+class RemoteNode(object):
+ def __init__(self, protocol, address):
+ self.protocol = protocol
+ self.address = address
+ def __getattr__(self, attr):
+ if attr.startswith("rpc_"):
+ def do_rpc(*args):
+ tag = random.randrange(2**64)
+ d = defer.Deferred()
+
+ self.protocol.queries[tag] = d
+
+ self.protocol.transport.write(json.dumps((self.protocol.id, False, (tag, attr[len("rpc_"):], args))), self.address)
+
+ return d
+ return do_rpc
+ raise AttributeError("%r object has no attribute %r" % (self.__class__.__name__, attr))
+
+class Node(protocol.DatagramProtocol):
+ def __init__(self, port, bootstrap_addresses):
+ #protocol.DatagramProtocol.__init__(self)
+ self.contacts = {} # address -> RemoteNode()
+ self.queries = {}
+ self.port = port
+ self.bootstrap_addresses = bootstrap_addresses
+ self.id = random.randrange(2**128)
+ circle((255, 0, 0), get_coords(self.id), 5)
+
+ @defer.inlineCallbacks
+ def add_contact(self, address, remote_id=None):
+ if address in self.contacts:
+ return
+ if remote_id is None:
+ remote_id = yield RemoteNode(self, address).rpc_ping()
+ if remote_id == self.id:
+ return
+ line((0, (self.id^remote_id)/2.**128*255, 255), get_coords(self.id), get_coords(remote_id))
+ self.contacts[address] = RemoteNode(self, address)
+
+ def startProtocol(self):
+ reactor.callLater(random.expovariate(5), self.think)
+
+ @defer.inlineCallbacks
+ def think(self):
+ reactor.callLater(random.expovariate(5), self.think)
+
+ if self.bootstrap_addresses:
+ self.add_contact(random.choice(self.bootstrap_addresses))
+
+ if self.contacts:
+ c = random.choice(self.contacts.values())
+ contacts = yield c.rpc_get_contacts()
+ #print self.port, [x[1] for x in self.contacts.keys()], c.address[1]
+ #print self.port, "contacted", c.address[1], "and got", [x[1] for x in contacts]
+ #print self.port, "GOT2", contacts, self.contacts
+ #print contacts
+ for contact in contacts:
+ contact = tuple(contact) # list -> tuple
+ #print "B", contact
+ self.add_contact(contact)
+
+ print self.port, len(self.contacts)
+
+ @defer.inlineCallbacks
+ def datagramReceived(self, datagram, addr):
+
+ remote_id, answer, contents = json.loads(datagram)
+ self.add_contact(addr, remote_id)
+ if answer:
+ tag, response = contents
+ self.queries.pop(tag).callback(response)
+ else: # question
+ tag, method_name, args = contents
+
+ resp = yield getattr(self, "rpc_" + method_name)(*args)
+ self.transport.write(json.dumps((self.id, True, (tag, resp))), addr)
+
+ def rpc_ping(self):
+ #print "pinged!"
+ return defer.succeed(self.id)
+
+ def rpc_get_time(self):
+ return time.time()
+
+ def rpc_get_contacts(self):
+ return defer.succeed(self.contacts.keys())
+
+
+def parse(x):
+ ip, port = x.split(':')
+ return ip, int(port)
+
+last = None
+
+for i in xrange(20):
+ port = random.randrange(49152, 65536)
+ reactor.listenUDP(port, Node(port, [] if last is None else [("127.0.0.1", last)]))
+ print port
+ last = port
+
+print "---"
+
+#port = random.randrange(49152, 65536)
+#reactor.listenUDP(port, Node(port, map(parse, sys.argv[1:])))
+#print port
+
+
+reactor.run()
Please sign in to comment.
Something went wrong with that request. Please try again.