def __init__(self, router, endpoint): self.router=router self.endpoint=endpoint self.keys=router.keys self.maildir='spool/'+encode(endpoint.public.bytes) self.addressBook=YamlMap('config/dustmail-addressbook.yaml') self.done=Event() self.commandDone=Event() self.book=YamlMap('config/dustmail-addressbook.yaml') dustmailConfig=YamlMap('config/dustmail-config.yaml') try: destAddress=dustmailConfig['tracker'] except: entry=self.addInvite() destAddress=entry['tracker'] dustmailConfig['tracker']=destAddress dest, outport, v6=decodeAddress(destAddress) print('Registering with tracker...') self.tracker=TrackerClient(self.router, addr=(dest, outport)) host=getPublicIP(v6) inport=dustmailConfig['port'] self.tracker.putPeerForEndpoint(encode(self.endpoint.public.bytes), [encode(self.endpoint.public.bytes), encodeAddress((host,inport))]) invite=self.keys.generateInvite(inport, v6=v6) self.tracker.putInviteForPeer(encodeAddress((host, inport)), encode(invite.message)) self.trackback=self.router.getService('trackback')
def __init__(self, router, endpoint): self.router = router self.endpoint = endpoint self.keys = router.keys self.maildir = 'spool/' + encode(endpoint.public.bytes) self.addressBook = YamlMap('config/dustmail-addressbook.yaml') self.done = Event() self.commandDone = Event() self.book = YamlMap('config/dustmail-addressbook.yaml') dustmailConfig = YamlMap('config/dustmail-config.yaml') try: destAddress = dustmailConfig['tracker'] except: entry = self.addInvite() destAddress = entry['tracker'] dustmailConfig['tracker'] = destAddress dest, outport, v6 = decodeAddress(destAddress) host = getPublicIP(v6) inport = dustmailConfig['port'] invite = self.keys.generateInvite(inport, v6=v6)
def __init__(self, v6, port, keys): self.host = getPublicIP(v6) self.port = port msock = lite_multiplex_socket(keys) msock.bind((self.host, self.port)) while True: msg, addr, service = msock.mrecvfrom(1024) if msg and addr and service: handler = services[service] # print('Routing to', handler, '...') handler(msg, addr)
def __init__(self, v6, port, keys): self.host = getPublicIP(v6) self.port=port msock=lite_multiplex_socket(keys) msock.bind((self.host, self.port)) while True: msg, addr, service=msock.mrecvfrom(1024) if msg and addr and service: handler=services[service] # print('Routing to', handler, '...') handler(msg, addr)
def __init__(self, v6, port, keys, passwd, debug=False): self.v6=v6 self.host = getPublicIP(v6) self.port=port self.keys=keys self.passwd=passwd self.tcp=True self.debug=debug self.msock=multiplex_socket(self.keys) self.msock.bind((self.host, self.port)) self.ui=None for service in activeServices.values(): service.setRouter(self)
def __init__(self, v6, port, keys, passwd, debug=False): self.v6 = v6 self.host = getPublicIP(v6) self.port = port self.keys = keys self.passwd = passwd self.tcp = True self.debug = debug self.msock = multiplex_socket(self.keys) self.msock.bind((self.host, self.port)) self.ui = None for service in activeServices.values(): service.setRouter(self)
def __init__(self, router, endpoint): self.router = router self.endpoint = endpoint self.keys = router.keys self.maildir = 'spool/' + encode(endpoint.public.bytes) self.addressBook = YamlMap('config/dustmail-addressbook.yaml') self.done = Event() self.commandDone = Event() self.book = YamlMap('config/dustmail-addressbook.yaml') dustmailConfig = YamlMap('config/dustmail-config.yaml') try: destAddress = dustmailConfig['tracker'] except: entry = self.addInvite() destAddress = entry['tracker'] dustmailConfig['tracker'] = destAddress dest, outport, v6 = decodeAddress(destAddress) print('Registering with tracker...') self.tracker = TrackerClient(self.router, addr=(dest, outport)) host = getPublicIP(v6) inport = dustmailConfig['port'] self.tracker.putPeerForEndpoint(encode(self.endpoint.public.bytes), [ encode(self.endpoint.public.bytes), encodeAddress((host, inport)) ]) invite = self.keys.generateInvite(inport, v6=v6) self.tracker.putInviteForPeer(encodeAddress((host, inport)), encode(invite.message)) self.trackback = self.router.getService('trackback')
def generate(self, pubkey, v6, tcp, port, entropy): self.pubkey=pubkey self.v6=v6 self.tcp=tcp self.ip=getPublicIP(v6) self.port=port self.id=self.makeIdentifier(entropy) self.secret = self.makeSecret(entropy) pubkey=self.pubkey.bytes flags=encodeFlags((self.v6, self.tcp, False, False, False, False, False, False)) if self.v6: ip=inet_pton(AF_INET6, self.ip) else: #print('v4:', self.ip) ip=inet_pton(AF_INET, self.ip) #print('ip:', ip) ip=fill(ip, IP_LENGTH) port=struct.pack('H', self.port) id=self.id secret=self.secret self.message=pubkey+flags+ip+port+id+secret
def generate(self, pubkey, v6, tcp, port, entropy): self.pubkey = pubkey self.v6 = v6 self.tcp = tcp self.ip = getPublicIP(v6) self.port = port self.id = self.makeIdentifier(entropy) self.secret = self.makeSecret(entropy) pubkey = self.pubkey.bytes flags = encodeFlags( (self.v6, self.tcp, False, False, False, False, False, False)) if self.v6: ip = inet_pton(AF_INET6, self.ip) else: #print('v4:', self.ip) ip = inet_pton(AF_INET, self.ip) #print('ip:', ip) ip = fill(ip, IP_LENGTH) port = struct.pack('H', self.port) id = self.id secret = self.secret self.message = pubkey + flags + ip + port + id + secret
from dust.crypto.keys import KeyManager from dust.extensions.multiplex.multiplex_socket import * from dust.core.util import getPublicIP from email.mime.text import MIMEText inport=int(sys.argv[1]) outport=int(sys.argv[2]) ipv=sys.argv[3] if ipv=='4': v6=False else: v6=True passwd=sys.argv[4] host=getPublicIP(v6) dest=host keys=KeyManager() keys.setInvitePassword(passwd) keys.loadKnownHosts('config/knownhosts.yaml') keys.loadKeypair('config/id.yaml') keys.loadIncomingInvites('config/incoming_invites.ip') keys.loadOutgoingInvites('config/outgoing_invites.ip') msock=multiplex_socket(keys) msock.bind((host, inport)) msock.connect((dest, outport)) msock.connectToService('mail') frm=input('From: ')
from dust.server.router import PacketRouter from dust.services.tracker.trackerClient import TrackerClient from dustmail.dustmailClient import DustmailClient passwd = sys.argv[1] inport = int(sys.argv[2]) dest = sys.argv[3] outport = int(sys.argv[4]) ipv = int(sys.argv[5]) if ipv == 6: v6 = True else: v6 = False host = getPublicIP(v6) print('Host: ' + str(host)) keys = KeyManager() keys.setInvitePassword(passwd) keys.loadKnownHosts('config/knownhosts.yaml') keys.loadKeypair('config/id.yaml') keys.loadIncomingInvites('config/incoming_invites.ip') keys.loadOutgoingInvites('config/outgoing_invites.ip') keypair = keys.getKeypair() pubkey = keypair.public destpubkey = pubkey pubkeyhex = encode(pubkey.bytes) destpubkeyhex = pubkeyhex
from dust.invite.invite import InvitePackage from dust.crypto.keys import KeyManager from dust.core.util import getAddress, getPublicIP password=sys.argv[1] port=int(sys.argv[2]) v6=True # defaults to IPv6 if sys.argv[3]=='6': v6=True elif sys.argv[3]=='4': v6=False else: print('Unknown IP version:', sys.argv[2]) print('v6: '+sys.argv[3]+' '+str(v6)) if v6: print('Generating invites for udp://'+getAddress(port)) else: print('Generating invites for udp://'+getPublicIP(False)+':'+str(port)) keys=KeyManager() keys.loadKeypair('config/id.yaml') keypair=keys.getKeypair() pubkey=keypair.public ip=InvitePackage() ip.generate(pubkey, v6, False, port, 5, keys.entropy) ip.save('config/incoming_invites.ip', password, keys.entropy)
import sys import time from dust.crypto.keys import KeyManager from dust.extensions.multiplex.multiplex_socket import * from dust.core.util import getPublicIP, decodeAddress passwd=sys.argv[1] inport=int(sys.argv[2]) addr=sys.argv[3] dest, outport, ipv=decodeAddress(addr) host=getPublicIP(ipv) keys=KeyManager() keys.setInvitePassword(passwd) keys.loadKnownHosts('config/knownhosts.yaml') keys.loadKeypair('config/id.yaml') keys.loadIncomingInvites('config/incoming_invites.ip') keys.loadOutgoingInvites('config/outgoing_invites.ip') msock=multiplex_socket(keys) msock.bind((host, inport)) msock.connect((dest, outport)) msock.connectToService('chat') msg='' while msg!='.': print('>> ', end='') msg=sys.stdin.readline().strip() msock.msend(msg.encode('ascii'))
import sys import time from dust.crypto.keys import KeyManager from dust.extensions.multiplex.multiplex_socket import * from dust.core.util import getPublicIP, decodeAddress passwd = sys.argv[1] inport = int(sys.argv[2]) addr = sys.argv[3] dest, outport, ipv = decodeAddress(addr) host = getPublicIP(ipv) keys = KeyManager() keys.setInvitePassword(passwd) keys.loadKnownHosts('config/knownhosts.yaml') keys.loadKeypair('config/id.yaml') keys.loadIncomingInvites('config/incoming_invites.ip') keys.loadOutgoingInvites('config/outgoing_invites.ip') msock = multiplex_socket(keys) msock.bind((host, inport)) msock.connect((dest, outport)) msock.connectToService('chat') msg = '' while msg != '.': print('>> ', end='') msg = sys.stdin.readline().strip() msock.msend(msg.encode('ascii'))
import sys from dust.core.util import getPublicIP ipv = sys.argv[1] if ipv == '6': print(getPublicIP(True)) elif ipv == '4': print(getPublicIP(False)) else: print('Unknown ip version:', ipv)
import sys from dust.core.util import getPublicIP ipv=sys.argv[1] if ipv=='6': print(getPublicIP(True)) elif ipv=='4': print(getPublicIP(False)) else: print('Unknown ip version:', ipv)