def __init__(self, inq, outq): utp.Callbacks.__init__(self) self.inq = inq self.outq = outq self.doneIn = False self.doneWrite = False self.closed = False self.bufferQueue = Queue() self.buffer = b'' self.connected = False self.connq = Queue() self.udp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.udp_socket.bind(('127.0.0.1', 0)) self.udp_socket.setblocking(0) size = 2 * 1024 * 1024 self.udp_socket.setsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF, size) self.udp_socket.setsockopt(socket.SOL_SOCKET, socket.SO_SNDBUF, size) self.utp_socket = utp.Socket() print("connecting", self.utp_socket) self.dust = lite_socket(KeyManager()) self.dust.setAddress(self.udp_socket.getsockname()) print(self.udp_socket.getsockname()) self.utp_socket.init_outgoing(self.send_to, ("127.0.0.1", 9000)) self.utp_socket.set_callbacks(self) self.utp_socket.connect()
def __init__(self): self.connq = Queue() self.udp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.udp_socket.bind(('127.0.0.1', 9000)) self.udp_socket.setblocking(0) size = 2 * 1024 * 1024 self.udp_socket.setsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF, size) self.udp_socket.setsockopt(socket.SOL_SOCKET, socket.SO_SNDBUF, size) self.dust = lite_socket(KeyManager()) self.dust.setAddress(self.udp_socket.getsockname()) print(self.udp_socket.getsockname()) self.utp_socket = utp.Socket() self.utp_socket.init_outgoing(self.send_to, ("127.0.0.1", 9000)) print("connecting", self.utp_socket, self.utp_socket.getpeername())
class lite_socket(object): def __init__(self, key): self.keys=KeyManager() self.key=key self.cipherIn=DustCipher(key, "\x00") self.cipherOut=DustCipher(key, "\x00") @_o def encrypt(self, data): data=self.cipherOut.encrypt(data) yield Return(data) @_o def decrypt(self, data): data=self.cipherIn.decrypt(data) yield Return(data) def createEphemeralKeypair(self): return self.keys.createKeypair()
def __init__(self, key): self.keys=KeyManager() self.key=key self.cipherIn=DustCipher(key, "\x00") self.cipherOut=DustCipher(key, "\x00")
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: ') to=input('To: ') subject=input('Subject: ')
from dust.server.router import PacketRouter from dust.crypto.keys import KeyManager from dust.core.util import getPublicIP, encodeAddress, decodeAddress, encode from dust.util.ymap import YamlMap from dust.util.safethread import wait from dust.services.tracker.trackerClient import TrackerClient inport=int(sys.argv[1]) v6=sys.argv[2] passwd=sys.argv[3] trackerAddr=decodeAddress(sys.argv[4]) host=getPublicIP(v6) keys=KeyManager() keys.setInvitePassword(passwd) try: keys.loadKeypair('config/id.yaml') except: print('Generating server keypair...') keys.createKeypair() keys.saveKeypair('config/id.yaml') keys.loadKnownHosts('config/knownhosts.yaml') keys.loadIncomingInvites('config/incoming_invites.ip') keys.loadOutgoingInvites('config/outgoing_invites.ip') router=PacketRouter(v6, inport, keys, passwd) router.connect(trackerAddr[0], trackerAddr[1])
from dust.intro.intro_socket import * from dust.crypto.keys import KeyManager from dust.core.util import getPublicIP passwd=sys.argv[1] ipv=sys.argv[2] if ipv=='4': v6=False else: v6=True host=getPublicIP(v6) dest=getPublicIP(v6) buffsize=102400 inport=8001 outport=7000 nodeName='A' keys=KeyManager() keys.loadKeypair('config/id.yaml') keypair=keys.getKeypair() keys.setInvitePassword(passwd) keys.loadOutgoingInvites('config/outgoing_invites.ip') invite=keys.outgoingInvites.getInviteForHost(False, (dest, outport)) isock=intro_socket(keys) isock.bind((host, inport)) isock.iconnect(invite) isock.isend()
from dust.crypto.keys import KeyManager from dust.core.data_packet import DataPacket from dust.core.util import encode, decode keys=KeyManager() #psk=keys.entropy.getBytes(32) psk=decode("5475e69147a1463ef65116ccd8b3d732ead5ce8b5c9b0e61eb4c218fe6165013") packet=DataPacket() packet.createDataPacket(psk, b"test #3", keys.entropy) print('packet:', packet) print('packetData:', encode(packet.packet)) print('------------------------') p2=DataPacket() p2.decodeDataPacket(psk, packet.packet) print(p2) print('checkMac:', p2.checkMac()) print('checkTimestamp:', p2.checkTimestamp())
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)
from dust.services.tracker.trackerClient import TrackerClient from dust.services.dustmail.dustmailClient import DustmailClient from dust.invite.invite_packet import InviteMessage from dust.services.dustmail.dustmail_packet import DustmailInvitePacket passwd=sys.argv[1] inport=int(sys.argv[2]) destAddress=sys.argv[3] dest, outport, v6=decodeAddress(destAddress) ipasswd=sys.argv[4] 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') endpoint=keys.loadEndpoint(os.path.expanduser('~/.dust/endpoint.yaml')) keypair=keys.getKeypair() pubkey=keypair.public pubkeyhex=encode(pubkey.bytes) done=Event() def gotInvite(invite): ps=input("Print or Save [P/s]?")
passwd = sys.argv[2] headless = True else: passwd = input("Password: ") headless = False dustmailConfig = YamlMap('config/dustmail-config.yaml') try: inport = int(dustmailConfig['port']) except: inport = randomPort() dustmailConfig['port'] = inport print('Loading keys...') keys = KeyManager() keys.setInvitePassword(passwd) keys.loadKnownHosts('config/knownhosts.yaml') try: keys.loadKeypair('config/id.yaml') except: print('Generating server keypair...') keys.createKeypair() keys.saveKeypair('config/id.yaml') keys.loadIncomingInvites('config/incoming_invites.ip') keys.loadOutgoingInvites('config/outgoing_invites.ip') try: endpoint = keys.loadEndpoint(
#!/usr/bin/python import os import sys # python sucks sys.path.insert( 0, os.path.realpath(os.path.join(os.path.dirname(__file__), ".."))) from dust.crypto.keys import KeyManager keys = KeyManager() keys.createKeypair() dustdir = os.path.expanduser("~/.dust") if not os.path.exists(dustdir): os.mkdir(dustdir) keys.saveKeypair(dustdir + '/endpoint.yaml')
#!/usr/bin/python import os import sys # python sucks sys.path.insert(0, os.path.realpath(os.path.join(os.path.dirname(__file__), ".."))) from dust.crypto.keys import KeyManager keys=KeyManager() keys.createKeypair() dustdir=os.path.expanduser("~/.dust") if not os.path.exists(dustdir): os.mkdir(dustdir) keys.saveKeypair(dustdir+'/endpoint.yaml')
import sys from dust.crypto.keys import KeyManager mypasswd=sys.argv[1] keys=KeyManager() keys.setInvitePassword(mypasswd) print('Outgoing:') keys.loadOutgoingInvites('config/outgoing_invites.ip') print(keys.outgoingInvites) print("\n------------------\n") print('Incoming:') keys.loadIncomingInvites('config/incoming_invites.ip') print(keys.incomingInvites)
from dust.server.router import PacketRouter from dust.crypto.keys import KeyManager from dust.core.util import getPublicIP, encodeAddress, decodeAddress, encode from dust.util.ymap import YamlMap from dust.util.safethread import wait from dust.services.tracker.trackerClient import TrackerClient inport = int(sys.argv[1]) v6 = sys.argv[2] passwd = sys.argv[3] trackerAddr = decodeAddress(sys.argv[4]) host = getPublicIP(v6) keys = KeyManager() keys.setInvitePassword(passwd) try: keys.loadKeypair('config/id.yaml') except: print('Generating server keypair...') keys.createKeypair() keys.saveKeypair('config/id.yaml') keys.loadKnownHosts('config/knownhosts.yaml') keys.loadIncomingInvites('config/incoming_invites.ip') keys.loadOutgoingInvites('config/outgoing_invites.ip') router = PacketRouter(v6, inport, keys, passwd) router.connect(trackerAddr[0], trackerAddr[1])
import sys from dust.crypto.keys import KeyManager passwd = sys.argv[1] mypasswd = sys.argv[2] keys = KeyManager() keys.setInvitePassword(mypasswd) keys.loadOutgoingInvites('config/outgoing_invites.ip') keys.loadIncomingInvites('config/incoming_invites.ip', passwd) keys.outgoingInvites.merge(keys.incomingInvites) keys.saveOutgoingInvites('config/outgoing_invites.ip', mypasswd)
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 router = PacketRouter(v6, inport, keys, passwd) router.connect(dest, outport)
#!/usr/bin/python3.1 import os import sys # python sucks sys.path.insert(0, os.path.realpath(os.path.join(os.path.dirname(__file__), ".."))) from dust.crypto.keys import KeyManager keys=KeyManager() keys.createKeypair() keys.saveKeypair('config/id.yaml')
#!/usr/bin/python3.1 import os import sys # python sucks sys.path.insert( 0, os.path.realpath(os.path.join(os.path.dirname(__file__), ".."))) from dust.crypto.keys import KeyManager keys = KeyManager() keys.createKeypair() keys.saveKeypair('config/id.yaml')