Merge pull request #1 from Atheros1/master
Populate project with initial files
This commit is contained in:
commit
899796691d
COPYINGabout.pyabout.uiaddresses.pybitmessage_icons.qrcbitmessage_icons_rc.pybitmessagemain.pybitmessageui.pybitmessageui.uidefaultKnownNodes.pyhelp.pyhelp.uiiconglossary.pyiconglossary.uinewaddressdialog.pynewaddressdialog.uinewsubscriptiondialog.pynewsubscriptiondialog.ui
rsa
__init__.py__init__.pyc_compat.py_compat.pyc_version133.py_version200.pybigfile.pybigfile.pyccli.pycommon.pycommon.pyccore.pycore.pyckey.pykey.pycparallel.pyparallel.pycpem.pypem.pycpkcs1.pypkcs1.pycprime.pyprime.pycrandnum.pyrandnum.pyctransform.pytransform.pycutil.pyvarblock.pyvarblock.pyc
settings.pysettings.ui
19
COPYING
Normal file
19
COPYING
Normal file
|
@ -0,0 +1,19 @@
|
|||
Copyright (c) 2012 Jonathan Warren
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
67
about.py
Normal file
67
about.py
Normal file
|
@ -0,0 +1,67 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Form implementation generated from reading ui file 'about.ui'
|
||||
#
|
||||
# Created: Mon Nov 19 13:33:47 2012
|
||||
# by: PyQt4 UI code generator 4.9.4
|
||||
#
|
||||
# WARNING! All changes made in this file will be lost!
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
try:
|
||||
_fromUtf8 = QtCore.QString.fromUtf8
|
||||
except AttributeError:
|
||||
_fromUtf8 = lambda s: s
|
||||
|
||||
class Ui_aboutDialog(object):
|
||||
def setupUi(self, aboutDialog):
|
||||
aboutDialog.setObjectName(_fromUtf8("aboutDialog"))
|
||||
aboutDialog.resize(360, 402)
|
||||
self.buttonBox = QtGui.QDialogButtonBox(aboutDialog)
|
||||
self.buttonBox.setGeometry(QtCore.QRect(20, 360, 311, 32))
|
||||
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
|
||||
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok)
|
||||
self.buttonBox.setObjectName(_fromUtf8("buttonBox"))
|
||||
self.label = QtGui.QLabel(aboutDialog)
|
||||
self.label.setGeometry(QtCore.QRect(70, 126, 111, 20))
|
||||
font = QtGui.QFont()
|
||||
font.setBold(True)
|
||||
font.setWeight(75)
|
||||
self.label.setFont(font)
|
||||
self.label.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
|
||||
self.label.setObjectName(_fromUtf8("label"))
|
||||
self.labelVersion = QtGui.QLabel(aboutDialog)
|
||||
self.labelVersion.setGeometry(QtCore.QRect(190, 126, 161, 20))
|
||||
self.labelVersion.setObjectName(_fromUtf8("labelVersion"))
|
||||
self.label_2 = QtGui.QLabel(aboutDialog)
|
||||
self.label_2.setGeometry(QtCore.QRect(10, 150, 341, 20))
|
||||
self.label_2.setAlignment(QtCore.Qt.AlignCenter)
|
||||
self.label_2.setObjectName(_fromUtf8("label_2"))
|
||||
self.label_3 = QtGui.QLabel(aboutDialog)
|
||||
self.label_3.setGeometry(QtCore.QRect(30, 210, 321, 51))
|
||||
self.label_3.setWordWrap(True)
|
||||
self.label_3.setObjectName(_fromUtf8("label_3"))
|
||||
self.label_4 = QtGui.QLabel(aboutDialog)
|
||||
self.label_4.setGeometry(QtCore.QRect(30, 260, 321, 101))
|
||||
self.label_4.setWordWrap(True)
|
||||
self.label_4.setObjectName(_fromUtf8("label_4"))
|
||||
self.label_5 = QtGui.QLabel(aboutDialog)
|
||||
self.label_5.setGeometry(QtCore.QRect(10, 180, 341, 20))
|
||||
self.label_5.setAlignment(QtCore.Qt.AlignCenter)
|
||||
self.label_5.setObjectName(_fromUtf8("label_5"))
|
||||
|
||||
self.retranslateUi(aboutDialog)
|
||||
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), aboutDialog.accept)
|
||||
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), aboutDialog.reject)
|
||||
QtCore.QMetaObject.connectSlotsByName(aboutDialog)
|
||||
|
||||
def retranslateUi(self, aboutDialog):
|
||||
aboutDialog.setWindowTitle(QtGui.QApplication.translate("aboutDialog", "About", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.label.setText(QtGui.QApplication.translate("aboutDialog", "PyBitmessage", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.labelVersion.setText(QtGui.QApplication.translate("aboutDialog", "version ?", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.label_2.setText(QtGui.QApplication.translate("aboutDialog", "Copyright © 2012 Jonathan Warren", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.label_3.setText(QtGui.QApplication.translate("aboutDialog", "Distributed under the MIT/X11 software license, see the accompanying file license.txt or http://www.opensource.org/licenses/mit-license.php", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.label_4.setText(QtGui.QApplication.translate("aboutDialog", "This product includes Python-RSA (http://stuvel.eu/rsa) originally written by Sybren A. Stüvel <sybren@stuvel.eu>. It is licensed under the Apache 2.0 license: http://www.apache.org/licenses/LICENSE-2.0", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.label_5.setText(QtGui.QApplication.translate("aboutDialog", "This is Beta software.", None, QtGui.QApplication.UnicodeUTF8))
|
||||
|
167
about.ui
Normal file
167
about.ui
Normal file
|
@ -0,0 +1,167 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>aboutDialog</class>
|
||||
<widget class="QDialog" name="aboutDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>360</width>
|
||||
<height>402</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>About</string>
|
||||
</property>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>360</y>
|
||||
<width>311</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>70</x>
|
||||
<y>126</y>
|
||||
<width>111</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PyBitmessage</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="labelVersion">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>190</x>
|
||||
<y>126</y>
|
||||
<width>161</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>version ?</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>150</y>
|
||||
<width>341</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Copyright © 2012 Jonathan Warren</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>210</y>
|
||||
<width>321</width>
|
||||
<height>51</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Distributed under the MIT/X11 software license, see the accompanying file license.txt or http://www.opensource.org/licenses/mit-license.php</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>260</y>
|
||||
<width>321</width>
|
||||
<height>101</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>This product includes Python-RSA (http://stuvel.eu/rsa) originally written by Sybren A. Stüvel <sybren@stuvel.eu>. It is licensed under the Apache 2.0 license: http://www.apache.org/licenses/LICENSE-2.0</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>180</y>
|
||||
<width>341</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>This is Beta software.</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>aboutDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>aboutDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
265
addresses.py
Normal file
265
addresses.py
Normal file
|
@ -0,0 +1,265 @@
|
|||
import rsa
|
||||
import hashlib
|
||||
from struct import *
|
||||
|
||||
#There is another copy of this function in Bitmessagemain.py
|
||||
def convertIntToString(n):
|
||||
a = __builtins__.hex(n)
|
||||
if a[-1:] == 'L':
|
||||
a = a[:-1]
|
||||
if (len(a) % 2) == 0:
|
||||
return a[2:].decode('hex')
|
||||
else:
|
||||
return ('0'+a[2:]).decode('hex')
|
||||
|
||||
ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
|
||||
|
||||
def encodeBase58(num, alphabet=ALPHABET):
|
||||
"""Encode a number in Base X
|
||||
|
||||
`num`: The number to encode
|
||||
`alphabet`: The alphabet to use for encoding
|
||||
"""
|
||||
if (num == 0):
|
||||
return alphabet[0]
|
||||
arr = []
|
||||
base = len(alphabet)
|
||||
while num:
|
||||
rem = num % base
|
||||
#print 'num is:', num
|
||||
num = num // base
|
||||
arr.append(alphabet[rem])
|
||||
arr.reverse()
|
||||
return ''.join(arr)
|
||||
|
||||
def decodeBase58(string, alphabet=ALPHABET):
|
||||
"""Decode a Base X encoded string into the number
|
||||
|
||||
Arguments:
|
||||
- `string`: The encoded string
|
||||
- `alphabet`: The alphabet to use for encoding
|
||||
"""
|
||||
base = len(alphabet)
|
||||
strlen = len(string)
|
||||
num = 0
|
||||
|
||||
try:
|
||||
power = strlen - 1
|
||||
for char in string:
|
||||
num += alphabet.index(char) * (base ** power)
|
||||
power -= 1
|
||||
except:
|
||||
#character not found (like a space character or a 0)
|
||||
return 0
|
||||
return num
|
||||
|
||||
def encodeVarint(integer):
|
||||
if integer < 0:
|
||||
print 'varint cannot be < 0'
|
||||
raise SystemExit
|
||||
if integer < 253:
|
||||
return pack('>B',integer)
|
||||
if integer >= 253 and integer < 65536:
|
||||
return pack('>B',253) + pack('>H',integer)
|
||||
if integer >= 65536 and integer < 4294967296:
|
||||
return pack('>B',254) + pack('>I',integer)
|
||||
if integer >= 4294967296 and integer < 18446744073709551616:
|
||||
return pack('>B',255) + pack('>Q',integer)
|
||||
if integer >= 18446744073709551616:
|
||||
print 'varint cannot be >= 18446744073709551616'
|
||||
raise SystemExit
|
||||
|
||||
def decodeVarint(data):
|
||||
if len(data) == 0:
|
||||
return (0,0)
|
||||
firstByte, = unpack('>B',data[0:1])
|
||||
if firstByte < 253:
|
||||
return (firstByte,1) #the 1 is the length of the varint
|
||||
if firstByte == 253:
|
||||
a, = unpack('>H',data[1:3])
|
||||
return (a,3)
|
||||
if firstByte == 254:
|
||||
a, = unpack('>I',data[1:5])
|
||||
return (a,5)
|
||||
if firstByte == 255:
|
||||
a, = unpack('>Q',data[1:9])
|
||||
return (a,9)
|
||||
|
||||
|
||||
|
||||
def calculateInventoryHash(data):
|
||||
sha = hashlib.new('sha512')
|
||||
sha2 = hashlib.new('sha512')
|
||||
sha.update(data)
|
||||
sha2.update(sha.digest())
|
||||
return sha2.digest()[0:32]
|
||||
|
||||
def encodeAddress(version,stream,ripe):
|
||||
a = encodeVarint(version) + encodeVarint(stream) + ripe
|
||||
sha = hashlib.new('sha512')
|
||||
sha.update(a)
|
||||
currentHash = sha.digest()
|
||||
#print 'sha after first hashing: ', sha.hexdigest()
|
||||
sha = hashlib.new('sha512')
|
||||
sha.update(currentHash)
|
||||
#print 'sha after second hashing: ', sha.hexdigest()
|
||||
|
||||
checksum = sha.digest()[0:4]
|
||||
#print 'len(a) = ', len(a)
|
||||
#print 'checksum = ', checksum.encode('hex')
|
||||
#print 'len(checksum) = ', len(checksum)
|
||||
|
||||
asInt = int(a.encode('hex') + checksum.encode('hex'),16)
|
||||
#asInt = int(checksum.encode('hex') + a.encode('hex'),16)
|
||||
# print asInt
|
||||
return 'BM-'+ encodeBase58(asInt)
|
||||
|
||||
def decodeAddress(address):
|
||||
#returns (status, address version number, stream number, data (almost certainly a ripe hash))
|
||||
|
||||
#check for the BM- at the front of the address. If it isn't there, this address might be for a different version of Bitmessage
|
||||
if address[:3] != 'BM-':
|
||||
status = 'missingbm'
|
||||
return status,0,0,0
|
||||
#take off the BM-
|
||||
integer = decodeBase58(address[3:])
|
||||
if integer == 0:
|
||||
status = 'invalidcharacters'
|
||||
return status,0,0,0
|
||||
#after converting to hex, the string will be prepended with a 0x and appended with a L
|
||||
hexdata = hex(integer)[2:-1]
|
||||
|
||||
if len(hexdata) % 2 != 0:
|
||||
hexdata = '0' + hexdata
|
||||
|
||||
#print 'hexdata', hexdata
|
||||
|
||||
data = hexdata.decode('hex')
|
||||
checksum = data[-4:]
|
||||
|
||||
sha = hashlib.new('sha512')
|
||||
sha.update(data[:-4])
|
||||
currentHash = sha.digest()
|
||||
#print 'sha after first hashing: ', sha.hexdigest()
|
||||
sha = hashlib.new('sha512')
|
||||
sha.update(currentHash)
|
||||
#print 'sha after second hashing: ', sha.hexdigest()
|
||||
|
||||
if checksum != sha.digest()[0:4]:
|
||||
print 'checksum failed'
|
||||
status = 'checksumfailed'
|
||||
return status,0,0,0
|
||||
#else:
|
||||
# print 'checksum PASSED'
|
||||
|
||||
addressVersionNumber, bytesUsedByVersionNumber = decodeVarint(data[:9])
|
||||
#print 'addressVersionNumber', addressVersionNumber
|
||||
#print 'bytesUsedByVersionNumber', bytesUsedByVersionNumber
|
||||
|
||||
if addressVersionNumber < 1:
|
||||
print 'cannot decode version address version numbers this high'
|
||||
status = 'versiontoohigh'
|
||||
return status,0,0,0
|
||||
|
||||
streamNumber, bytesUsedByStreamNumber = decodeVarint(data[bytesUsedByVersionNumber:10+bytesUsedByVersionNumber])
|
||||
#print streamNumber
|
||||
status = 'success'
|
||||
return status,addressVersionNumber,streamNumber,data[-24:-4]
|
||||
|
||||
|
||||
def addressStream(address):
|
||||
#returns the stream number of an address or False if there is a problem with the address.
|
||||
|
||||
#check for the BM- at the front of the address. If it isn't there, this address might be for a different version of Bitmessage
|
||||
if address[:3] != 'BM-':
|
||||
status = 'missingbm'
|
||||
return False
|
||||
#here we take off the BM-
|
||||
integer = decodeBase58(address[3:])
|
||||
#after converting to hex, the string will be prepended with a 0x and appended with a L
|
||||
hexdata = hex(integer)[2:-1]
|
||||
|
||||
if len(hexdata) % 2 != 0:
|
||||
hexdata = '0' + hexdata
|
||||
|
||||
#print 'hexdata', hexdata
|
||||
|
||||
data = hexdata.decode('hex')
|
||||
checksum = data[-4:]
|
||||
|
||||
sha = hashlib.new('sha512')
|
||||
sha.update(data[:-4])
|
||||
currentHash = sha.digest()
|
||||
#print 'sha after first hashing: ', sha.hexdigest()
|
||||
sha = hashlib.new('sha512')
|
||||
sha.update(currentHash)
|
||||
#print 'sha after second hashing: ', sha.hexdigest()
|
||||
|
||||
if checksum != sha.digest()[0:4]:
|
||||
print 'checksum failed'
|
||||
status = 'checksumfailed'
|
||||
return False
|
||||
#else:
|
||||
# print 'checksum PASSED'
|
||||
|
||||
addressVersionNumber, bytesUsedByVersionNumber = decodeVarint(data[:9])
|
||||
#print 'addressVersionNumber', addressVersionNumber
|
||||
#print 'bytesUsedByVersionNumber', bytesUsedByVersionNumber
|
||||
|
||||
if addressVersionNumber < 1:
|
||||
print 'cannot decode version address version numbers this high'
|
||||
status = 'versiontoohigh'
|
||||
return False
|
||||
|
||||
streamNumber, bytesUsedByStreamNumber = decodeVarint(data[bytesUsedByVersionNumber:9+bytesUsedByVersionNumber])
|
||||
#print streamNumber
|
||||
status = 'success'
|
||||
return streamNumber
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
#Let's make a new Bitmessage address:
|
||||
(pubkey, privkey) = rsa.newkeys(256)
|
||||
print privkey['n']
|
||||
print privkey['e']
|
||||
print privkey['d']
|
||||
print privkey['p']
|
||||
print privkey['q']
|
||||
|
||||
ripe = hashlib.new('ripemd160')
|
||||
sha = hashlib.new('sha512')
|
||||
sha.update(convertIntToString(pubkey.n)+convertIntToString(pubkey.e))
|
||||
|
||||
ripe.update(sha.digest())
|
||||
#print 'sha digest:', sha.digest()
|
||||
#print 'ripe digest:', ripe.digest()
|
||||
#print len(sha.digest())
|
||||
#print len(ripe.digest())
|
||||
|
||||
#prepend the version number and stream number
|
||||
a = '\x05' + '\x08' + ripe.digest()
|
||||
#print 'lengh of a at beginning = ', len(a)
|
||||
print 'This is the data to be encoded in the address: ', a.encode('hex')
|
||||
|
||||
returnedAddress = encodeAddress(5,8,ripe.digest())
|
||||
status,addressVersionNumber,streamNumber,data = decodeAddress(returnedAddress)
|
||||
print returnedAddress
|
||||
print 'Status:', status
|
||||
print 'addressVersionNumber', addressVersionNumber
|
||||
print 'streamNumber', streamNumber
|
||||
print 'length of data(the ripe hash):', len(data)
|
||||
|
||||
print '\n\nNow let us try making an address with given 2048-bit n and e values.'
|
||||
testn = 16691381808213609635656612695328489234826227577985206736118595570304213887605602327717776979169783795560145663031146864154748634207927153095849203939039346778471192284119479329875655789428795925773927040539038073349089996911318012189546542694411685389074592231210678771416758973061752125295462189928432307067746658691146428088703129795340914596189054255127032271420140641112277113597275245807890920656563056790943850440012709593297328230145129809419550219898595770524436575484115680960823105256137731976622290028349172297572826751147335728017861413787053794003722218722212196385625462088929496952843002425059308041193
|
||||
teste = 65537
|
||||
ripe = hashlib.new('ripemd160')
|
||||
sha = hashlib.new('sha512')
|
||||
sha.update(convertIntToString(testn)+convertIntToString(teste))
|
||||
ripe.update(sha.digest())
|
||||
encodedAddress = encodeAddress(1,1,ripe.digest())
|
||||
print encodedAddress
|
||||
status,addressVersionNumber,streamNumber,data = decodeAddress(encodedAddress)
|
||||
print 'Status:', status
|
||||
print 'addressVersionNumber', addressVersionNumber
|
||||
print 'streamNumber', streamNumber
|
||||
print 'length of data(the ripe hash):', len(data)
|
15
bitmessage_icons.qrc
Normal file
15
bitmessage_icons.qrc
Normal file
|
@ -0,0 +1,15 @@
|
|||
<RCC>
|
||||
<qresource prefix="newPrefix">
|
||||
<file>images/greenicon.png</file>
|
||||
<file>images/redicon.png</file>
|
||||
<file>images/yellowicon.png</file>
|
||||
<file>images/addressbook.png</file>
|
||||
<file>images/blacklist.png</file>
|
||||
<file>images/identities.png</file>
|
||||
<file>images/networkstatus.png</file>
|
||||
<file>images/sent.png</file>
|
||||
<file>images/subscriptions.png</file>
|
||||
<file>images/send.png</file>
|
||||
<file>images/inbox.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
1095
bitmessage_icons_rc.py
Normal file
1095
bitmessage_icons_rc.py
Normal file
|
@ -0,0 +1,1095 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Resource object code
|
||||
#
|
||||
# Created: Fri Nov 2 17:44:30 2012
|
||||
# by: The Resource Compiler for PyQt (Qt v4.8.3)
|
||||
#
|
||||
# WARNING! All changes made in this file will be lost!
|
||||
|
||||
from PyQt4 import QtCore
|
||||
|
||||
qt_resource_data = "\
|
||||
\x00\x00\x02\x24\
|
||||
\x89\
|
||||
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
|
||||
\x00\x00\x10\x00\x00\x00\x10\x08\x06\x00\x00\x00\x1f\xf3\xff\x61\
|
||||
\x00\x00\x00\x19\x74\x45\x58\x74\x53\x6f\x66\x74\x77\x61\x72\x65\
|
||||
\x00\x41\x64\x6f\x62\x65\x20\x49\x6d\x61\x67\x65\x52\x65\x61\x64\
|
||||
\x79\x71\xc9\x65\x3c\x00\x00\x01\xc6\x49\x44\x41\x54\x78\xda\x8c\
|
||||
\x53\x3d\x4b\x03\x41\x10\x7d\xd9\x3b\xf5\x44\x45\x8b\x44\x34\xa2\
|
||||
\xc4\x42\x49\x2b\xe8\xcf\xb0\xf3\x07\x28\xd6\x82\x9d\x20\x58\x88\
|
||||
\x0a\x36\x82\x8d\x95\xa0\x58\x0b\x16\xda\x8b\xd8\x08\x09\x44\x0b\
|
||||
\x8b\x54\x22\x7e\x44\x10\x41\x42\xce\xe4\x2e\xb7\x1f\xce\x9c\xe6\
|
||||
\xcb\x5c\xc0\xe5\x06\x6e\xdf\xbe\xf7\x66\x76\x76\x37\x96\xdd\x05\
|
||||
\x62\xc0\x12\x80\x14\xfe\x3f\x1e\x0d\x70\x3c\xbb\x66\x60\x1b\xfa\
|
||||
\xa3\x6f\x72\x6e\xf5\x62\x03\x5a\x03\x4a\x75\x96\x59\x16\x20\x04\
|
||||
\xb2\xfb\xf3\x5b\x35\x48\x84\x06\x06\xe2\x25\x93\x01\x1b\x18\x29\
|
||||
\x61\xaa\x7e\x7b\x10\xce\xeb\xcc\x63\x3e\xeb\x42\x03\xc5\x49\x35\
|
||||
\x44\x6f\x3c\x8e\xfb\xcb\x4b\xca\x22\x60\x44\x7b\x30\xce\xeb\xcc\
|
||||
\x63\x3e\xeb\x78\xd8\xfa\xc7\xc9\x1a\x1a\x4e\xa0\xe2\x96\x70\x73\
|
||||
\x7e\x51\xaf\xd8\xf3\x3c\x38\x8e\x53\x9f\x4f\x4c\x4f\x81\x79\xa4\
|
||||
\xb1\x6a\x98\xfd\xeb\x24\x0c\xed\x7d\x38\x39\x1a\x46\x08\x74\x75\
|
||||
\xe3\x29\x9f\xc7\x44\x3a\x0d\x1d\x54\xeb\x26\xcc\xe3\x0a\xfe\x1a\
|
||||
\x58\x5a\x05\x50\x32\x68\x34\x4c\xc4\x30\xd0\xd7\x87\x28\x9c\x34\
|
||||
\x56\xbb\x81\x54\xd0\xdc\xa8\xdf\x11\x13\x16\x1d\x08\x63\x11\x78\
|
||||
\x94\x81\x51\x92\xb2\x35\x88\x42\x59\x90\x94\x39\x0a\xef\x50\x41\
|
||||
\x00\xdd\x54\xaa\x1f\x28\x2c\xf6\x6c\xa2\xfa\xa6\xa8\x99\x92\x22\
|
||||
\x80\xef\x2b\x64\xa6\x8f\x5a\x0d\xa4\xaa\x19\x48\xda\x6b\x23\x53\
|
||||
\xd9\xf5\x70\x32\x53\x6e\xba\x45\x22\x0c\xf7\xae\x04\xd2\x44\x54\
|
||||
\x10\x96\xda\xa8\xc0\xfd\x2c\xc2\xae\x54\x90\xcb\xe5\x90\x48\x24\
|
||||
\xc2\x7e\xa4\x52\x29\xe8\x62\xa9\x53\x0f\xa8\x59\x4d\xd7\xd8\x25\
|
||||
\x62\x77\xb9\x8c\x34\x1d\x63\xbd\x2a\x9a\xeb\xd2\x57\xab\xc1\xdd\
|
||||
\x23\x90\x4e\xc2\x79\x79\x7a\xa5\x9b\xaa\x9a\x7a\xe0\xe3\xe3\x74\
|
||||
\xa5\xed\x39\x0c\xc6\x87\xe0\x55\xe1\xe4\x0b\xc0\x02\x1b\xec\x9c\
|
||||
\x61\xf0\x60\x19\xfd\xe3\xe3\xc9\xd6\xf3\x1e\x1b\x89\x7e\x4f\x76\
|
||||
\x17\x6e\xaf\xd1\xcf\xba\x6d\xa0\x68\xb3\xe9\xfd\x33\x0a\x87\x7b\
|
||||
\xeb\x57\xff\x7d\xcb\x0f\xef\x28\xb0\x8e\xa2\xf8\x2d\xc0\x00\x14\
|
||||
\x2c\x1a\x71\xde\xeb\xd2\x54\x00\x00\x00\x00\x49\x45\x4e\x44\xae\
|
||||
\x42\x60\x82\
|
||||
\x00\x00\x0c\xdd\
|
||||
\x89\
|
||||
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
|
||||
\x00\x00\x10\x00\x00\x00\x10\x08\x06\x00\x00\x00\x1f\xf3\xff\x61\
|
||||
\x00\x00\x00\x09\x70\x48\x59\x73\x00\x00\x0b\x13\x00\x00\x0b\x13\
|
||||
\x01\x00\x9a\x9c\x18\x00\x00\x0a\x4f\x69\x43\x43\x50\x50\x68\x6f\
|
||||
\x74\x6f\x73\x68\x6f\x70\x20\x49\x43\x43\x20\x70\x72\x6f\x66\x69\
|
||||
\x6c\x65\x00\x00\x78\xda\x9d\x53\x67\x54\x53\xe9\x16\x3d\xf7\xde\
|
||||
\xf4\x42\x4b\x88\x80\x94\x4b\x6f\x52\x15\x08\x20\x52\x42\x8b\x80\
|
||||
\x14\x91\x26\x2a\x21\x09\x10\x4a\x88\x21\xa1\xd9\x15\x51\xc1\x11\
|
||||
\x45\x45\x04\x1b\xc8\xa0\x88\x03\x8e\x8e\x80\x8c\x15\x51\x2c\x0c\
|
||||
\x8a\x0a\xd8\x07\xe4\x21\xa2\x8e\x83\xa3\x88\x8a\xca\xfb\xe1\x7b\
|
||||
\xa3\x6b\xd6\xbc\xf7\xe6\xcd\xfe\xb5\xd7\x3e\xe7\xac\xf3\x9d\xb3\
|
||||
\xcf\x07\xc0\x08\x0c\x96\x48\x33\x51\x35\x80\x0c\xa9\x42\x1e\x11\
|
||||
\xe0\x83\xc7\xc4\xc6\xe1\xe4\x2e\x40\x81\x0a\x24\x70\x00\x10\x08\
|
||||
\xb3\x64\x21\x73\xfd\x23\x01\x00\xf8\x7e\x3c\x3c\x2b\x22\xc0\x07\
|
||||
\xbe\x00\x01\x78\xd3\x0b\x08\x00\xc0\x4d\x9b\xc0\x30\x1c\x87\xff\
|
||||
\x0f\xea\x42\x99\x5c\x01\x80\x84\x01\xc0\x74\x91\x38\x4b\x08\x80\
|
||||
\x14\x00\x40\x7a\x8e\x42\xa6\x00\x40\x46\x01\x80\x9d\x98\x26\x53\
|
||||
\x00\xa0\x04\x00\x60\xcb\x63\x62\xe3\x00\x50\x2d\x00\x60\x27\x7f\
|
||||
\xe6\xd3\x00\x80\x9d\xf8\x99\x7b\x01\x00\x5b\x94\x21\x15\x01\xa0\
|
||||
\x91\x00\x20\x13\x65\x88\x44\x00\x68\x3b\x00\xac\xcf\x56\x8a\x45\
|
||||
\x00\x58\x30\x00\x14\x66\x4b\xc4\x39\x00\xd8\x2d\x00\x30\x49\x57\
|
||||
\x66\x48\x00\xb0\xb7\x00\xc0\xce\x10\x0b\xb2\x00\x08\x0c\x00\x30\
|
||||
\x51\x88\x85\x29\x00\x04\x7b\x00\x60\xc8\x23\x23\x78\x00\x84\x99\
|
||||
\x00\x14\x46\xf2\x57\x3c\xf1\x2b\xae\x10\xe7\x2a\x00\x00\x78\x99\
|
||||
\xb2\x3c\xb9\x24\x39\x45\x81\x5b\x08\x2d\x71\x07\x57\x57\x2e\x1e\
|
||||
\x28\xce\x49\x17\x2b\x14\x36\x61\x02\x61\x9a\x40\x2e\xc2\x79\x99\
|
||||
\x19\x32\x81\x34\x0f\xe0\xf3\xcc\x00\x00\xa0\x91\x15\x11\xe0\x83\
|
||||
\xf3\xfd\x78\xce\x0e\xae\xce\xce\x36\x8e\xb6\x0e\x5f\x2d\xea\xbf\
|
||||
\x06\xff\x22\x62\x62\xe3\xfe\xe5\xcf\xab\x70\x40\x00\x00\xe1\x74\
|
||||
\x7e\xd1\xfe\x2c\x2f\xb3\x1a\x80\x3b\x06\x80\x6d\xfe\xa2\x25\xee\
|
||||
\x04\x68\x5e\x0b\xa0\x75\xf7\x8b\x66\xb2\x0f\x40\xb5\x00\xa0\xe9\
|
||||
\xda\x57\xf3\x70\xf8\x7e\x3c\x3c\x45\xa1\x90\xb9\xd9\xd9\xe5\xe4\
|
||||
\xe4\xd8\x4a\xc4\x42\x5b\x61\xca\x57\x7d\xfe\x67\xc2\x5f\xc0\x57\
|
||||
\xfd\x6c\xf9\x7e\x3c\xfc\xf7\xf5\xe0\xbe\xe2\x24\x81\x32\x5d\x81\
|
||||
\x47\x04\xf8\xe0\xc2\xcc\xf4\x4c\xa5\x1c\xcf\x92\x09\x84\x62\xdc\
|
||||
\xe6\x8f\x47\xfc\xb7\x0b\xff\xfc\x1d\xd3\x22\xc4\x49\x62\xb9\x58\
|
||||
\x2a\x14\xe3\x51\x12\x71\x8e\x44\x9a\x8c\xf3\x32\xa5\x22\x89\x42\
|
||||
\x92\x29\xc5\x25\xd2\xff\x64\xe2\xdf\x2c\xfb\x03\x3e\xdf\x35\x00\
|
||||
\xb0\x6a\x3e\x01\x7b\x91\x2d\xa8\x5d\x63\x03\xf6\x4b\x27\x10\x58\
|
||||
\x74\xc0\xe2\xf7\x00\x00\xf2\xbb\x6f\xc1\xd4\x28\x08\x03\x80\x68\
|
||||
\x83\xe1\xcf\x77\xff\xef\x3f\xfd\x47\xa0\x25\x00\x80\x66\x49\x92\
|
||||
\x71\x00\x00\x5e\x44\x24\x2e\x54\xca\xb3\x3f\xc7\x08\x00\x00\x44\
|
||||
\xa0\x81\x2a\xb0\x41\x1b\xf4\xc1\x18\x2c\xc0\x06\x1c\xc1\x05\xdc\
|
||||
\xc1\x0b\xfc\x60\x36\x84\x42\x24\xc4\xc2\x42\x10\x42\x0a\x64\x80\
|
||||
\x1c\x72\x60\x29\xac\x82\x42\x28\x86\xcd\xb0\x1d\x2a\x60\x2f\xd4\
|
||||
\x40\x1d\x34\xc0\x51\x68\x86\x93\x70\x0e\x2e\xc2\x55\xb8\x0e\x3d\
|
||||
\x70\x0f\xfa\x61\x08\x9e\xc1\x28\xbc\x81\x09\x04\x41\xc8\x08\x13\
|
||||
\x61\x21\xda\x88\x01\x62\x8a\x58\x23\x8e\x08\x17\x99\x85\xf8\x21\
|
||||
\xc1\x48\x04\x12\x8b\x24\x20\xc9\x88\x14\x51\x22\x4b\x91\x35\x48\
|
||||
\x31\x52\x8a\x54\x20\x55\x48\x1d\xf2\x3d\x72\x02\x39\x87\x5c\x46\
|
||||
\xba\x91\x3b\xc8\x00\x32\x82\xfc\x86\xbc\x47\x31\x94\x81\xb2\x51\
|
||||
\x3d\xd4\x0c\xb5\x43\xb9\xa8\x37\x1a\x84\x46\xa2\x0b\xd0\x64\x74\
|
||||
\x31\x9a\x8f\x16\xa0\x9b\xd0\x72\xb4\x1a\x3d\x8c\x36\xa1\xe7\xd0\
|
||||
\xab\x68\x0f\xda\x8f\x3e\x43\xc7\x30\xc0\xe8\x18\x07\x33\xc4\x6c\
|
||||
\x30\x2e\xc6\xc3\x42\xb1\x38\x2c\x09\x93\x63\xcb\xb1\x22\xac\x0c\
|
||||
\xab\xc6\x1a\xb0\x56\xac\x03\xbb\x89\xf5\x63\xcf\xb1\x77\x04\x12\
|
||||
\x81\x45\xc0\x09\x36\x04\x77\x42\x20\x61\x1e\x41\x48\x58\x4c\x58\
|
||||
\x4e\xd8\x48\xa8\x20\x1c\x24\x34\x11\xda\x09\x37\x09\x03\x84\x51\
|
||||
\xc2\x27\x22\x93\xa8\x4b\xb4\x26\xba\x11\xf9\xc4\x18\x62\x32\x31\
|
||||
\x87\x58\x48\x2c\x23\xd6\x12\x8f\x13\x2f\x10\x7b\x88\x43\xc4\x37\
|
||||
\x24\x12\x89\x43\x32\x27\xb9\x90\x02\x49\xb1\xa4\x54\xd2\x12\xd2\
|
||||
\x46\xd2\x6e\x52\x23\xe9\x2c\xa9\x9b\x34\x48\x1a\x23\x93\xc9\xda\
|
||||
\x64\x6b\xb2\x07\x39\x94\x2c\x20\x2b\xc8\x85\xe4\x9d\xe4\xc3\xe4\
|
||||
\x33\xe4\x1b\xe4\x21\xf2\x5b\x0a\x9d\x62\x40\x71\xa4\xf8\x53\xe2\
|
||||
\x28\x52\xca\x6a\x4a\x19\xe5\x10\xe5\x34\xe5\x06\x65\x98\x32\x41\
|
||||
\x55\xa3\x9a\x52\xdd\xa8\xa1\x54\x11\x35\x8f\x5a\x42\xad\xa1\xb6\
|
||||
\x52\xaf\x51\x87\xa8\x13\x34\x75\x9a\x39\xcd\x83\x16\x49\x4b\xa5\
|
||||
\xad\xa2\x95\xd3\x1a\x68\x17\x68\xf7\x69\xaf\xe8\x74\xba\x11\xdd\
|
||||
\x95\x1e\x4e\x97\xd0\x57\xd2\xcb\xe9\x47\xe8\x97\xe8\x03\xf4\x77\
|
||||
\x0c\x0d\x86\x15\x83\xc7\x88\x67\x28\x19\x9b\x18\x07\x18\x67\x19\
|
||||
\x77\x18\xaf\x98\x4c\xa6\x19\xd3\x8b\x19\xc7\x54\x30\x37\x31\xeb\
|
||||
\x98\xe7\x99\x0f\x99\x6f\x55\x58\x2a\xb6\x2a\x7c\x15\x91\xca\x0a\
|
||||
\x95\x4a\x95\x26\x95\x1b\x2a\x2f\x54\xa9\xaa\xa6\xaa\xde\xaa\x0b\
|
||||
\x55\xf3\x55\xcb\x54\x8f\xa9\x5e\x53\x7d\xae\x46\x55\x33\x53\xe3\
|
||||
\xa9\x09\xd4\x96\xab\x55\xaa\x9d\x50\xeb\x53\x1b\x53\x67\xa9\x3b\
|
||||
\xa8\x87\xaa\x67\xa8\x6f\x54\x3f\xa4\x7e\x59\xfd\x89\x06\x59\xc3\
|
||||
\x4c\xc3\x4f\x43\xa4\x51\xa0\xb1\x5f\xe3\xbc\xc6\x20\x0b\x63\x19\
|
||||
\xb3\x78\x2c\x21\x6b\x0d\xab\x86\x75\x81\x35\xc4\x26\xb1\xcd\xd9\
|
||||
\x7c\x76\x2a\xbb\x98\xfd\x1d\xbb\x8b\x3d\xaa\xa9\xa1\x39\x43\x33\
|
||||
\x4a\x33\x57\xb3\x52\xf3\x94\x66\x3f\x07\xe3\x98\x71\xf8\x9c\x74\
|
||||
\x4e\x09\xe7\x28\xa7\x97\xf3\x7e\x8a\xde\x14\xef\x29\xe2\x29\x1b\
|
||||
\xa6\x34\x4c\xb9\x31\x65\x5c\x6b\xaa\x96\x97\x96\x58\xab\x48\xab\
|
||||
\x51\xab\x47\xeb\xbd\x36\xae\xed\xa7\x9d\xa6\xbd\x45\xbb\x59\xfb\
|
||||
\x81\x0e\x41\xc7\x4a\x27\x5c\x27\x47\x67\x8f\xce\x05\x9d\xe7\x53\
|
||||
\xd9\x53\xdd\xa7\x0a\xa7\x16\x4d\x3d\x3a\xf5\xae\x2e\xaa\x6b\xa5\
|
||||
\x1b\xa1\xbb\x44\x77\xbf\x6e\xa7\xee\x98\x9e\xbe\x5e\x80\x9e\x4c\
|
||||
\x6f\xa7\xde\x79\xbd\xe7\xfa\x1c\x7d\x2f\xfd\x54\xfd\x6d\xfa\xa7\
|
||||
\xf5\x47\x0c\x58\x06\xb3\x0c\x24\x06\xdb\x0c\xce\x18\x3c\xc5\x35\
|
||||
\x71\x6f\x3c\x1d\x2f\xc7\xdb\xf1\x51\x43\x5d\xc3\x40\x43\xa5\x61\
|
||||
\x95\x61\x97\xe1\x84\x91\xb9\xd1\x3c\xa3\xd5\x46\x8d\x46\x0f\x8c\
|
||||
\x69\xc6\x5c\xe3\x24\xe3\x6d\xc6\x6d\xc6\xa3\x26\x06\x26\x21\x26\
|
||||
\x4b\x4d\xea\x4d\xee\x9a\x52\x4d\xb9\xa6\x29\xa6\x3b\x4c\x3b\x4c\
|
||||
\xc7\xcd\xcc\xcd\xa2\xcd\xd6\x99\x35\x9b\x3d\x31\xd7\x32\xe7\x9b\
|
||||
\xe7\x9b\xd7\x9b\xdf\xb7\x60\x5a\x78\x5a\x2c\xb6\xa8\xb6\xb8\x65\
|
||||
\x49\xb2\xe4\x5a\xa6\x59\xee\xb6\xbc\x6e\x85\x5a\x39\x59\xa5\x58\
|
||||
\x55\x5a\x5d\xb3\x46\xad\x9d\xad\x25\xd6\xbb\xad\xbb\xa7\x11\xa7\
|
||||
\xb9\x4e\x93\x4e\xab\x9e\xd6\x67\xc3\xb0\xf1\xb6\xc9\xb6\xa9\xb7\
|
||||
\x19\xb0\xe5\xd8\x06\xdb\xae\xb6\x6d\xb6\x7d\x61\x67\x62\x17\x67\
|
||||
\xb7\xc5\xae\xc3\xee\x93\xbd\x93\x7d\xba\x7d\x8d\xfd\x3d\x07\x0d\
|
||||
\x87\xd9\x0e\xab\x1d\x5a\x1d\x7e\x73\xb4\x72\x14\x3a\x56\x3a\xde\
|
||||
\x9a\xce\x9c\xee\x3f\x7d\xc5\xf4\x96\xe9\x2f\x67\x58\xcf\x10\xcf\
|
||||
\xd8\x33\xe3\xb6\x13\xcb\x29\xc4\x69\x9d\x53\x9b\xd3\x47\x67\x17\
|
||||
\x67\xb9\x73\x83\xf3\x88\x8b\x89\x4b\x82\xcb\x2e\x97\x3e\x2e\x9b\
|
||||
\x1b\xc6\xdd\xc8\xbd\xe4\x4a\x74\xf5\x71\x5d\xe1\x7a\xd2\xf5\x9d\
|
||||
\x9b\xb3\x9b\xc2\xed\xa8\xdb\xaf\xee\x36\xee\x69\xee\x87\xdc\x9f\
|
||||
\xcc\x34\x9f\x29\x9e\x59\x33\x73\xd0\xc3\xc8\x43\xe0\x51\xe5\xd1\
|
||||
\x3f\x0b\x9f\x95\x30\x6b\xdf\xac\x7e\x4f\x43\x4f\x81\x67\xb5\xe7\
|
||||
\x23\x2f\x63\x2f\x91\x57\xad\xd7\xb0\xb7\xa5\x77\xaa\xf7\x61\xef\
|
||||
\x17\x3e\xf6\x3e\x72\x9f\xe3\x3e\xe3\x3c\x37\xde\x32\xde\x59\x5f\
|
||||
\xcc\x37\xc0\xb7\xc8\xb7\xcb\x4f\xc3\x6f\x9e\x5f\x85\xdf\x43\x7f\
|
||||
\x23\xff\x64\xff\x7a\xff\xd1\x00\xa7\x80\x25\x01\x67\x03\x89\x81\
|
||||
\x41\x81\x5b\x02\xfb\xf8\x7a\x7c\x21\xbf\x8e\x3f\x3a\xdb\x65\xf6\
|
||||
\xb2\xd9\xed\x41\x8c\xa0\xb9\x41\x15\x41\x8f\x82\xad\x82\xe5\xc1\
|
||||
\xad\x21\x68\xc8\xec\x90\xad\x21\xf7\xe7\x98\xce\x91\xce\x69\x0e\
|
||||
\x85\x50\x7e\xe8\xd6\xd0\x07\x61\xe6\x61\x8b\xc3\x7e\x0c\x27\x85\
|
||||
\x87\x85\x57\x86\x3f\x8e\x70\x88\x58\x1a\xd1\x31\x97\x35\x77\xd1\
|
||||
\xdc\x43\x73\xdf\x44\xfa\x44\x96\x44\xde\x9b\x67\x31\x4f\x39\xaf\
|
||||
\x2d\x4a\x35\x2a\x3e\xaa\x2e\x6a\x3c\xda\x37\xba\x34\xba\x3f\xc6\
|
||||
\x2e\x66\x59\xcc\xd5\x58\x9d\x58\x49\x6c\x4b\x1c\x39\x2e\x2a\xae\
|
||||
\x36\x6e\x6c\xbe\xdf\xfc\xed\xf3\x87\xe2\x9d\xe2\x0b\xe3\x7b\x17\
|
||||
\x98\x2f\xc8\x5d\x70\x79\xa1\xce\xc2\xf4\x85\xa7\x16\xa9\x2e\x12\
|
||||
\x2c\x3a\x96\x40\x4c\x88\x4e\x38\x94\xf0\x41\x10\x2a\xa8\x16\x8c\
|
||||
\x25\xf2\x13\x77\x25\x8e\x0a\x79\xc2\x1d\xc2\x67\x22\x2f\xd1\x36\
|
||||
\xd1\x88\xd8\x43\x5c\x2a\x1e\x4e\xf2\x48\x2a\x4d\x7a\x92\xec\x91\
|
||||
\xbc\x35\x79\x24\xc5\x33\xa5\x2c\xe5\xb9\x84\x27\xa9\x90\xbc\x4c\
|
||||
\x0d\x4c\xdd\x9b\x3a\x9e\x16\x9a\x76\x20\x6d\x32\x3d\x3a\xbd\x31\
|
||||
\x83\x92\x91\x90\x71\x42\xaa\x21\x4d\x93\xb6\x67\xea\x67\xe6\x66\
|
||||
\x76\xcb\xac\x65\x85\xb2\xfe\xc5\x6e\x8b\xb7\x2f\x1e\x95\x07\xc9\
|
||||
\x6b\xb3\x90\xac\x05\x59\x2d\x0a\xb6\x42\xa6\xe8\x54\x5a\x28\xd7\
|
||||
\x2a\x07\xb2\x67\x65\x57\x66\xbf\xcd\x89\xca\x39\x96\xab\x9e\x2b\
|
||||
\xcd\xed\xcc\xb3\xca\xdb\x90\x37\x9c\xef\x9f\xff\xed\x12\xc2\x12\
|
||||
\xe1\x92\xb6\xa5\x86\x4b\x57\x2d\x1d\x58\xe6\xbd\xac\x6a\x39\xb2\
|
||||
\x3c\x71\x79\xdb\x0a\xe3\x15\x05\x2b\x86\x56\x06\xac\x3c\xb8\x8a\
|
||||
\xb6\x2a\x6d\xd5\x4f\xab\xed\x57\x97\xae\x7e\xbd\x26\x7a\x4d\x6b\
|
||||
\x81\x5e\xc1\xca\x82\xc1\xb5\x01\x6b\xeb\x0b\x55\x0a\xe5\x85\x7d\
|
||||
\xeb\xdc\xd7\xed\x5d\x4f\x58\x2f\x59\xdf\xb5\x61\xfa\x86\x9d\x1b\
|
||||
\x3e\x15\x89\x8a\xae\x14\xdb\x17\x97\x15\x7f\xd8\x28\xdc\x78\xe5\
|
||||
\x1b\x87\x6f\xca\xbf\x99\xdc\x94\xb4\xa9\xab\xc4\xb9\x64\xcf\x66\
|
||||
\xd2\x66\xe9\xe6\xde\x2d\x9e\x5b\x0e\x96\xaa\x97\xe6\x97\x0e\x6e\
|
||||
\x0d\xd9\xda\xb4\x0d\xdf\x56\xb4\xed\xf5\xf6\x45\xdb\x2f\x97\xcd\
|
||||
\x28\xdb\xbb\x83\xb6\x43\xb9\xa3\xbf\x3c\xb8\xbc\x65\xa7\xc9\xce\
|
||||
\xcd\x3b\x3f\x54\xa4\x54\xf4\x54\xfa\x54\x36\xee\xd2\xdd\xb5\x61\
|
||||
\xd7\xf8\x6e\xd1\xee\x1b\x7b\xbc\xf6\x34\xec\xd5\xdb\x5b\xbc\xf7\
|
||||
\xfd\x3e\xc9\xbe\xdb\x55\x01\x55\x4d\xd5\x66\xd5\x65\xfb\x49\xfb\
|
||||
\xb3\xf7\x3f\xae\x89\xaa\xe9\xf8\x96\xfb\x6d\x5d\xad\x4e\x6d\x71\
|
||||
\xed\xc7\x03\xd2\x03\xfd\x07\x23\x0e\xb6\xd7\xb9\xd4\xd5\x1d\xd2\
|
||||
\x3d\x54\x52\x8f\xd6\x2b\xeb\x47\x0e\xc7\x1f\xbe\xfe\x9d\xef\x77\
|
||||
\x2d\x0d\x36\x0d\x55\x8d\x9c\xc6\xe2\x23\x70\x44\x79\xe4\xe9\xf7\
|
||||
\x09\xdf\xf7\x1e\x0d\x3a\xda\x76\x8c\x7b\xac\xe1\x07\xd3\x1f\x76\
|
||||
\x1d\x67\x1d\x2f\x6a\x42\x9a\xf2\x9a\x46\x9b\x53\x9a\xfb\x5b\x62\
|
||||
\x5b\xba\x4f\xcc\x3e\xd1\xd6\xea\xde\x7a\xfc\x47\xdb\x1f\x0f\x9c\
|
||||
\x34\x3c\x59\x79\x4a\xf3\x54\xc9\x69\xda\xe9\x82\xd3\x93\x67\xf2\
|
||||
\xcf\x8c\x9d\x95\x9d\x7d\x7e\x2e\xf9\xdc\x60\xdb\xa2\xb6\x7b\xe7\
|
||||
\x63\xce\xdf\x6a\x0f\x6f\xef\xba\x10\x74\xe1\xd2\x45\xff\x8b\xe7\
|
||||
\x3b\xbc\x3b\xce\x5c\xf2\xb8\x74\xf2\xb2\xdb\xe5\x13\x57\xb8\x57\
|
||||
\x9a\xaf\x3a\x5f\x6d\xea\x74\xea\x3c\xfe\x93\xd3\x4f\xc7\xbb\x9c\
|
||||
\xbb\x9a\xae\xb9\x5c\x6b\xb9\xee\x7a\xbd\xb5\x7b\x66\xf7\xe9\x1b\
|
||||
\x9e\x37\xce\xdd\xf4\xbd\x79\xf1\x16\xff\xd6\xd5\x9e\x39\x3d\xdd\
|
||||
\xbd\xf3\x7a\x6f\xf7\xc5\xf7\xf5\xdf\x16\xdd\x7e\x72\x27\xfd\xce\
|
||||
\xcb\xbb\xd9\x77\x27\xee\xad\xbc\x4f\xbc\x5f\xf4\x40\xed\x41\xd9\
|
||||
\x43\xdd\x87\xd5\x3f\x5b\xfe\xdc\xd8\xef\xdc\x7f\x6a\xc0\x77\xa0\
|
||||
\xf3\xd1\xdc\x47\xf7\x06\x85\x83\xcf\xfe\x91\xf5\x8f\x0f\x43\x05\
|
||||
\x8f\x99\x8f\xcb\x86\x0d\x86\xeb\x9e\x38\x3e\x39\x39\xe2\x3f\x72\
|
||||
\xfd\xe9\xfc\xa7\x43\xcf\x64\xcf\x26\x9e\x17\xfe\xa2\xfe\xcb\xae\
|
||||
\x17\x16\x2f\x7e\xf8\xd5\xeb\xd7\xce\xd1\x98\xd1\xa1\x97\xf2\x97\
|
||||
\x93\xbf\x6d\x7c\xa5\xfd\xea\xc0\xeb\x19\xaf\xdb\xc6\xc2\xc6\x1e\
|
||||
\xbe\xc9\x78\x33\x31\x5e\xf4\x56\xfb\xed\xc1\x77\xdc\x77\x1d\xef\
|
||||
\xa3\xdf\x0f\x4f\xe4\x7c\x20\x7f\x28\xff\x68\xf9\xb1\xf5\x53\xd0\
|
||||
\xa7\xfb\x93\x19\x93\x93\xff\x04\x03\x98\xf3\xfc\x63\x33\x2d\xdb\
|
||||
\x00\x00\x00\x20\x63\x48\x52\x4d\x00\x00\x7a\x25\x00\x00\x80\x83\
|
||||
\x00\x00\xf9\xff\x00\x00\x80\xe9\x00\x00\x75\x30\x00\x00\xea\x60\
|
||||
\x00\x00\x3a\x98\x00\x00\x17\x6f\x92\x5f\xc5\x46\x00\x00\x02\x08\
|
||||
\x49\x44\x41\x54\x78\xda\x64\x91\x3d\x6b\x14\x41\x18\xc7\x7f\x73\
|
||||
\xb7\x2c\x6c\x0c\xb9\x20\xa6\x0d\x58\x45\x90\x88\x1f\x40\xb1\x12\
|
||||
\x2e\x8d\x82\x5f\x41\x08\x58\x05\xb4\xb5\x0c\xd8\x09\xa2\x20\x08\
|
||||
\x7e\x88\x58\x05\xac\x04\xfb\x08\x56\x42\x40\x48\x9d\xdc\xe5\xf6\
|
||||
\x66\xe7\x75\x67\xc7\xe2\x19\x72\x07\x0e\xfc\x18\x06\xe6\xff\x32\
|
||||
\xcf\xa8\x9c\x1f\x00\xb7\x81\x09\x70\x0b\xa8\xf7\x40\x1d\x42\x7a\
|
||||
\x02\xe1\x21\x78\xc0\xfe\x82\xee\x07\x74\x9f\x41\x9f\x83\x41\xf0\
|
||||
\xa8\x9c\x1f\x17\x83\x4d\xa0\x7e\x0d\xea\x18\xfa\x46\x84\xae\xe0\
|
||||
\x01\x0b\x18\x0b\xe6\x2d\x98\xf7\x72\x0e\xa8\x9c\x0f\x80\x49\x0d\
|
||||
\xf5\x09\xa8\x29\xf4\xe5\x72\x57\x76\x0f\x44\x20\xac\x19\x9a\x53\
|
||||
\x70\xcf\x21\x84\x11\xd4\x00\x1f\xa1\x9f\x4a\xad\x05\x70\x05\x5c\
|
||||
\x96\x7d\x06\x5c\x03\xcb\x62\xda\x01\x66\x9a\xb3\x79\x17\x42\x8f\
|
||||
\xca\xf9\xd9\x3e\x54\x67\x90\xc6\x92\xb8\x28\xe8\x92\x9e\x80\x5c\
|
||||
\x48\x80\x23\xa5\x88\x31\xa4\x10\xb8\x5f\x41\x38\x84\x38\x96\x6a\
|
||||
\x4b\x60\x5e\x12\x6d\xa9\x9e\x91\xa5\x80\x9e\x10\x32\xd6\x82\x31\
|
||||
\x8c\xbd\xe7\x55\x05\x66\x2a\xce\xb6\x18\x2c\xcb\x84\x03\x30\xb0\
|
||||
\xbe\x62\x14\x71\xd7\x09\xd6\xf2\xa8\x02\xbd\xfb\xff\xe0\x62\x11\
|
||||
\xe7\x1b\x71\xce\x10\x23\x78\x0f\xc6\xc0\x72\x09\xc6\xb0\x5b\x49\
|
||||
\x62\xcf\xea\xdb\xe2\xda\xbb\x57\xe2\x94\xa0\xef\xb9\x69\x50\x0c\
|
||||
\x18\xc1\xf2\x02\xda\x32\x34\x49\xcf\x39\x93\x33\x37\x0c\x83\xa4\
|
||||
\x5b\x0b\x5a\x43\xdb\x0a\x5d\xc7\xc5\x08\xda\x53\x99\x7a\x4b\x4a\
|
||||
\x96\x18\x13\x21\x48\x5a\x4a\xab\xda\x5a\xc3\xf5\x35\xcc\x66\x42\
|
||||
\xdb\x82\xb5\xfc\x54\x29\xb1\xef\x1c\x67\x31\x32\xee\x7b\x49\x04\
|
||||
\x50\x4a\xf6\x94\xc0\x39\xa9\x7c\x79\x09\x57\x57\xb0\x58\x40\x08\
|
||||
\xa4\xba\xe6\x5e\x65\x0c\xbf\xad\xe5\x93\x73\x1c\xc5\x28\xc9\xc3\
|
||||
\xb0\x12\xf7\xbd\xbc\xb5\x6d\x61\x3e\x17\xb1\xf7\x30\x1a\xf1\xa1\
|
||||
\x69\x38\x57\xb3\x19\x68\x4d\xdd\x75\x9c\x58\xcb\x34\x04\x11\xae\
|
||||
\xd7\xb7\x56\x0c\xb4\x96\x33\xf0\x6d\x63\x83\x17\x77\xee\x90\xaa\
|
||||
\x61\x80\x61\x20\xc4\xc8\x81\x73\x1c\x19\xc3\xb1\x73\x6c\x7a\x0f\
|
||||
\x21\x48\x7d\x6b\x85\x18\xd1\x4a\xf1\xa6\x69\xf8\xb2\xb5\x05\xdb\
|
||||
\xdb\xa0\xe6\x73\xf9\x96\xb6\x95\x7a\x6d\xcb\x5d\xad\x79\xa9\x35\
|
||||
\x4f\xad\x65\xcf\x7b\x88\x91\x3f\x29\xf1\x7d\x3c\xe6\x6b\xd3\xf0\
|
||||
\x77\x32\x81\x9d\x1d\xe1\xdf\x00\x3c\x20\x6c\x94\x21\xaa\x95\x54\
|
||||
\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82\
|
||||
\x00\x00\x03\x37\
|
||||
\x89\
|
||||
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
|
||||
\x00\x00\x10\x00\x00\x00\x10\x08\x06\x00\x00\x00\x1f\xf3\xff\x61\
|
||||
\x00\x00\x00\x19\x74\x45\x58\x74\x53\x6f\x66\x74\x77\x61\x72\x65\
|
||||
\x00\x41\x64\x6f\x62\x65\x20\x49\x6d\x61\x67\x65\x52\x65\x61\x64\
|
||||
\x79\x71\xc9\x65\x3c\x00\x00\x02\xd9\x49\x44\x41\x54\x78\xda\x6c\
|
||||
\x93\x5d\x48\x14\x51\x14\xc7\xff\xbb\xb3\xbb\xb6\xab\x95\x5b\x46\
|
||||
\xae\x99\xba\x7e\x40\x42\x46\x12\xa5\x4b\x49\xe8\x83\x60\x22\x11\
|
||||
\x3d\x94\xf6\xd6\x43\xe9\x6b\x81\x6f\x46\xd1\x43\x54\xd0\xf6\x49\
|
||||
\xf6\x24\x44\x81\x6f\x3d\x04\x8b\x08\x9a\x60\x59\xb6\x18\x65\xe9\
|
||||
\x22\xbb\xce\xb8\xea\xfa\xb1\x8b\xdf\xe3\x3a\xbb\xb3\xce\xed\xcc\
|
||||
\x75\x35\xad\x2e\x73\xb9\x77\xe6\x9c\xf3\xbf\xbf\x73\xee\x19\xc3\
|
||||
\xad\xf6\x76\x18\x0c\x06\x3e\x35\x4d\x83\x3e\x68\x5f\x47\x8b\x03\
|
||||
\xff\x1f\xdd\xeb\x89\x44\x40\x4d\x24\xc0\x18\x83\x69\xbb\xc5\x48\
|
||||
\x22\x09\x32\xd0\xc8\x6a\xa9\xaf\x6f\x9d\x8e\x44\x61\xb7\x5b\xb8\
|
||||
\xb0\x46\xce\x43\x81\x00\x3a\x07\x07\x1b\xf5\x33\x68\xfa\x79\xcc\
|
||||
\x0e\x6d\x12\x30\x0a\x02\x74\xf5\xc8\x9c\x02\x8a\x44\x24\xb2\x86\
|
||||
\x99\xd9\x28\xa6\x66\x56\x21\xcb\x32\xee\x36\x34\xb4\x92\xbd\x8a\
|
||||
\xbc\x8b\xf4\x90\x4d\x82\x3a\xc2\x71\x24\xf1\x21\x08\x42\xc5\xe4\
|
||||
\x62\x08\xcb\xb2\x8a\xe2\x9c\x83\xc8\xb0\x5a\xa1\xae\xaf\xe3\xc7\
|
||||
\xf0\x3c\xde\x7a\x3c\x28\xc9\xc8\x68\x7d\xd2\xde\x7e\x83\xdc\xdd\
|
||||
\x26\x8d\x0c\x9b\xc8\x23\x81\x15\xe4\xe6\x59\x77\x20\x0f\x07\xa7\
|
||||
\x91\x99\xbe\x1f\xa9\x29\x36\x9c\x38\xea\x42\x82\x6c\x66\xb3\x19\
|
||||
\xe5\xc1\xa0\xc2\x09\xd4\x8d\x9c\xe1\x17\x65\x3d\x03\x04\xc7\xd6\
|
||||
\x78\x71\xf4\x7a\xea\xc8\x35\xe5\xe5\xf8\xe8\xf3\xc1\xbe\xc7\x8c\
|
||||
\x0c\xbb\x8d\x93\x08\x24\x10\x8b\xc5\x0c\x1b\x02\xaa\xca\xc9\x8b\
|
||||
\x9c\xa9\xf0\x4b\xab\x70\x1e\xb6\xf0\x53\x74\xc7\x21\x71\x03\x59\
|
||||
\x1f\x83\xbf\xfc\xa8\xad\xa8\x24\x1b\xa3\xca\xa9\x88\x93\xc0\xc9\
|
||||
\xee\x6e\x12\x88\xc7\xb9\x80\x38\x1e\x85\xd1\x68\xc0\xd8\x64\x9c\
|
||||
\x13\xd0\x83\x92\xc2\xd3\x9c\x44\x7f\x5f\x54\xc7\x71\x60\x5f\x0a\
|
||||
\xdf\xc7\x07\x06\xd0\xe8\x76\x5f\xd3\xc2\xe1\x21\x23\xa1\x70\x9c\
|
||||
\xc2\x1c\x1b\x4f\xa1\x20\x67\x17\xf2\xf9\x4c\x41\x2e\xd1\x64\x67\
|
||||
\x0b\xc8\xcb\xb7\x52\x41\xe3\x98\x5f\x4a\x60\xc4\x1f\x42\xaf\xf7\
|
||||
\x3b\xca\x9a\x9a\x8e\x45\x80\x3b\x26\x42\xe1\x04\x52\x68\x8d\xdf\
|
||||
\xc0\x58\x28\xc6\x4f\xd7\x34\xb6\x45\xc2\x98\x02\x9b\x05\xb0\xa8\
|
||||
\xfd\x08\x8e\x2e\xa3\xe6\xfa\x55\xd4\xb9\x5c\x3d\x17\x19\xbb\x67\
|
||||
\x8a\x25\x05\x0a\xb2\x6d\x18\x9d\x8c\x22\x2f\xcb\xca\x6f\x80\x17\
|
||||
\x32\xb9\x1a\xa8\x37\xc4\x2e\x2f\x7c\xa1\xf7\xa8\x39\x75\x1c\xee\
|
||||
\xa7\x12\x66\x9d\xce\xaf\xdf\x04\xa1\xd3\xa4\x28\xca\x06\xc1\x54\
|
||||
\x92\x60\x4a\xd9\xca\x7b\x93\x24\xb6\xf8\x09\xc6\xb9\x37\x28\xab\
|
||||
\x3c\x8b\x8e\x8e\x7e\x5c\xba\xd0\x82\xd7\x7d\x3d\xe1\xb6\x89\x09\
|
||||
\xfc\x21\x38\x44\x04\xa1\x28\xf2\x75\x02\x60\x8b\x60\x61\xb6\x17\
|
||||
\xe2\xec\x73\x54\x53\xf0\xc3\x47\xee\xd1\x8e\x61\xc7\x87\xa1\x97\
|
||||
\xcd\x7e\x4d\x96\x97\xe5\x70\x38\xdf\x34\x23\x8a\xd8\xeb\x70\x18\
|
||||
\x44\x22\xd0\x5b\x5c\x9a\x56\x92\x79\x33\x44\x17\x46\x11\x09\x3c\
|
||||
\xc0\x19\x57\x29\x1e\x3f\x7b\x21\x05\x25\xa5\xb9\xcf\x23\x7d\x01\
|
||||
\xa4\xcd\xe6\xd7\x83\x90\x7e\xe4\xfc\xf9\x9b\x14\xc0\x88\x40\x5f\
|
||||
\x18\x9d\xcc\xd6\x89\xfd\xb3\xe7\x36\x63\xf2\x08\x7b\xd7\x56\xc5\
|
||||
\x6a\xaf\x94\xbe\x22\x5f\xfb\xdf\xbf\xa6\xde\x4d\xb9\xbb\x8b\x8b\
|
||||
\xab\x8d\x69\x69\xff\x18\x97\xbc\xde\xfb\x97\xcf\xa5\xfe\x1c\x5e\
|
||||
\xcd\xec\x93\xc2\x96\x81\x15\x9f\xaf\x8b\x3e\x8b\xdb\x7d\x7e\x0b\
|
||||
\x30\x00\x66\x8d\xa1\xfd\x87\x65\xe6\x27\x00\x00\x00\x00\x49\x45\
|
||||
\x4e\x44\xae\x42\x60\x82\
|
||||
\x00\x00\x02\xa1\
|
||||
\x89\
|
||||
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
|
||||
\x00\x00\x10\x00\x00\x00\x10\x08\x06\x00\x00\x00\x1f\xf3\xff\x61\
|
||||
\x00\x00\x00\x19\x74\x45\x58\x74\x53\x6f\x66\x74\x77\x61\x72\x65\
|
||||
\x00\x41\x64\x6f\x62\x65\x20\x49\x6d\x61\x67\x65\x52\x65\x61\x64\
|
||||
\x79\x71\xc9\x65\x3c\x00\x00\x02\x43\x49\x44\x41\x54\x78\xda\xa4\
|
||||
\x93\xcf\x6b\x13\x51\x10\xc7\xbf\xfb\x23\x6b\xd3\x4d\x63\x53\x51\
|
||||
\x69\x93\x2d\x52\x62\xc5\xb6\x54\x08\x52\x28\x28\xb4\xa8\x08\xc5\
|
||||
\x5e\x84\xfe\x01\x3d\x49\x2f\x9e\x7a\x29\x96\x9e\xf2\x07\xf4\xa4\
|
||||
\x88\x17\x7f\x1c\x82\x22\x2a\xb9\x05\x5a\xe8\x49\x94\x0a\xb1\x58\
|
||||
\x24\x97\x68\x49\xa5\x31\x35\x90\xd2\xcd\x26\xd9\xcd\x6e\xd6\x99\
|
||||
\xad\x5b\x82\xb4\x50\x71\x60\xf6\xbd\x37\xcc\x7c\xdf\x7c\xde\xdb\
|
||||
\x27\xb8\xae\x8b\xff\x31\x79\x66\x69\xe9\x70\x21\x08\xc2\x34\x0d\
|
||||
\x7d\xff\x50\xbf\x23\xf3\xd7\x69\xb5\xfc\x40\xf4\x4d\x32\xf9\xe8\
|
||||
\x24\x3d\x09\xe4\x77\x17\x17\xe7\x64\xda\x15\x92\x28\xc2\x34\x4d\
|
||||
\x8e\x8b\x0e\x21\x7d\x2e\xba\xa8\x14\xbe\x42\x8b\x0f\x63\x20\xd2\
|
||||
\x3a\x52\x40\xa4\x1a\xbb\xd9\x14\xbd\x0e\x04\x5a\x28\x8a\x82\x9a\
|
||||
\x61\x88\x36\x09\xec\x15\xbe\xa0\x98\xdf\x84\x08\x07\x5a\xe2\x32\
|
||||
\x0a\xa5\x12\x82\xc1\x20\x6c\xdb\x46\x6f\x4f\x8f\x27\x20\xd1\xc6\
|
||||
\xbe\xc0\x34\x5c\xb7\x8f\x15\x03\x8a\x72\x6d\x65\x7d\x1d\xdb\xbb\
|
||||
\x3a\x8a\xe5\x32\x6a\xe1\x5f\xa8\x7e\x32\xd0\xa0\x42\xdf\xce\x77\
|
||||
\x77\xe3\x4a\x3c\x8e\x00\xe5\x37\x2d\x4b\x94\x6d\xc7\x39\x86\xfb\
|
||||
\xe6\x91\xdc\x4f\x33\x19\x9c\x56\x55\x5c\xd0\x34\x58\x96\x25\xc9\
|
||||
\xdc\x06\x73\x3f\xcb\xba\xf8\xfe\xfe\x35\xc6\x6f\xcf\xe0\xd6\xc0\
|
||||
\xf1\xdc\x6a\x67\x27\x62\xd1\x28\x6c\x3a\x78\xcb\x34\x45\x91\x05\
|
||||
\x98\xfb\xe7\x87\x57\xd8\x5c\x4d\x61\x63\xe5\x25\x9a\x8e\x83\xb5\
|
||||
\x6c\x16\x1b\x5b\x5b\xf8\x98\xcb\x79\x6b\x76\xce\x4b\x2e\x2f\xa7\
|
||||
\x9f\xa4\x52\xab\xcd\x03\x01\x49\x66\x0e\x56\x3b\xa3\x0d\xa1\x5a\
|
||||
\xad\xe2\x5c\xff\x10\x2c\x62\x8e\xc5\x62\xde\xae\x2a\xb5\x6b\xfd\
|
||||
\x39\x03\xe6\x56\x43\x21\x69\x6e\x76\xf6\x06\xd5\xc1\xd0\xf5\x80\
|
||||
\xcc\x1c\xac\xf6\xee\x6d\x1a\x86\x61\x60\x2d\x93\xc6\x9d\xeb\xf7\
|
||||
\x91\xa3\x9d\x7d\x2b\x45\x22\xa8\xd7\xeb\x18\x4f\x24\x50\xd3\xf5\
|
||||
\xca\xd9\x78\x7c\x21\x14\x0e\x77\x39\x86\x51\x96\x99\x83\x3b\x78\
|
||||
\xf1\x70\x9e\x52\xe7\xbd\x82\x7a\xad\x86\xab\xa3\xa3\xde\x3c\x48\
|
||||
\xcc\xbe\x71\x9e\x24\x49\xdf\xec\x7c\xfe\xf9\x1e\xc0\xe7\x5e\x11\
|
||||
\x99\x83\x3b\x60\xae\xde\x91\x91\x05\x1e\x2d\xe2\xf5\xbd\x3d\xce\
|
||||
\x79\xa4\x60\x5c\x9c\x9c\xdc\xa1\xe2\x22\x79\x03\x97\xa6\xa6\x1e\
|
||||
\xec\x9a\xa6\x5b\xa1\x57\xc5\x73\x1e\x7f\xe8\xfa\xa1\xb7\xc7\x39\
|
||||
\x8f\xe7\xe4\x88\x8d\x8d\x1d\x5c\x6d\xd7\xe0\xe0\x3d\x49\x55\xfb\
|
||||
\xab\xfb\xfb\xba\xd2\x68\x6c\x5b\x1d\x1d\x1a\xf3\xf9\x6d\xff\x1d\
|
||||
\x27\xee\x02\xf9\xe3\xf6\x7f\xe3\x14\x79\x84\xaf\xf9\x04\x6f\xc8\
|
||||
\xe3\xf6\x5a\x27\x1b\x9e\x98\xc0\x6f\x01\x06\x00\x48\xae\x45\x78\
|
||||
\x60\x4e\x1f\xe2\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82\
|
||||
\
|
||||
\x00\x00\x02\xaf\
|
||||
\x89\
|
||||
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
|
||||
\x00\x00\x10\x00\x00\x00\x10\x08\x06\x00\x00\x00\x1f\xf3\xff\x61\
|
||||
\x00\x00\x00\x19\x74\x45\x58\x74\x53\x6f\x66\x74\x77\x61\x72\x65\
|
||||
\x00\x41\x64\x6f\x62\x65\x20\x49\x6d\x61\x67\x65\x52\x65\x61\x64\
|
||||
\x79\x71\xc9\x65\x3c\x00\x00\x02\x51\x49\x44\x41\x54\x78\xda\x9c\
|
||||
\x53\xcf\x6b\x13\x51\x10\xfe\x36\xfb\x62\x8d\x69\x48\x62\x9b\x18\
|
||||
\x8d\xab\x5d\xd3\x84\xa2\x10\xbd\x48\x0f\x62\xa9\xd8\x93\xe0\x49\
|
||||
\x0f\xa5\x20\x52\xb0\xe0\x7f\xe0\x45\x3c\xf5\xa6\x77\x7b\xe8\x55\
|
||||
\x28\x41\x3d\x78\x28\x7a\xf0\x47\x51\xa4\xbd\x58\x0d\xa8\x60\x5a\
|
||||
\x13\x51\xd0\x43\x89\x69\xf3\x63\xb3\xc9\xee\x3e\x67\x9e\xd9\xa2\
|
||||
\x08\x4a\x1d\x18\xde\xdb\x99\xf9\xbe\xf7\xcd\x7b\xb3\xda\x8d\x85\
|
||||
\x05\xb0\x69\x9a\x76\x9e\x96\xfd\xf8\xbb\x3d\x71\x1c\x67\xad\xdb\
|
||||
\xe9\xe0\xdc\xf3\x19\x48\x0a\x08\xd7\x75\xfd\xe4\x81\xeb\x93\x93\
|
||||
\x73\x0e\x7d\x73\xc2\x95\x12\x5d\xda\x77\x3d\x4f\xed\x2b\x95\x0a\
|
||||
\x1e\x15\x8b\x57\xa5\x94\x1a\xa5\x4b\x3e\x28\x30\xf1\xf8\x32\xcc\
|
||||
\xb5\x7b\x20\x56\x4d\x72\xb1\xe3\xc0\xe9\x76\xe1\xf6\xbc\xd3\x6e\
|
||||
\xc3\x6a\x36\xd1\x68\x34\x30\x3b\x35\x35\x47\xb9\xb3\x44\x92\xf5\
|
||||
\x09\x04\xfb\xf0\xa7\x07\x57\x5a\x32\x78\x41\xd3\x2e\xe1\xc5\xea\
|
||||
\x2a\x3c\x22\x8a\xc5\x62\x68\xb5\x5a\x38\x3e\x32\xa2\x0a\xab\xd5\
|
||||
\x2a\xee\x2c\x2e\x22\x9f\x4c\xde\x5e\x29\xcc\x3e\x85\x8e\x02\x85\
|
||||
\xe7\x05\xa9\x1b\x44\x40\xcf\x65\x8f\x9e\x9c\x60\x6d\x99\x4c\x06\
|
||||
\x74\x82\x22\x89\xc7\xe3\x08\xea\xba\x22\x38\x35\x3a\x8a\x0e\xa9\
|
||||
\x0b\x85\xc3\x18\x68\x5d\x3c\x23\x1f\xbe\x7a\x2d\x3d\x77\x50\xb8\
|
||||
\x12\xc6\x5e\xe3\xd8\xf0\x26\x5d\x4c\x40\xd3\x54\xaf\xd1\x68\x54\
|
||||
\x9d\xc8\x24\x1f\x89\x8c\x09\x39\xc6\x8a\x4e\xe4\xf3\xb0\x6d\x1b\
|
||||
\x49\xc2\x54\x2b\x45\x43\xb8\x1e\x0e\xed\x8e\x26\xf7\x59\x56\x1b\
|
||||
\xbf\x2a\xe0\xd3\x7d\x25\xb2\x47\xe2\x2b\xe2\x5a\xc6\x30\x96\x14\
|
||||
\xc8\xa1\x60\x38\x16\x6a\x12\x3b\x3d\x25\xca\xe5\xf2\x36\xc0\x57\
|
||||
\xc2\x2b\x7f\xb3\x82\xc3\xa9\x14\xb8\x96\x31\x8c\x15\x8e\x87\x5c\
|
||||
\x24\x65\x26\xac\xf7\x75\x94\x0b\xd7\x30\x40\xb7\xde\x97\x1b\x47\
|
||||
\x5f\x76\xec\x37\x25\xf6\x87\x25\x04\x4b\x4b\xf8\xba\xbe\x07\x56\
|
||||
\xdb\x46\xc4\x34\x13\x8c\xe5\x16\x44\x24\x91\x4e\x4d\x27\x7e\x3e\
|
||||
\x0b\x4f\xd2\xca\xf2\x7d\x38\xc2\x50\x40\x7e\x0d\x6e\x63\x73\xf9\
|
||||
\x2e\x4e\x8f\x8d\xab\x9a\x69\x53\x2d\x29\xc6\xb2\x02\xb1\xb5\xb1\
|
||||
\x41\x7d\x59\x2a\xda\x4f\x00\x23\x9d\xc6\x97\x67\x37\x15\x41\x93\
|
||||
\x62\x3c\x58\xe6\x90\x89\x66\xbd\x8e\x46\xad\xa6\xea\x42\xa1\x10\
|
||||
\x1c\x45\xe0\x4a\xe1\xf0\xf0\x90\xb3\xd5\x88\xcc\xc8\x66\x71\xd0\
|
||||
\x3c\xf2\xc7\x1c\x7f\x2e\x6d\x0f\xa0\xaa\x67\xac\xe8\x7a\x08\x76\
|
||||
\x3a\x34\x71\xe4\xbe\xad\xbf\x7d\x87\x7f\x99\xae\x0b\x30\x56\x34\
|
||||
\x6c\xf4\x4b\xc9\x5a\x74\xec\xc4\x18\xc3\x58\xf1\xe6\x9b\xac\x6c\
|
||||
\xcd\xdf\x7a\x89\xff\xb0\xf2\x77\x54\x78\x76\x76\x91\xc7\x7a\xff\
|
||||
\xc5\x4e\x8c\x2f\xad\xf6\x43\x80\x01\x00\xc1\x52\x4e\xcc\x97\x5f\
|
||||
\x6c\x5a\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82\
|
||||
\x00\x00\x02\x77\
|
||||
\x89\
|
||||
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
|
||||
\x00\x00\x10\x00\x00\x00\x10\x08\x06\x00\x00\x00\x1f\xf3\xff\x61\
|
||||
\x00\x00\x00\x19\x74\x45\x58\x74\x53\x6f\x66\x74\x77\x61\x72\x65\
|
||||
\x00\x41\x64\x6f\x62\x65\x20\x49\x6d\x61\x67\x65\x52\x65\x61\x64\
|
||||
\x79\x71\xc9\x65\x3c\x00\x00\x02\x19\x49\x44\x41\x54\x78\xda\x8c\
|
||||
\x93\xbd\xaf\xa1\x41\x14\xc6\xcf\xcb\x2b\xe2\x26\x16\x05\xb1\x42\
|
||||
\x43\xa2\x11\xbd\x66\x23\xa2\x22\xb9\xff\xc1\xaa\xf7\xd6\x1a\x0a\
|
||||
\x09\x89\x46\xb7\xd1\xdd\x68\x97\xbf\x60\x2b\x8a\x0d\xb1\x85\x8f\
|
||||
\x42\x50\xae\x50\x21\x44\x04\xb1\xbe\x3f\x76\x9e\xb3\x5e\xb9\x37\
|
||||
\x5b\xac\x93\x8c\x31\x73\xcc\xef\x79\xce\x99\x21\x25\x93\x49\xba\
|
||||
\x5e\xaf\x24\x49\xd2\x33\x11\x7d\xa4\xff\xc7\x8f\xf3\xf9\xdc\x3b\
|
||||
\x1e\x8f\x94\xc9\x64\x48\xc6\x8e\x4a\xa5\xa2\xd3\xe9\x64\x4b\x24\
|
||||
\x12\xaf\x22\xc9\x40\x0c\xb1\x77\x1f\x58\xf7\x7a\x3d\x2a\x95\x4a\
|
||||
\x2f\x37\x50\x0f\x1f\x00\x3c\x8b\x24\x94\x3f\xb5\x5a\x2d\x9a\x4e\
|
||||
\xa7\xa4\x56\xab\xc9\x60\x30\xd0\x78\x3c\x26\x9d\x4e\x47\xbb\xdd\
|
||||
\x8e\xdc\x6e\x37\xad\xd7\x6b\x4a\xa7\xd3\xaf\xf1\x78\x1c\x10\x49\
|
||||
\x8c\x5f\x92\x50\xfd\xf2\x88\x32\x20\xc3\xe1\x90\x34\x1a\x0d\xcb\
|
||||
\x67\xb3\xd9\x68\xa3\xd1\xf8\x2a\xa3\x16\xfc\xe8\x72\xb9\xfc\x33\
|
||||
\x2b\x10\x28\x87\x42\x21\x2a\x16\x8b\x64\xb5\x5a\xc9\x62\xb1\x50\
|
||||
\xbd\x5e\xdf\x71\xf9\x02\x20\xfa\x27\x51\xb3\xd9\xa4\x6e\xb7\xcb\
|
||||
\xfd\xa8\x56\xab\xd4\xef\xf7\xa9\xdd\x6e\x93\x2c\xcb\x34\x9f\xcf\
|
||||
\xa9\x50\x28\xd0\x6c\x36\xa3\x72\xb9\x8c\x86\xd3\x7e\xbf\x97\xb8\
|
||||
\x07\x0a\xc0\xe7\xf3\xdd\x95\x03\x81\x00\xcf\x18\x70\xe8\xf7\xfb\
|
||||
\xd9\x89\x56\xab\xa5\x5a\xad\xc6\xd0\xc3\xe1\xf0\x17\x00\x12\x00\
|
||||
\xb9\x5c\x8e\xed\x79\xbd\x5e\x4a\xa5\x52\x64\xb3\xd9\xc8\xe9\x74\
|
||||
\x52\x24\x12\xa1\x7c\x3e\x4f\x66\xb3\x99\x3c\x1e\x0f\x94\x19\x70\
|
||||
\x77\x00\x12\x00\xe1\x70\x98\x1d\x38\x1c\x0e\xee\xbc\xc9\x64\xe2\
|
||||
\x32\x50\x52\x30\x18\x64\x37\xc8\x0d\x06\x03\x06\x88\xa6\x32\x40\
|
||||
\xa5\x38\xc0\x95\x2d\x16\x0b\xae\x0f\xca\x88\xd1\x68\xc4\x80\xc9\
|
||||
\x64\x42\xcb\xe5\x92\x0f\xe2\xb6\xde\xf5\x00\x24\x6c\xc0\x32\x1c\
|
||||
\xe0\x40\x2c\x16\xbb\x5f\x29\x94\xed\x76\x3b\xcf\x6f\x01\xdb\xed\
|
||||
\xf6\xbd\x03\x58\x53\x1c\x54\x2a\x15\xea\x74\x3a\x3c\x03\x88\x1c\
|
||||
\xe6\xdb\x41\x5a\xad\x56\x70\xcc\xaf\x58\x56\x48\x8a\xed\xb7\x25\
|
||||
\xa0\x0f\x58\xbb\x5c\x2e\xe5\xff\x82\x07\xf4\x3d\x1a\x8d\xfe\x14\
|
||||
\x8e\x26\x0c\x00\x49\x51\xc7\x7d\x23\xb0\x36\x1a\x8d\xac\x86\x40\
|
||||
\x0e\x00\xc4\x66\xb3\x69\x89\x7e\x7c\x13\x5f\x57\x2c\xa8\xd7\xeb\
|
||||
\x3f\x0b\x7b\x36\x7a\x30\x84\xf2\x48\xf4\x2d\xaf\xbc\x60\xd8\x7f\
|
||||
\x12\xe3\x03\xfa\xf1\xc0\xf9\xeb\x4d\xf9\x37\x2f\x04\xe0\x8f\x00\
|
||||
\x03\x00\xe7\xe3\x7a\x6e\x30\xbb\xf3\xb7\x00\x00\x00\x00\x49\x45\
|
||||
\x4e\x44\xae\x42\x60\x82\
|
||||
\x00\x00\x03\x66\
|
||||
\x89\
|
||||
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
|
||||
\x00\x00\x10\x00\x00\x00\x10\x08\x06\x00\x00\x00\x1f\xf3\xff\x61\
|
||||
\x00\x00\x00\x19\x74\x45\x58\x74\x53\x6f\x66\x74\x77\x61\x72\x65\
|
||||
\x00\x41\x64\x6f\x62\x65\x20\x49\x6d\x61\x67\x65\x52\x65\x61\x64\
|
||||
\x79\x71\xc9\x65\x3c\x00\x00\x03\x08\x49\x44\x41\x54\x78\xda\x84\
|
||||
\x53\x6d\x48\x53\x51\x18\x7e\xce\xfd\xd8\x75\x9b\x8e\xdc\x2c\xdd\
|
||||
\x4c\x5d\x4e\xa7\xc9\xe6\xb7\xf6\x61\x61\x11\x14\x52\x16\xf5\xc7\
|
||||
\x0a\x0b\xa2\x3f\x41\x51\x41\x61\x7f\x0a\x84\xa2\x9f\xfd\xeb\x67\
|
||||
\x7f\xfa\x51\x44\x50\x91\x14\x15\x5a\x14\x41\x25\x6d\x44\x59\x68\
|
||||
\x69\xd9\x74\xa6\x6d\xd7\x7d\x38\xb6\xdd\x6d\x77\xa7\x73\x2d\x4d\
|
||||
\x84\xe8\x81\x87\xf7\x7d\xef\x7b\xde\xe7\xbe\xe7\x9c\xf7\x10\x30\
|
||||
\x48\x84\x20\x4f\xb3\xf8\x8b\xb3\x1b\xe9\xbc\xe5\x38\x14\xb3\x74\
|
||||
\x2f\x73\xab\x18\x47\x28\x45\x6f\x36\x0b\xff\xc2\x3a\xde\xc6\xb2\
|
||||
\x06\xcd\x61\x24\x4b\x04\xbe\x87\x09\x48\x82\x89\x8a\xb8\x62\xaf\
|
||||
\x76\x75\x5a\x4a\xcb\x9d\x31\x85\xae\x9d\x0d\xce\x15\x7c\xf1\xa3\
|
||||
\xef\x67\x18\xd0\xc8\xe1\x1f\xf0\xcf\x01\x43\x53\xc4\xf1\x33\x04\
|
||||
\x57\x20\x12\x29\xcc\x31\x5b\x84\x4d\x7b\xf6\x18\xb5\x78\xcc\x0f\
|
||||
\x07\x23\x34\x0a\xcb\xea\x0a\x19\x4f\x32\xda\x19\xc7\x53\x04\x91\
|
||||
\x99\x10\xc4\xde\xd3\xa7\x61\x30\x1a\xa1\xb2\xde\xb5\x98\xe7\xb0\
|
||||
\x85\xe5\xc7\xb4\x02\x81\x2e\xa9\x66\xfe\xb9\x86\xd6\xd6\xfd\xee\
|
||||
\xba\x3a\xcb\x3b\x8f\x47\x9e\x78\xe7\x8d\xc5\x13\x88\x4a\x3a\x1d\
|
||||
\x94\x78\x1c\x82\x28\x22\xae\x6d\x8b\x47\x23\x5b\x7e\x6d\x5e\xa0\
|
||||
\xdd\xf9\x77\xe7\xcf\x3e\xd3\x0d\xbd\xa7\x3a\xac\x2e\xa7\x15\x43\
|
||||
\x9f\x6d\xd6\xae\x43\xde\xb0\x51\x44\x74\x6c\x78\x18\xf6\x8a\x0a\
|
||||
\x68\x96\xc5\x1a\x4a\x16\x6a\x84\xad\xce\xc5\xfa\xae\xc1\x69\x53\
|
||||
\x65\xbd\xdb\x8e\x74\x32\x09\xcd\xea\xf2\x4c\xb9\x0e\x5b\x94\x0c\
|
||||
\xdc\xba\xe9\x6d\xda\xbe\xa3\xd1\xf3\xe4\xb1\x37\xf7\xb7\x40\xc1\
|
||||
\xa2\x40\x26\xbb\x28\xc0\x75\xd5\x29\x23\xc9\xb9\xb9\x8d\x99\x74\
|
||||
\x1a\x2a\xe3\xae\xfa\xf4\xc7\xf1\x92\xa2\x60\xce\xc4\x0f\x4b\x85\
|
||||
\xb3\x0a\xcf\xfb\x6e\xd2\x57\xdd\x35\x1f\x73\x43\xc9\x47\x33\x25\
|
||||
\x26\x4c\x15\xe7\x82\x27\xb5\x07\x41\x09\x87\x7c\x75\x66\xc8\x28\
|
||||
\x66\xaa\x4b\x2a\xdd\x4d\xec\x42\x85\xf0\x6c\x20\xf5\x32\x3c\xfa\
|
||||
\x4d\x3a\xd1\xe3\xd4\xd7\xb4\x54\xa5\x14\x17\xa6\xdb\xaa\x6d\x85\
|
||||
\x5b\xda\x0b\x9e\xe6\x04\x12\xe1\x3c\xc1\x8e\x2c\xfd\xc2\x7f\x6d\
|
||||
\xba\x8c\x41\x7d\x07\x1e\x99\x8e\x40\xa5\x24\xc0\x7d\xb8\xb1\x3e\
|
||||
\x96\x26\xb6\x57\xaf\x07\xfc\x74\x77\x77\x45\xc1\x6a\x87\x79\x2a\
|
||||
\x91\xc0\xd9\x8e\xa3\xb8\x3d\xe5\x41\xe9\xaa\x62\x93\xcb\x5c\x5e\
|
||||
\x6b\xa0\xba\x35\xdf\x02\x93\xe2\x92\x39\xa0\xcd\xfd\xa6\xc3\x3b\
|
||||
\x83\xf2\x2c\x69\x6c\x6e\x41\x24\x1a\x13\xef\x8f\xb4\xbe\x1f\xf7\
|
||||
\x49\x93\x49\x76\x26\xb2\x2c\x43\xb3\x1a\xd4\x54\x46\xaa\x36\x97\
|
||||
\xb9\x69\x54\x69\x23\x7c\x77\xdf\x0a\x70\xe2\x7e\x83\x24\xd4\x1c\
|
||||
\xeb\x74\xef\x5b\x19\x19\x2a\xb6\x4b\x32\xc6\x15\x0b\x82\xf9\x95\
|
||||
\xa1\xab\x0f\xfb\x3d\x49\xce\x17\x6b\x19\xf6\x0e\x0c\x6e\xf0\x6f\
|
||||
\xa3\x69\x55\x0f\x45\x35\xd0\x74\x36\x07\xa3\xd1\x27\x84\x3f\x70\
|
||||
\xe7\x4c\xe7\xfa\xf2\xee\xa6\x2a\xeb\x5a\x4b\x7e\x9e\xe4\xf3\x4d\
|
||||
\xe3\xd2\xde\x52\x9c\xbf\xeb\x43\x59\x99\x15\x72\x28\x9a\x7a\xfb\
|
||||
\xe9\xfb\x68\x5f\xff\xeb\x7b\xea\x83\x93\xd7\x97\x0d\x9e\xcc\x41\
|
||||
\x89\x36\xd7\xda\xcd\xf5\xd9\x4c\x76\xfe\x2d\x2d\x6f\x97\xaa\xd0\
|
||||
\xd5\x39\xac\x35\x90\x4c\xe5\xfc\xe6\x9e\x11\xed\x41\x2d\x61\x90\
|
||||
\xf0\xf5\x87\x2e\xc0\xda\xd0\x4e\x79\x29\x41\x05\x7d\x0c\x82\x3e\
|
||||
\xde\x36\x7d\xf5\xcd\xcb\xa2\xe3\xeb\x48\x26\x69\x20\x99\x84\x91\
|
||||
\xa8\x8a\x1e\x3f\xbc\x2f\xe8\xec\xe8\x45\x1a\x99\x04\x8d\x4c\x2c\
|
||||
\xb6\x40\xfe\x0c\x85\x05\xff\x87\xac\xfd\x71\xf9\xc7\x5f\x02\x0c\
|
||||
\x00\x00\x31\x44\x70\x94\xe4\x6d\xa8\x00\x00\x00\x00\x49\x45\x4e\
|
||||
\x44\xae\x42\x60\x82\
|
||||
\x00\x00\x0c\xdf\
|
||||
\x89\
|
||||
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
|
||||
\x00\x00\x10\x00\x00\x00\x10\x08\x06\x00\x00\x00\x1f\xf3\xff\x61\
|
||||
\x00\x00\x00\x09\x70\x48\x59\x73\x00\x00\x0b\x13\x00\x00\x0b\x13\
|
||||
\x01\x00\x9a\x9c\x18\x00\x00\x0a\x4f\x69\x43\x43\x50\x50\x68\x6f\
|
||||
\x74\x6f\x73\x68\x6f\x70\x20\x49\x43\x43\x20\x70\x72\x6f\x66\x69\
|
||||
\x6c\x65\x00\x00\x78\xda\x9d\x53\x67\x54\x53\xe9\x16\x3d\xf7\xde\
|
||||
\xf4\x42\x4b\x88\x80\x94\x4b\x6f\x52\x15\x08\x20\x52\x42\x8b\x80\
|
||||
\x14\x91\x26\x2a\x21\x09\x10\x4a\x88\x21\xa1\xd9\x15\x51\xc1\x11\
|
||||
\x45\x45\x04\x1b\xc8\xa0\x88\x03\x8e\x8e\x80\x8c\x15\x51\x2c\x0c\
|
||||
\x8a\x0a\xd8\x07\xe4\x21\xa2\x8e\x83\xa3\x88\x8a\xca\xfb\xe1\x7b\
|
||||
\xa3\x6b\xd6\xbc\xf7\xe6\xcd\xfe\xb5\xd7\x3e\xe7\xac\xf3\x9d\xb3\
|
||||
\xcf\x07\xc0\x08\x0c\x96\x48\x33\x51\x35\x80\x0c\xa9\x42\x1e\x11\
|
||||
\xe0\x83\xc7\xc4\xc6\xe1\xe4\x2e\x40\x81\x0a\x24\x70\x00\x10\x08\
|
||||
\xb3\x64\x21\x73\xfd\x23\x01\x00\xf8\x7e\x3c\x3c\x2b\x22\xc0\x07\
|
||||
\xbe\x00\x01\x78\xd3\x0b\x08\x00\xc0\x4d\x9b\xc0\x30\x1c\x87\xff\
|
||||
\x0f\xea\x42\x99\x5c\x01\x80\x84\x01\xc0\x74\x91\x38\x4b\x08\x80\
|
||||
\x14\x00\x40\x7a\x8e\x42\xa6\x00\x40\x46\x01\x80\x9d\x98\x26\x53\
|
||||
\x00\xa0\x04\x00\x60\xcb\x63\x62\xe3\x00\x50\x2d\x00\x60\x27\x7f\
|
||||
\xe6\xd3\x00\x80\x9d\xf8\x99\x7b\x01\x00\x5b\x94\x21\x15\x01\xa0\
|
||||
\x91\x00\x20\x13\x65\x88\x44\x00\x68\x3b\x00\xac\xcf\x56\x8a\x45\
|
||||
\x00\x58\x30\x00\x14\x66\x4b\xc4\x39\x00\xd8\x2d\x00\x30\x49\x57\
|
||||
\x66\x48\x00\xb0\xb7\x00\xc0\xce\x10\x0b\xb2\x00\x08\x0c\x00\x30\
|
||||
\x51\x88\x85\x29\x00\x04\x7b\x00\x60\xc8\x23\x23\x78\x00\x84\x99\
|
||||
\x00\x14\x46\xf2\x57\x3c\xf1\x2b\xae\x10\xe7\x2a\x00\x00\x78\x99\
|
||||
\xb2\x3c\xb9\x24\x39\x45\x81\x5b\x08\x2d\x71\x07\x57\x57\x2e\x1e\
|
||||
\x28\xce\x49\x17\x2b\x14\x36\x61\x02\x61\x9a\x40\x2e\xc2\x79\x99\
|
||||
\x19\x32\x81\x34\x0f\xe0\xf3\xcc\x00\x00\xa0\x91\x15\x11\xe0\x83\
|
||||
\xf3\xfd\x78\xce\x0e\xae\xce\xce\x36\x8e\xb6\x0e\x5f\x2d\xea\xbf\
|
||||
\x06\xff\x22\x62\x62\xe3\xfe\xe5\xcf\xab\x70\x40\x00\x00\xe1\x74\
|
||||
\x7e\xd1\xfe\x2c\x2f\xb3\x1a\x80\x3b\x06\x80\x6d\xfe\xa2\x25\xee\
|
||||
\x04\x68\x5e\x0b\xa0\x75\xf7\x8b\x66\xb2\x0f\x40\xb5\x00\xa0\xe9\
|
||||
\xda\x57\xf3\x70\xf8\x7e\x3c\x3c\x45\xa1\x90\xb9\xd9\xd9\xe5\xe4\
|
||||
\xe4\xd8\x4a\xc4\x42\x5b\x61\xca\x57\x7d\xfe\x67\xc2\x5f\xc0\x57\
|
||||
\xfd\x6c\xf9\x7e\x3c\xfc\xf7\xf5\xe0\xbe\xe2\x24\x81\x32\x5d\x81\
|
||||
\x47\x04\xf8\xe0\xc2\xcc\xf4\x4c\xa5\x1c\xcf\x92\x09\x84\x62\xdc\
|
||||
\xe6\x8f\x47\xfc\xb7\x0b\xff\xfc\x1d\xd3\x22\xc4\x49\x62\xb9\x58\
|
||||
\x2a\x14\xe3\x51\x12\x71\x8e\x44\x9a\x8c\xf3\x32\xa5\x22\x89\x42\
|
||||
\x92\x29\xc5\x25\xd2\xff\x64\xe2\xdf\x2c\xfb\x03\x3e\xdf\x35\x00\
|
||||
\xb0\x6a\x3e\x01\x7b\x91\x2d\xa8\x5d\x63\x03\xf6\x4b\x27\x10\x58\
|
||||
\x74\xc0\xe2\xf7\x00\x00\xf2\xbb\x6f\xc1\xd4\x28\x08\x03\x80\x68\
|
||||
\x83\xe1\xcf\x77\xff\xef\x3f\xfd\x47\xa0\x25\x00\x80\x66\x49\x92\
|
||||
\x71\x00\x00\x5e\x44\x24\x2e\x54\xca\xb3\x3f\xc7\x08\x00\x00\x44\
|
||||
\xa0\x81\x2a\xb0\x41\x1b\xf4\xc1\x18\x2c\xc0\x06\x1c\xc1\x05\xdc\
|
||||
\xc1\x0b\xfc\x60\x36\x84\x42\x24\xc4\xc2\x42\x10\x42\x0a\x64\x80\
|
||||
\x1c\x72\x60\x29\xac\x82\x42\x28\x86\xcd\xb0\x1d\x2a\x60\x2f\xd4\
|
||||
\x40\x1d\x34\xc0\x51\x68\x86\x93\x70\x0e\x2e\xc2\x55\xb8\x0e\x3d\
|
||||
\x70\x0f\xfa\x61\x08\x9e\xc1\x28\xbc\x81\x09\x04\x41\xc8\x08\x13\
|
||||
\x61\x21\xda\x88\x01\x62\x8a\x58\x23\x8e\x08\x17\x99\x85\xf8\x21\
|
||||
\xc1\x48\x04\x12\x8b\x24\x20\xc9\x88\x14\x51\x22\x4b\x91\x35\x48\
|
||||
\x31\x52\x8a\x54\x20\x55\x48\x1d\xf2\x3d\x72\x02\x39\x87\x5c\x46\
|
||||
\xba\x91\x3b\xc8\x00\x32\x82\xfc\x86\xbc\x47\x31\x94\x81\xb2\x51\
|
||||
\x3d\xd4\x0c\xb5\x43\xb9\xa8\x37\x1a\x84\x46\xa2\x0b\xd0\x64\x74\
|
||||
\x31\x9a\x8f\x16\xa0\x9b\xd0\x72\xb4\x1a\x3d\x8c\x36\xa1\xe7\xd0\
|
||||
\xab\x68\x0f\xda\x8f\x3e\x43\xc7\x30\xc0\xe8\x18\x07\x33\xc4\x6c\
|
||||
\x30\x2e\xc6\xc3\x42\xb1\x38\x2c\x09\x93\x63\xcb\xb1\x22\xac\x0c\
|
||||
\xab\xc6\x1a\xb0\x56\xac\x03\xbb\x89\xf5\x63\xcf\xb1\x77\x04\x12\
|
||||
\x81\x45\xc0\x09\x36\x04\x77\x42\x20\x61\x1e\x41\x48\x58\x4c\x58\
|
||||
\x4e\xd8\x48\xa8\x20\x1c\x24\x34\x11\xda\x09\x37\x09\x03\x84\x51\
|
||||
\xc2\x27\x22\x93\xa8\x4b\xb4\x26\xba\x11\xf9\xc4\x18\x62\x32\x31\
|
||||
\x87\x58\x48\x2c\x23\xd6\x12\x8f\x13\x2f\x10\x7b\x88\x43\xc4\x37\
|
||||
\x24\x12\x89\x43\x32\x27\xb9\x90\x02\x49\xb1\xa4\x54\xd2\x12\xd2\
|
||||
\x46\xd2\x6e\x52\x23\xe9\x2c\xa9\x9b\x34\x48\x1a\x23\x93\xc9\xda\
|
||||
\x64\x6b\xb2\x07\x39\x94\x2c\x20\x2b\xc8\x85\xe4\x9d\xe4\xc3\xe4\
|
||||
\x33\xe4\x1b\xe4\x21\xf2\x5b\x0a\x9d\x62\x40\x71\xa4\xf8\x53\xe2\
|
||||
\x28\x52\xca\x6a\x4a\x19\xe5\x10\xe5\x34\xe5\x06\x65\x98\x32\x41\
|
||||
\x55\xa3\x9a\x52\xdd\xa8\xa1\x54\x11\x35\x8f\x5a\x42\xad\xa1\xb6\
|
||||
\x52\xaf\x51\x87\xa8\x13\x34\x75\x9a\x39\xcd\x83\x16\x49\x4b\xa5\
|
||||
\xad\xa2\x95\xd3\x1a\x68\x17\x68\xf7\x69\xaf\xe8\x74\xba\x11\xdd\
|
||||
\x95\x1e\x4e\x97\xd0\x57\xd2\xcb\xe9\x47\xe8\x97\xe8\x03\xf4\x77\
|
||||
\x0c\x0d\x86\x15\x83\xc7\x88\x67\x28\x19\x9b\x18\x07\x18\x67\x19\
|
||||
\x77\x18\xaf\x98\x4c\xa6\x19\xd3\x8b\x19\xc7\x54\x30\x37\x31\xeb\
|
||||
\x98\xe7\x99\x0f\x99\x6f\x55\x58\x2a\xb6\x2a\x7c\x15\x91\xca\x0a\
|
||||
\x95\x4a\x95\x26\x95\x1b\x2a\x2f\x54\xa9\xaa\xa6\xaa\xde\xaa\x0b\
|
||||
\x55\xf3\x55\xcb\x54\x8f\xa9\x5e\x53\x7d\xae\x46\x55\x33\x53\xe3\
|
||||
\xa9\x09\xd4\x96\xab\x55\xaa\x9d\x50\xeb\x53\x1b\x53\x67\xa9\x3b\
|
||||
\xa8\x87\xaa\x67\xa8\x6f\x54\x3f\xa4\x7e\x59\xfd\x89\x06\x59\xc3\
|
||||
\x4c\xc3\x4f\x43\xa4\x51\xa0\xb1\x5f\xe3\xbc\xc6\x20\x0b\x63\x19\
|
||||
\xb3\x78\x2c\x21\x6b\x0d\xab\x86\x75\x81\x35\xc4\x26\xb1\xcd\xd9\
|
||||
\x7c\x76\x2a\xbb\x98\xfd\x1d\xbb\x8b\x3d\xaa\xa9\xa1\x39\x43\x33\
|
||||
\x4a\x33\x57\xb3\x52\xf3\x94\x66\x3f\x07\xe3\x98\x71\xf8\x9c\x74\
|
||||
\x4e\x09\xe7\x28\xa7\x97\xf3\x7e\x8a\xde\x14\xef\x29\xe2\x29\x1b\
|
||||
\xa6\x34\x4c\xb9\x31\x65\x5c\x6b\xaa\x96\x97\x96\x58\xab\x48\xab\
|
||||
\x51\xab\x47\xeb\xbd\x36\xae\xed\xa7\x9d\xa6\xbd\x45\xbb\x59\xfb\
|
||||
\x81\x0e\x41\xc7\x4a\x27\x5c\x27\x47\x67\x8f\xce\x05\x9d\xe7\x53\
|
||||
\xd9\x53\xdd\xa7\x0a\xa7\x16\x4d\x3d\x3a\xf5\xae\x2e\xaa\x6b\xa5\
|
||||
\x1b\xa1\xbb\x44\x77\xbf\x6e\xa7\xee\x98\x9e\xbe\x5e\x80\x9e\x4c\
|
||||
\x6f\xa7\xde\x79\xbd\xe7\xfa\x1c\x7d\x2f\xfd\x54\xfd\x6d\xfa\xa7\
|
||||
\xf5\x47\x0c\x58\x06\xb3\x0c\x24\x06\xdb\x0c\xce\x18\x3c\xc5\x35\
|
||||
\x71\x6f\x3c\x1d\x2f\xc7\xdb\xf1\x51\x43\x5d\xc3\x40\x43\xa5\x61\
|
||||
\x95\x61\x97\xe1\x84\x91\xb9\xd1\x3c\xa3\xd5\x46\x8d\x46\x0f\x8c\
|
||||
\x69\xc6\x5c\xe3\x24\xe3\x6d\xc6\x6d\xc6\xa3\x26\x06\x26\x21\x26\
|
||||
\x4b\x4d\xea\x4d\xee\x9a\x52\x4d\xb9\xa6\x29\xa6\x3b\x4c\x3b\x4c\
|
||||
\xc7\xcd\xcc\xcd\xa2\xcd\xd6\x99\x35\x9b\x3d\x31\xd7\x32\xe7\x9b\
|
||||
\xe7\x9b\xd7\x9b\xdf\xb7\x60\x5a\x78\x5a\x2c\xb6\xa8\xb6\xb8\x65\
|
||||
\x49\xb2\xe4\x5a\xa6\x59\xee\xb6\xbc\x6e\x85\x5a\x39\x59\xa5\x58\
|
||||
\x55\x5a\x5d\xb3\x46\xad\x9d\xad\x25\xd6\xbb\xad\xbb\xa7\x11\xa7\
|
||||
\xb9\x4e\x93\x4e\xab\x9e\xd6\x67\xc3\xb0\xf1\xb6\xc9\xb6\xa9\xb7\
|
||||
\x19\xb0\xe5\xd8\x06\xdb\xae\xb6\x6d\xb6\x7d\x61\x67\x62\x17\x67\
|
||||
\xb7\xc5\xae\xc3\xee\x93\xbd\x93\x7d\xba\x7d\x8d\xfd\x3d\x07\x0d\
|
||||
\x87\xd9\x0e\xab\x1d\x5a\x1d\x7e\x73\xb4\x72\x14\x3a\x56\x3a\xde\
|
||||
\x9a\xce\x9c\xee\x3f\x7d\xc5\xf4\x96\xe9\x2f\x67\x58\xcf\x10\xcf\
|
||||
\xd8\x33\xe3\xb6\x13\xcb\x29\xc4\x69\x9d\x53\x9b\xd3\x47\x67\x17\
|
||||
\x67\xb9\x73\x83\xf3\x88\x8b\x89\x4b\x82\xcb\x2e\x97\x3e\x2e\x9b\
|
||||
\x1b\xc6\xdd\xc8\xbd\xe4\x4a\x74\xf5\x71\x5d\xe1\x7a\xd2\xf5\x9d\
|
||||
\x9b\xb3\x9b\xc2\xed\xa8\xdb\xaf\xee\x36\xee\x69\xee\x87\xdc\x9f\
|
||||
\xcc\x34\x9f\x29\x9e\x59\x33\x73\xd0\xc3\xc8\x43\xe0\x51\xe5\xd1\
|
||||
\x3f\x0b\x9f\x95\x30\x6b\xdf\xac\x7e\x4f\x43\x4f\x81\x67\xb5\xe7\
|
||||
\x23\x2f\x63\x2f\x91\x57\xad\xd7\xb0\xb7\xa5\x77\xaa\xf7\x61\xef\
|
||||
\x17\x3e\xf6\x3e\x72\x9f\xe3\x3e\xe3\x3c\x37\xde\x32\xde\x59\x5f\
|
||||
\xcc\x37\xc0\xb7\xc8\xb7\xcb\x4f\xc3\x6f\x9e\x5f\x85\xdf\x43\x7f\
|
||||
\x23\xff\x64\xff\x7a\xff\xd1\x00\xa7\x80\x25\x01\x67\x03\x89\x81\
|
||||
\x41\x81\x5b\x02\xfb\xf8\x7a\x7c\x21\xbf\x8e\x3f\x3a\xdb\x65\xf6\
|
||||
\xb2\xd9\xed\x41\x8c\xa0\xb9\x41\x15\x41\x8f\x82\xad\x82\xe5\xc1\
|
||||
\xad\x21\x68\xc8\xec\x90\xad\x21\xf7\xe7\x98\xce\x91\xce\x69\x0e\
|
||||
\x85\x50\x7e\xe8\xd6\xd0\x07\x61\xe6\x61\x8b\xc3\x7e\x0c\x27\x85\
|
||||
\x87\x85\x57\x86\x3f\x8e\x70\x88\x58\x1a\xd1\x31\x97\x35\x77\xd1\
|
||||
\xdc\x43\x73\xdf\x44\xfa\x44\x96\x44\xde\x9b\x67\x31\x4f\x39\xaf\
|
||||
\x2d\x4a\x35\x2a\x3e\xaa\x2e\x6a\x3c\xda\x37\xba\x34\xba\x3f\xc6\
|
||||
\x2e\x66\x59\xcc\xd5\x58\x9d\x58\x49\x6c\x4b\x1c\x39\x2e\x2a\xae\
|
||||
\x36\x6e\x6c\xbe\xdf\xfc\xed\xf3\x87\xe2\x9d\xe2\x0b\xe3\x7b\x17\
|
||||
\x98\x2f\xc8\x5d\x70\x79\xa1\xce\xc2\xf4\x85\xa7\x16\xa9\x2e\x12\
|
||||
\x2c\x3a\x96\x40\x4c\x88\x4e\x38\x94\xf0\x41\x10\x2a\xa8\x16\x8c\
|
||||
\x25\xf2\x13\x77\x25\x8e\x0a\x79\xc2\x1d\xc2\x67\x22\x2f\xd1\x36\
|
||||
\xd1\x88\xd8\x43\x5c\x2a\x1e\x4e\xf2\x48\x2a\x4d\x7a\x92\xec\x91\
|
||||
\xbc\x35\x79\x24\xc5\x33\xa5\x2c\xe5\xb9\x84\x27\xa9\x90\xbc\x4c\
|
||||
\x0d\x4c\xdd\x9b\x3a\x9e\x16\x9a\x76\x20\x6d\x32\x3d\x3a\xbd\x31\
|
||||
\x83\x92\x91\x90\x71\x42\xaa\x21\x4d\x93\xb6\x67\xea\x67\xe6\x66\
|
||||
\x76\xcb\xac\x65\x85\xb2\xfe\xc5\x6e\x8b\xb7\x2f\x1e\x95\x07\xc9\
|
||||
\x6b\xb3\x90\xac\x05\x59\x2d\x0a\xb6\x42\xa6\xe8\x54\x5a\x28\xd7\
|
||||
\x2a\x07\xb2\x67\x65\x57\x66\xbf\xcd\x89\xca\x39\x96\xab\x9e\x2b\
|
||||
\xcd\xed\xcc\xb3\xca\xdb\x90\x37\x9c\xef\x9f\xff\xed\x12\xc2\x12\
|
||||
\xe1\x92\xb6\xa5\x86\x4b\x57\x2d\x1d\x58\xe6\xbd\xac\x6a\x39\xb2\
|
||||
\x3c\x71\x79\xdb\x0a\xe3\x15\x05\x2b\x86\x56\x06\xac\x3c\xb8\x8a\
|
||||
\xb6\x2a\x6d\xd5\x4f\xab\xed\x57\x97\xae\x7e\xbd\x26\x7a\x4d\x6b\
|
||||
\x81\x5e\xc1\xca\x82\xc1\xb5\x01\x6b\xeb\x0b\x55\x0a\xe5\x85\x7d\
|
||||
\xeb\xdc\xd7\xed\x5d\x4f\x58\x2f\x59\xdf\xb5\x61\xfa\x86\x9d\x1b\
|
||||
\x3e\x15\x89\x8a\xae\x14\xdb\x17\x97\x15\x7f\xd8\x28\xdc\x78\xe5\
|
||||
\x1b\x87\x6f\xca\xbf\x99\xdc\x94\xb4\xa9\xab\xc4\xb9\x64\xcf\x66\
|
||||
\xd2\x66\xe9\xe6\xde\x2d\x9e\x5b\x0e\x96\xaa\x97\xe6\x97\x0e\x6e\
|
||||
\x0d\xd9\xda\xb4\x0d\xdf\x56\xb4\xed\xf5\xf6\x45\xdb\x2f\x97\xcd\
|
||||
\x28\xdb\xbb\x83\xb6\x43\xb9\xa3\xbf\x3c\xb8\xbc\x65\xa7\xc9\xce\
|
||||
\xcd\x3b\x3f\x54\xa4\x54\xf4\x54\xfa\x54\x36\xee\xd2\xdd\xb5\x61\
|
||||
\xd7\xf8\x6e\xd1\xee\x1b\x7b\xbc\xf6\x34\xec\xd5\xdb\x5b\xbc\xf7\
|
||||
\xfd\x3e\xc9\xbe\xdb\x55\x01\x55\x4d\xd5\x66\xd5\x65\xfb\x49\xfb\
|
||||
\xb3\xf7\x3f\xae\x89\xaa\xe9\xf8\x96\xfb\x6d\x5d\xad\x4e\x6d\x71\
|
||||
\xed\xc7\x03\xd2\x03\xfd\x07\x23\x0e\xb6\xd7\xb9\xd4\xd5\x1d\xd2\
|
||||
\x3d\x54\x52\x8f\xd6\x2b\xeb\x47\x0e\xc7\x1f\xbe\xfe\x9d\xef\x77\
|
||||
\x2d\x0d\x36\x0d\x55\x8d\x9c\xc6\xe2\x23\x70\x44\x79\xe4\xe9\xf7\
|
||||
\x09\xdf\xf7\x1e\x0d\x3a\xda\x76\x8c\x7b\xac\xe1\x07\xd3\x1f\x76\
|
||||
\x1d\x67\x1d\x2f\x6a\x42\x9a\xf2\x9a\x46\x9b\x53\x9a\xfb\x5b\x62\
|
||||
\x5b\xba\x4f\xcc\x3e\xd1\xd6\xea\xde\x7a\xfc\x47\xdb\x1f\x0f\x9c\
|
||||
\x34\x3c\x59\x79\x4a\xf3\x54\xc9\x69\xda\xe9\x82\xd3\x93\x67\xf2\
|
||||
\xcf\x8c\x9d\x95\x9d\x7d\x7e\x2e\xf9\xdc\x60\xdb\xa2\xb6\x7b\xe7\
|
||||
\x63\xce\xdf\x6a\x0f\x6f\xef\xba\x10\x74\xe1\xd2\x45\xff\x8b\xe7\
|
||||
\x3b\xbc\x3b\xce\x5c\xf2\xb8\x74\xf2\xb2\xdb\xe5\x13\x57\xb8\x57\
|
||||
\x9a\xaf\x3a\x5f\x6d\xea\x74\xea\x3c\xfe\x93\xd3\x4f\xc7\xbb\x9c\
|
||||
\xbb\x9a\xae\xb9\x5c\x6b\xb9\xee\x7a\xbd\xb5\x7b\x66\xf7\xe9\x1b\
|
||||
\x9e\x37\xce\xdd\xf4\xbd\x79\xf1\x16\xff\xd6\xd5\x9e\x39\x3d\xdd\
|
||||
\xbd\xf3\x7a\x6f\xf7\xc5\xf7\xf5\xdf\x16\xdd\x7e\x72\x27\xfd\xce\
|
||||
\xcb\xbb\xd9\x77\x27\xee\xad\xbc\x4f\xbc\x5f\xf4\x40\xed\x41\xd9\
|
||||
\x43\xdd\x87\xd5\x3f\x5b\xfe\xdc\xd8\xef\xdc\x7f\x6a\xc0\x77\xa0\
|
||||
\xf3\xd1\xdc\x47\xf7\x06\x85\x83\xcf\xfe\x91\xf5\x8f\x0f\x43\x05\
|
||||
\x8f\x99\x8f\xcb\x86\x0d\x86\xeb\x9e\x38\x3e\x39\x39\xe2\x3f\x72\
|
||||
\xfd\xe9\xfc\xa7\x43\xcf\x64\xcf\x26\x9e\x17\xfe\xa2\xfe\xcb\xae\
|
||||
\x17\x16\x2f\x7e\xf8\xd5\xeb\xd7\xce\xd1\x98\xd1\xa1\x97\xf2\x97\
|
||||
\x93\xbf\x6d\x7c\xa5\xfd\xea\xc0\xeb\x19\xaf\xdb\xc6\xc2\xc6\x1e\
|
||||
\xbe\xc9\x78\x33\x31\x5e\xf4\x56\xfb\xed\xc1\x77\xdc\x77\x1d\xef\
|
||||
\xa3\xdf\x0f\x4f\xe4\x7c\x20\x7f\x28\xff\x68\xf9\xb1\xf5\x53\xd0\
|
||||
\xa7\xfb\x93\x19\x93\x93\xff\x04\x03\x98\xf3\xfc\x63\x33\x2d\xdb\
|
||||
\x00\x00\x00\x20\x63\x48\x52\x4d\x00\x00\x7a\x25\x00\x00\x80\x83\
|
||||
\x00\x00\xf9\xff\x00\x00\x80\xe9\x00\x00\x75\x30\x00\x00\xea\x60\
|
||||
\x00\x00\x3a\x98\x00\x00\x17\x6f\x92\x5f\xc5\x46\x00\x00\x02\x0a\
|
||||
\x49\x44\x41\x54\x78\xda\x64\xd1\x4d\xab\x1c\x45\x18\xc5\xf1\x5f\
|
||||
\xdf\x69\x1a\xc6\x5c\xbc\x12\x74\x1b\x10\x84\x08\x92\xe0\x07\x30\
|
||||
\xb8\x0a\x8c\x9b\x04\xfc\x0a\x42\xc4\x95\xa2\x5b\x97\x82\x2b\x05\
|
||||
\x51\x70\xe5\x87\x88\x2b\xc1\x95\xe0\x3e\x82\x2b\x21\x20\x64\xe7\
|
||||
\xdb\x9d\x3b\xd3\x3d\xfd\x52\xd5\x35\xed\xa2\x2a\xde\x01\x1b\x0e\
|
||||
\x0f\x05\x7d\xce\xff\xd4\x53\xd5\x72\xf7\x2e\x37\x6f\x72\x71\xc1\
|
||||
\x8d\x1b\x34\xcd\x6d\x55\xf5\x48\x4a\x6f\x0b\xe1\x4d\xd3\xc4\x30\
|
||||
\xfc\xe2\x70\xf8\xc9\xe1\xf0\xad\xae\x7b\xaa\xef\xe9\x7b\xa6\x49\
|
||||
\xb5\xdc\xbb\x97\x03\xce\xcf\x69\x9a\x8f\x55\xd5\x67\xe6\x79\x6d\
|
||||
\x9a\x18\xc7\xac\x1c\x42\xdf\x0f\xfa\xfe\x53\x7d\xff\xa5\x61\x20\
|
||||
\x04\xb5\xf3\x73\xd6\xeb\xc6\x6a\xf5\xd8\xf1\xb8\x31\xcf\xf9\xe7\
|
||||
\xc3\x21\xcf\x69\x22\x46\x42\x60\x1c\xd7\xa6\xe9\x0b\xd3\x74\x5f\
|
||||
\x08\x0f\x85\x10\x6a\x4d\x03\x5f\x9b\xe7\x8d\x18\xb3\xa9\x6d\xe9\
|
||||
\xba\x4c\x0f\x81\x94\xb2\x72\x08\xc3\xb0\x59\xc6\xf1\xf3\xc8\x27\
|
||||
\xd5\xf2\xe0\xc1\x1d\x75\xfd\x44\x4a\x2b\xc3\xc0\x6e\x97\xd5\x75\
|
||||
\x99\x9e\x12\xcb\x92\x95\x12\xe3\x28\xc5\xa8\x27\x05\xde\xa8\x85\
|
||||
\xf0\x48\x8c\x2b\xe3\x98\xc9\xdb\x2d\x57\x57\xb9\x49\x8c\xd9\x08\
|
||||
\x55\xc5\x3c\x0b\xcb\x62\x40\xcf\x6a\xe2\x83\x5a\xdf\x6f\xa4\x74\
|
||||
\x5d\xbd\x6d\xf3\x86\x43\xe0\x78\x74\xfa\xc5\x62\x3e\x14\x0d\xbc\
|
||||
\x55\xeb\xba\x5b\xff\x5b\x5c\x8c\xd9\xfc\x9c\x8e\x05\x11\x53\xa6\
|
||||
\x6b\xf3\xbc\x55\x6b\x5b\xe6\xd9\x7f\xcf\x16\xe3\xf5\xbd\x4f\xcc\
|
||||
\x09\x73\xa6\x3a\x5c\x07\xa8\xb5\xed\x33\x31\xbe\x26\x46\xcf\xb5\
|
||||
\x9c\x98\xe1\x58\xe8\x03\x3a\xec\x8b\x26\x9e\x9d\xd9\xef\x7f\xb0\
|
||||
\xdb\xb1\xdf\x4b\xc3\x20\xa6\x24\x14\x5a\x3a\xa9\xdd\xe1\x0a\x97\
|
||||
\x45\xfb\x1c\xf8\x73\x95\xb8\x33\xf2\x24\xb2\x9a\x4b\x5d\xa8\xca\
|
||||
\x4c\x18\x4b\xe5\xbf\xf1\x0f\x76\x08\xa4\x86\xd7\xeb\x9e\x5f\x07\
|
||||
\xbe\x19\xf9\x30\x16\xf2\xf1\xc4\x3c\x97\xbb\xee\xb1\x2d\xe6\x09\
|
||||
\x67\x7c\xb5\xe6\x69\x75\x99\xeb\x35\x07\x1e\x0f\x6c\x42\x31\x9e\
|
||||
\xd6\x1f\x4a\x40\x57\xce\xf8\xfe\x05\xde\x7d\x99\x74\x76\xcc\xc4\
|
||||
\x10\x79\x67\xe4\xa3\x8e\x6e\x8b\xbf\xf0\x27\xfe\x28\xba\xcc\xdb\
|
||||
\xef\x12\xef\x37\x3c\x7c\x91\xf4\x12\xaa\x6d\x79\x96\x7d\xa9\xb7\
|
||||
\xe7\xd5\x8e\xf7\x3a\xee\x0f\xdc\x9e\x72\x93\xdf\x12\x3f\xae\xf8\
|
||||
\x6e\xcd\xef\x17\x78\xa5\xe8\xdf\x01\x00\xd9\x09\x61\x5f\xc2\xb1\
|
||||
\xaf\xf3\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82\
|
||||
\x00\x00\x02\xf0\
|
||||
\x89\
|
||||
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
|
||||
\x00\x00\x10\x00\x00\x00\x10\x08\x06\x00\x00\x00\x1f\xf3\xff\x61\
|
||||
\x00\x00\x00\x19\x74\x45\x58\x74\x53\x6f\x66\x74\x77\x61\x72\x65\
|
||||
\x00\x41\x64\x6f\x62\x65\x20\x49\x6d\x61\x67\x65\x52\x65\x61\x64\
|
||||
\x79\x71\xc9\x65\x3c\x00\x00\x02\x92\x49\x44\x41\x54\x78\xda\x84\
|
||||
\x53\x5f\x48\x53\x61\x14\x3f\xf7\xee\x6e\x22\x0b\x4c\x6b\xac\x60\
|
||||
\x6a\xb5\x39\xdd\x06\x36\xd9\x70\x6b\xb8\x31\xd4\xb2\x35\x82\x3d\
|
||||
\x4c\x50\x50\x08\x1f\x24\x84\x24\x56\xea\xc3\xdc\x2a\x63\x36\x1d\
|
||||
\x4d\xa1\xb0\xf0\xc1\x17\x1f\x7c\xb0\x3f\x0f\x51\x96\x12\xe8\xa6\
|
||||
\x84\xa6\xeb\x45\xa9\x84\x22\x25\x08\xb7\x97\xec\x45\xe6\xee\xdd\
|
||||
\xed\x7c\x97\xb5\x36\x1a\x74\xe0\xc7\xe1\xfb\x9d\xf3\xfb\x9d\xf3\
|
||||
\xdd\x8f\x4b\x41\x4e\xd0\xc5\xc5\x20\xa9\xa8\x80\xc3\xdd\x5d\x48\
|
||||
\x1f\x1c\x40\x75\x43\x03\x68\x6d\x36\xa0\x45\x22\xa0\x69\x5a\x85\
|
||||
\x2d\x8d\x90\x1f\x3f\x18\x28\x10\x4a\xa3\x11\xaa\x4d\x26\x41\x98\
|
||||
\x89\xaa\x74\x3a\xdd\x38\x3b\x34\xf4\xf8\x0f\x41\x21\xdc\x7e\xff\
|
||||
\xd5\x3c\x83\x53\x7a\xbd\x20\x16\x31\x79\x74\x55\x9a\xe3\x9a\x66\
|
||||
\x03\x81\x47\xd1\xf5\x75\xf8\xb0\xb5\x05\x75\x3a\x1d\x58\xb1\x0f\
|
||||
\x79\x4a\xe8\x2c\xaf\xab\x83\xd3\x48\x30\xcc\x3f\x0b\x55\x71\x1c\
|
||||
\xd7\xfc\x34\x18\x9c\xc0\x0c\x89\xfd\x7d\x28\x2d\x2b\xa3\x30\xf3\
|
||||
\xa4\xc8\x11\x03\x53\x47\x07\x88\xc4\xe2\x42\x37\x51\xe3\x84\xf3\
|
||||
\xcf\x42\xa1\x87\xc9\x64\x12\x44\x78\x1d\x8d\x52\x09\xdf\xe3\x71\
|
||||
\xbe\x5c\x2e\x17\x1a\xb0\x4e\xd3\x50\x38\xd4\x2c\xc7\x5d\x78\x82\
|
||||
\xe2\x58\x2c\x06\x57\x70\xc8\xd6\xe6\x26\x9c\x51\x28\xc0\x6e\x30\
|
||||
\x80\xba\xb2\x12\x2e\x79\x3c\xd7\x70\x83\x85\x42\x06\xd5\x1c\xcb\
|
||||
\xb6\x3c\x0f\x87\x1f\xbc\x5f\x5b\x83\xbb\x7e\x3f\x1c\xe0\x8b\xdc\
|
||||
\x1a\x1c\x24\x2b\x0b\x1f\xd6\xd1\xdb\xdb\x8b\xd3\x17\xf0\x1e\xdb\
|
||||
\x4c\x01\xf1\xc5\x17\x13\x13\xe3\xef\x56\x56\xe0\x8e\xd7\x9b\x2d\
|
||||
\x04\x46\x47\x41\x52\x54\x04\x2d\x3d\x3d\xd7\x29\x8a\x9a\x47\xa3\
|
||||
\xcf\x84\xcf\x35\xa8\x61\x59\xd6\xf1\x6a\x72\x32\xbc\xbc\xb4\x04\
|
||||
\xbe\xfe\xfe\x6c\x61\x64\x6c\x0c\x8c\xf5\xf5\xd0\xdc\xdd\xed\x41\
|
||||
\xf1\x1b\x51\x46\x9c\x6b\xa0\x21\xe2\xd7\x53\x53\xf7\x23\x8b\x8b\
|
||||
\xe0\xef\xeb\xcb\x8a\xef\x85\xc3\x60\xb6\x58\xa0\xb1\xab\xeb\x06\
|
||||
\x8a\xe7\x50\xfc\x29\x77\x65\x62\xa0\xe1\x52\x29\xe7\xfc\xf4\x74\
|
||||
\x28\x8a\xe2\x00\xae\x2d\x91\x48\x84\xe2\xed\x60\x10\x2c\x56\x2b\
|
||||
\xd8\x3b\x3b\xfb\x80\x88\x19\x26\x2b\xfe\x8a\xdf\xe7\xcb\xea\x2a\
|
||||
\x30\x38\xf9\xf2\xdb\x99\x99\x91\xbd\x78\x1c\xc6\x87\x87\x41\x2a\
|
||||
\x95\x0a\x0d\x37\x7d\x3e\x41\x6c\x6b\x6f\x1f\xc0\xc9\x2f\x71\xf2\
|
||||
\x47\xc2\xef\xe0\xab\xec\x6c\x6c\xfc\x5d\x41\xdf\xda\xaa\x3d\xeb\
|
||||
\x76\x0f\xfc\xe4\x79\x7e\x2e\x12\xe1\x5d\x2e\x17\x3f\x1f\x8d\xf2\
|
||||
\xbf\xf0\x4c\x78\x52\x37\xb4\xb5\x81\xa2\xb6\xb6\xf0\x83\x9f\xd0\
|
||||
\x6a\xa1\xc6\xe9\xd4\xa9\x1d\x0e\x2f\x31\xd9\xde\xdb\xe3\xf7\x31\
|
||||
\x93\x33\xe1\x49\xfd\x7f\x41\xfe\x98\x92\x12\x95\xaa\x49\x6e\x36\
|
||||
\x0f\x11\x13\x92\x8f\xaa\x54\x76\xe4\x8f\x21\x4a\x49\x1d\x71\x04\
|
||||
\x51\x8c\x28\x42\x88\x33\x3a\x8a\xca\x1c\x4e\x22\x8e\x4b\x64\x32\
|
||||
\x85\x58\x26\x3b\x97\x4a\x24\x96\x0f\x13\x89\x6f\xc8\xa5\x10\x6c\
|
||||
\x26\x13\x1c\xe6\x70\x04\xdc\x6f\x01\x06\x00\x2d\x06\x04\x62\x7f\
|
||||
\xe8\x51\x71\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82\
|
||||
\x00\x00\x02\x75\
|
||||
\x89\
|
||||
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
|
||||
\x00\x00\x10\x00\x00\x00\x10\x08\x06\x00\x00\x00\x1f\xf3\xff\x61\
|
||||
\x00\x00\x00\x19\x74\x45\x58\x74\x53\x6f\x66\x74\x77\x61\x72\x65\
|
||||
\x00\x41\x64\x6f\x62\x65\x20\x49\x6d\x61\x67\x65\x52\x65\x61\x64\
|
||||
\x79\x71\xc9\x65\x3c\x00\x00\x02\x17\x49\x44\x41\x54\x78\xda\xa4\
|
||||
\x93\x4f\x6b\x13\x51\x14\xc5\xcf\x9b\x37\x93\x49\xc6\xa9\x25\xa3\
|
||||
\x15\x63\x16\x2e\x02\x06\xad\x0b\x45\xc1\x95\x5f\xc0\x3f\x0b\x21\
|
||||
\x1b\xa5\x20\xb8\x31\xea\x7c\x82\xac\xf4\x2b\x54\x5b\x23\x88\x1b\
|
||||
\x4b\xb3\x70\xe1\x42\xb7\x82\x20\xe8\x42\xbb\x70\xa1\x62\x36\xa2\
|
||||
\xa0\x51\xda\x1a\xc2\x4c\xa6\x26\x93\xcc\x78\xef\x75\x5a\xb4\x2a\
|
||||
\x54\x7c\x70\xb8\x2f\x93\x7b\x7e\xf7\xbc\x37\x89\xaa\xd5\x6a\x50\
|
||||
\x4a\x9d\x06\xb0\x07\xff\xb6\x3e\xa5\x69\xfa\xc0\x4c\x92\x84\x3f\
|
||||
\x94\x9b\xcd\xe6\xcd\x38\x8e\xb7\xe4\xb4\x2c\x0b\xf5\x7a\xfd\x12\
|
||||
\xef\xcd\xd1\x68\xc4\xd5\x18\x0c\x06\xf0\x7d\x1f\x0c\x64\x11\x5d\
|
||||
\xea\x78\x3c\x46\x18\xf6\xa9\xa6\x62\xf4\x3c\x0f\xf3\xf3\xd7\x41\
|
||||
\x3e\xe3\x67\x80\xe2\xca\x86\x6a\xb5\x0a\x4e\xf2\xed\x68\x05\xa3\
|
||||
\xc7\x2f\xb1\xb2\xf2\x95\x9e\x6b\x32\xdb\xb0\xed\x3c\xa2\x28\x60\
|
||||
\x33\x4b\x09\x20\x8b\x6d\xf0\x43\x9e\xc6\x49\x58\x69\x79\x07\x56\
|
||||
\x57\xbb\x64\x88\x91\xcf\x6f\x13\xb3\x65\xe5\xa9\x27\x16\x00\xf9\
|
||||
\x8c\x0d\x23\x49\x33\x48\x00\x34\x39\x8a\x22\xa8\xbd\xbb\x08\x94\
|
||||
\x60\xf2\x60\x05\xe5\xd9\x3a\x26\x4f\x1c\x13\x90\x69\xda\x92\x90\
|
||||
\x3d\xec\x35\x86\xc3\x21\x48\x3f\x40\xa5\x22\x9d\x37\x84\x73\xed\
|
||||
\xbc\x5c\xd6\xf6\xe9\x0a\x3c\xff\x14\x7a\x8d\x16\x01\x8b\xa8\x35\
|
||||
\xaf\x12\xc0\x94\x04\xec\x61\xef\xc6\x11\xb8\x26\xef\xbf\xa0\xdf\
|
||||
\x5d\x43\xf7\xe1\x53\xb8\x07\xf6\xa1\x78\xf9\x24\xfa\xb7\x1f\xc1\
|
||||
\x75\x8b\x48\x5b\x4b\xb8\x77\xf7\x19\xbf\x72\x49\xb0\x7e\x04\x93\
|
||||
\x29\xb4\x24\x8e\xe3\x38\xe8\xf5\x7a\x30\x0c\x0b\xfa\xed\x07\x84\
|
||||
\xfe\x2c\x0a\x85\x09\x0c\x0c\x2d\x46\x5e\xb6\xad\xd7\x13\x68\x01\
|
||||
\xb4\xdb\x6d\x94\x4a\xa5\x1c\x37\x34\x1a\x8d\x2d\xfd\x0e\xb8\x37\
|
||||
\x08\x82\x5c\xa7\xd3\x01\x63\x3d\xd7\x75\x67\xb4\xd6\xbb\x37\x37\
|
||||
\xd2\xa4\xb2\x4c\x31\xcd\x8f\x9b\xbf\xa3\x0b\xff\x4c\xf7\xb5\xc0\
|
||||
\x80\x02\x69\x82\xfb\x7e\xe9\x98\xce\x01\xaf\x86\x7e\xb6\xbf\x41\
|
||||
\xfb\xdf\xf8\xa4\x40\xfd\x35\xe7\xe2\xd4\x2d\xbc\x89\x8f\xc8\x7e\
|
||||
\xbf\xb5\x84\x73\xcb\x17\xff\xd4\xc6\x53\x77\x92\x2a\xa4\x43\xa4\
|
||||
\xc3\xa4\xaa\x24\x5a\x0c\x71\xe6\xce\x59\x01\xdc\xbf\xd0\xe2\xf2\
|
||||
\x82\x93\x93\xde\x65\xfb\xe7\xa4\xd7\x9c\xc0\xca\x8e\xe1\x66\x72\
|
||||
\xf8\xad\xe0\x8a\x33\x83\x29\x75\x5c\xc6\x2c\xa7\x4f\x30\x17\x2d\
|
||||
\x64\x43\xd7\x38\x7a\xa6\x48\xf1\x9f\xe6\x7f\xd6\x77\x01\x06\x00\
|
||||
\xf9\x1f\x11\xa0\x42\x25\x9c\x34\x00\x00\x00\x00\x49\x45\x4e\x44\
|
||||
\xae\x42\x60\x82\
|
||||
\x00\x00\x0d\x2a\
|
||||
\x89\
|
||||
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
|
||||
\x00\x00\x10\x00\x00\x00\x10\x08\x06\x00\x00\x00\x1f\xf3\xff\x61\
|
||||
\x00\x00\x00\x09\x70\x48\x59\x73\x00\x00\x0b\x13\x00\x00\x0b\x13\
|
||||
\x01\x00\x9a\x9c\x18\x00\x00\x0a\x4f\x69\x43\x43\x50\x50\x68\x6f\
|
||||
\x74\x6f\x73\x68\x6f\x70\x20\x49\x43\x43\x20\x70\x72\x6f\x66\x69\
|
||||
\x6c\x65\x00\x00\x78\xda\x9d\x53\x67\x54\x53\xe9\x16\x3d\xf7\xde\
|
||||
\xf4\x42\x4b\x88\x80\x94\x4b\x6f\x52\x15\x08\x20\x52\x42\x8b\x80\
|
||||
\x14\x91\x26\x2a\x21\x09\x10\x4a\x88\x21\xa1\xd9\x15\x51\xc1\x11\
|
||||
\x45\x45\x04\x1b\xc8\xa0\x88\x03\x8e\x8e\x80\x8c\x15\x51\x2c\x0c\
|
||||
\x8a\x0a\xd8\x07\xe4\x21\xa2\x8e\x83\xa3\x88\x8a\xca\xfb\xe1\x7b\
|
||||
\xa3\x6b\xd6\xbc\xf7\xe6\xcd\xfe\xb5\xd7\x3e\xe7\xac\xf3\x9d\xb3\
|
||||
\xcf\x07\xc0\x08\x0c\x96\x48\x33\x51\x35\x80\x0c\xa9\x42\x1e\x11\
|
||||
\xe0\x83\xc7\xc4\xc6\xe1\xe4\x2e\x40\x81\x0a\x24\x70\x00\x10\x08\
|
||||
\xb3\x64\x21\x73\xfd\x23\x01\x00\xf8\x7e\x3c\x3c\x2b\x22\xc0\x07\
|
||||
\xbe\x00\x01\x78\xd3\x0b\x08\x00\xc0\x4d\x9b\xc0\x30\x1c\x87\xff\
|
||||
\x0f\xea\x42\x99\x5c\x01\x80\x84\x01\xc0\x74\x91\x38\x4b\x08\x80\
|
||||
\x14\x00\x40\x7a\x8e\x42\xa6\x00\x40\x46\x01\x80\x9d\x98\x26\x53\
|
||||
\x00\xa0\x04\x00\x60\xcb\x63\x62\xe3\x00\x50\x2d\x00\x60\x27\x7f\
|
||||
\xe6\xd3\x00\x80\x9d\xf8\x99\x7b\x01\x00\x5b\x94\x21\x15\x01\xa0\
|
||||
\x91\x00\x20\x13\x65\x88\x44\x00\x68\x3b\x00\xac\xcf\x56\x8a\x45\
|
||||
\x00\x58\x30\x00\x14\x66\x4b\xc4\x39\x00\xd8\x2d\x00\x30\x49\x57\
|
||||
\x66\x48\x00\xb0\xb7\x00\xc0\xce\x10\x0b\xb2\x00\x08\x0c\x00\x30\
|
||||
\x51\x88\x85\x29\x00\x04\x7b\x00\x60\xc8\x23\x23\x78\x00\x84\x99\
|
||||
\x00\x14\x46\xf2\x57\x3c\xf1\x2b\xae\x10\xe7\x2a\x00\x00\x78\x99\
|
||||
\xb2\x3c\xb9\x24\x39\x45\x81\x5b\x08\x2d\x71\x07\x57\x57\x2e\x1e\
|
||||
\x28\xce\x49\x17\x2b\x14\x36\x61\x02\x61\x9a\x40\x2e\xc2\x79\x99\
|
||||
\x19\x32\x81\x34\x0f\xe0\xf3\xcc\x00\x00\xa0\x91\x15\x11\xe0\x83\
|
||||
\xf3\xfd\x78\xce\x0e\xae\xce\xce\x36\x8e\xb6\x0e\x5f\x2d\xea\xbf\
|
||||
\x06\xff\x22\x62\x62\xe3\xfe\xe5\xcf\xab\x70\x40\x00\x00\xe1\x74\
|
||||
\x7e\xd1\xfe\x2c\x2f\xb3\x1a\x80\x3b\x06\x80\x6d\xfe\xa2\x25\xee\
|
||||
\x04\x68\x5e\x0b\xa0\x75\xf7\x8b\x66\xb2\x0f\x40\xb5\x00\xa0\xe9\
|
||||
\xda\x57\xf3\x70\xf8\x7e\x3c\x3c\x45\xa1\x90\xb9\xd9\xd9\xe5\xe4\
|
||||
\xe4\xd8\x4a\xc4\x42\x5b\x61\xca\x57\x7d\xfe\x67\xc2\x5f\xc0\x57\
|
||||
\xfd\x6c\xf9\x7e\x3c\xfc\xf7\xf5\xe0\xbe\xe2\x24\x81\x32\x5d\x81\
|
||||
\x47\x04\xf8\xe0\xc2\xcc\xf4\x4c\xa5\x1c\xcf\x92\x09\x84\x62\xdc\
|
||||
\xe6\x8f\x47\xfc\xb7\x0b\xff\xfc\x1d\xd3\x22\xc4\x49\x62\xb9\x58\
|
||||
\x2a\x14\xe3\x51\x12\x71\x8e\x44\x9a\x8c\xf3\x32\xa5\x22\x89\x42\
|
||||
\x92\x29\xc5\x25\xd2\xff\x64\xe2\xdf\x2c\xfb\x03\x3e\xdf\x35\x00\
|
||||
\xb0\x6a\x3e\x01\x7b\x91\x2d\xa8\x5d\x63\x03\xf6\x4b\x27\x10\x58\
|
||||
\x74\xc0\xe2\xf7\x00\x00\xf2\xbb\x6f\xc1\xd4\x28\x08\x03\x80\x68\
|
||||
\x83\xe1\xcf\x77\xff\xef\x3f\xfd\x47\xa0\x25\x00\x80\x66\x49\x92\
|
||||
\x71\x00\x00\x5e\x44\x24\x2e\x54\xca\xb3\x3f\xc7\x08\x00\x00\x44\
|
||||
\xa0\x81\x2a\xb0\x41\x1b\xf4\xc1\x18\x2c\xc0\x06\x1c\xc1\x05\xdc\
|
||||
\xc1\x0b\xfc\x60\x36\x84\x42\x24\xc4\xc2\x42\x10\x42\x0a\x64\x80\
|
||||
\x1c\x72\x60\x29\xac\x82\x42\x28\x86\xcd\xb0\x1d\x2a\x60\x2f\xd4\
|
||||
\x40\x1d\x34\xc0\x51\x68\x86\x93\x70\x0e\x2e\xc2\x55\xb8\x0e\x3d\
|
||||
\x70\x0f\xfa\x61\x08\x9e\xc1\x28\xbc\x81\x09\x04\x41\xc8\x08\x13\
|
||||
\x61\x21\xda\x88\x01\x62\x8a\x58\x23\x8e\x08\x17\x99\x85\xf8\x21\
|
||||
\xc1\x48\x04\x12\x8b\x24\x20\xc9\x88\x14\x51\x22\x4b\x91\x35\x48\
|
||||
\x31\x52\x8a\x54\x20\x55\x48\x1d\xf2\x3d\x72\x02\x39\x87\x5c\x46\
|
||||
\xba\x91\x3b\xc8\x00\x32\x82\xfc\x86\xbc\x47\x31\x94\x81\xb2\x51\
|
||||
\x3d\xd4\x0c\xb5\x43\xb9\xa8\x37\x1a\x84\x46\xa2\x0b\xd0\x64\x74\
|
||||
\x31\x9a\x8f\x16\xa0\x9b\xd0\x72\xb4\x1a\x3d\x8c\x36\xa1\xe7\xd0\
|
||||
\xab\x68\x0f\xda\x8f\x3e\x43\xc7\x30\xc0\xe8\x18\x07\x33\xc4\x6c\
|
||||
\x30\x2e\xc6\xc3\x42\xb1\x38\x2c\x09\x93\x63\xcb\xb1\x22\xac\x0c\
|
||||
\xab\xc6\x1a\xb0\x56\xac\x03\xbb\x89\xf5\x63\xcf\xb1\x77\x04\x12\
|
||||
\x81\x45\xc0\x09\x36\x04\x77\x42\x20\x61\x1e\x41\x48\x58\x4c\x58\
|
||||
\x4e\xd8\x48\xa8\x20\x1c\x24\x34\x11\xda\x09\x37\x09\x03\x84\x51\
|
||||
\xc2\x27\x22\x93\xa8\x4b\xb4\x26\xba\x11\xf9\xc4\x18\x62\x32\x31\
|
||||
\x87\x58\x48\x2c\x23\xd6\x12\x8f\x13\x2f\x10\x7b\x88\x43\xc4\x37\
|
||||
\x24\x12\x89\x43\x32\x27\xb9\x90\x02\x49\xb1\xa4\x54\xd2\x12\xd2\
|
||||
\x46\xd2\x6e\x52\x23\xe9\x2c\xa9\x9b\x34\x48\x1a\x23\x93\xc9\xda\
|
||||
\x64\x6b\xb2\x07\x39\x94\x2c\x20\x2b\xc8\x85\xe4\x9d\xe4\xc3\xe4\
|
||||
\x33\xe4\x1b\xe4\x21\xf2\x5b\x0a\x9d\x62\x40\x71\xa4\xf8\x53\xe2\
|
||||
\x28\x52\xca\x6a\x4a\x19\xe5\x10\xe5\x34\xe5\x06\x65\x98\x32\x41\
|
||||
\x55\xa3\x9a\x52\xdd\xa8\xa1\x54\x11\x35\x8f\x5a\x42\xad\xa1\xb6\
|
||||
\x52\xaf\x51\x87\xa8\x13\x34\x75\x9a\x39\xcd\x83\x16\x49\x4b\xa5\
|
||||
\xad\xa2\x95\xd3\x1a\x68\x17\x68\xf7\x69\xaf\xe8\x74\xba\x11\xdd\
|
||||
\x95\x1e\x4e\x97\xd0\x57\xd2\xcb\xe9\x47\xe8\x97\xe8\x03\xf4\x77\
|
||||
\x0c\x0d\x86\x15\x83\xc7\x88\x67\x28\x19\x9b\x18\x07\x18\x67\x19\
|
||||
\x77\x18\xaf\x98\x4c\xa6\x19\xd3\x8b\x19\xc7\x54\x30\x37\x31\xeb\
|
||||
\x98\xe7\x99\x0f\x99\x6f\x55\x58\x2a\xb6\x2a\x7c\x15\x91\xca\x0a\
|
||||
\x95\x4a\x95\x26\x95\x1b\x2a\x2f\x54\xa9\xaa\xa6\xaa\xde\xaa\x0b\
|
||||
\x55\xf3\x55\xcb\x54\x8f\xa9\x5e\x53\x7d\xae\x46\x55\x33\x53\xe3\
|
||||
\xa9\x09\xd4\x96\xab\x55\xaa\x9d\x50\xeb\x53\x1b\x53\x67\xa9\x3b\
|
||||
\xa8\x87\xaa\x67\xa8\x6f\x54\x3f\xa4\x7e\x59\xfd\x89\x06\x59\xc3\
|
||||
\x4c\xc3\x4f\x43\xa4\x51\xa0\xb1\x5f\xe3\xbc\xc6\x20\x0b\x63\x19\
|
||||
\xb3\x78\x2c\x21\x6b\x0d\xab\x86\x75\x81\x35\xc4\x26\xb1\xcd\xd9\
|
||||
\x7c\x76\x2a\xbb\x98\xfd\x1d\xbb\x8b\x3d\xaa\xa9\xa1\x39\x43\x33\
|
||||
\x4a\x33\x57\xb3\x52\xf3\x94\x66\x3f\x07\xe3\x98\x71\xf8\x9c\x74\
|
||||
\x4e\x09\xe7\x28\xa7\x97\xf3\x7e\x8a\xde\x14\xef\x29\xe2\x29\x1b\
|
||||
\xa6\x34\x4c\xb9\x31\x65\x5c\x6b\xaa\x96\x97\x96\x58\xab\x48\xab\
|
||||
\x51\xab\x47\xeb\xbd\x36\xae\xed\xa7\x9d\xa6\xbd\x45\xbb\x59\xfb\
|
||||
\x81\x0e\x41\xc7\x4a\x27\x5c\x27\x47\x67\x8f\xce\x05\x9d\xe7\x53\
|
||||
\xd9\x53\xdd\xa7\x0a\xa7\x16\x4d\x3d\x3a\xf5\xae\x2e\xaa\x6b\xa5\
|
||||
\x1b\xa1\xbb\x44\x77\xbf\x6e\xa7\xee\x98\x9e\xbe\x5e\x80\x9e\x4c\
|
||||
\x6f\xa7\xde\x79\xbd\xe7\xfa\x1c\x7d\x2f\xfd\x54\xfd\x6d\xfa\xa7\
|
||||
\xf5\x47\x0c\x58\x06\xb3\x0c\x24\x06\xdb\x0c\xce\x18\x3c\xc5\x35\
|
||||
\x71\x6f\x3c\x1d\x2f\xc7\xdb\xf1\x51\x43\x5d\xc3\x40\x43\xa5\x61\
|
||||
\x95\x61\x97\xe1\x84\x91\xb9\xd1\x3c\xa3\xd5\x46\x8d\x46\x0f\x8c\
|
||||
\x69\xc6\x5c\xe3\x24\xe3\x6d\xc6\x6d\xc6\xa3\x26\x06\x26\x21\x26\
|
||||
\x4b\x4d\xea\x4d\xee\x9a\x52\x4d\xb9\xa6\x29\xa6\x3b\x4c\x3b\x4c\
|
||||
\xc7\xcd\xcc\xcd\xa2\xcd\xd6\x99\x35\x9b\x3d\x31\xd7\x32\xe7\x9b\
|
||||
\xe7\x9b\xd7\x9b\xdf\xb7\x60\x5a\x78\x5a\x2c\xb6\xa8\xb6\xb8\x65\
|
||||
\x49\xb2\xe4\x5a\xa6\x59\xee\xb6\xbc\x6e\x85\x5a\x39\x59\xa5\x58\
|
||||
\x55\x5a\x5d\xb3\x46\xad\x9d\xad\x25\xd6\xbb\xad\xbb\xa7\x11\xa7\
|
||||
\xb9\x4e\x93\x4e\xab\x9e\xd6\x67\xc3\xb0\xf1\xb6\xc9\xb6\xa9\xb7\
|
||||
\x19\xb0\xe5\xd8\x06\xdb\xae\xb6\x6d\xb6\x7d\x61\x67\x62\x17\x67\
|
||||
\xb7\xc5\xae\xc3\xee\x93\xbd\x93\x7d\xba\x7d\x8d\xfd\x3d\x07\x0d\
|
||||
\x87\xd9\x0e\xab\x1d\x5a\x1d\x7e\x73\xb4\x72\x14\x3a\x56\x3a\xde\
|
||||
\x9a\xce\x9c\xee\x3f\x7d\xc5\xf4\x96\xe9\x2f\x67\x58\xcf\x10\xcf\
|
||||
\xd8\x33\xe3\xb6\x13\xcb\x29\xc4\x69\x9d\x53\x9b\xd3\x47\x67\x17\
|
||||
\x67\xb9\x73\x83\xf3\x88\x8b\x89\x4b\x82\xcb\x2e\x97\x3e\x2e\x9b\
|
||||
\x1b\xc6\xdd\xc8\xbd\xe4\x4a\x74\xf5\x71\x5d\xe1\x7a\xd2\xf5\x9d\
|
||||
\x9b\xb3\x9b\xc2\xed\xa8\xdb\xaf\xee\x36\xee\x69\xee\x87\xdc\x9f\
|
||||
\xcc\x34\x9f\x29\x9e\x59\x33\x73\xd0\xc3\xc8\x43\xe0\x51\xe5\xd1\
|
||||
\x3f\x0b\x9f\x95\x30\x6b\xdf\xac\x7e\x4f\x43\x4f\x81\x67\xb5\xe7\
|
||||
\x23\x2f\x63\x2f\x91\x57\xad\xd7\xb0\xb7\xa5\x77\xaa\xf7\x61\xef\
|
||||
\x17\x3e\xf6\x3e\x72\x9f\xe3\x3e\xe3\x3c\x37\xde\x32\xde\x59\x5f\
|
||||
\xcc\x37\xc0\xb7\xc8\xb7\xcb\x4f\xc3\x6f\x9e\x5f\x85\xdf\x43\x7f\
|
||||
\x23\xff\x64\xff\x7a\xff\xd1\x00\xa7\x80\x25\x01\x67\x03\x89\x81\
|
||||
\x41\x81\x5b\x02\xfb\xf8\x7a\x7c\x21\xbf\x8e\x3f\x3a\xdb\x65\xf6\
|
||||
\xb2\xd9\xed\x41\x8c\xa0\xb9\x41\x15\x41\x8f\x82\xad\x82\xe5\xc1\
|
||||
\xad\x21\x68\xc8\xec\x90\xad\x21\xf7\xe7\x98\xce\x91\xce\x69\x0e\
|
||||
\x85\x50\x7e\xe8\xd6\xd0\x07\x61\xe6\x61\x8b\xc3\x7e\x0c\x27\x85\
|
||||
\x87\x85\x57\x86\x3f\x8e\x70\x88\x58\x1a\xd1\x31\x97\x35\x77\xd1\
|
||||
\xdc\x43\x73\xdf\x44\xfa\x44\x96\x44\xde\x9b\x67\x31\x4f\x39\xaf\
|
||||
\x2d\x4a\x35\x2a\x3e\xaa\x2e\x6a\x3c\xda\x37\xba\x34\xba\x3f\xc6\
|
||||
\x2e\x66\x59\xcc\xd5\x58\x9d\x58\x49\x6c\x4b\x1c\x39\x2e\x2a\xae\
|
||||
\x36\x6e\x6c\xbe\xdf\xfc\xed\xf3\x87\xe2\x9d\xe2\x0b\xe3\x7b\x17\
|
||||
\x98\x2f\xc8\x5d\x70\x79\xa1\xce\xc2\xf4\x85\xa7\x16\xa9\x2e\x12\
|
||||
\x2c\x3a\x96\x40\x4c\x88\x4e\x38\x94\xf0\x41\x10\x2a\xa8\x16\x8c\
|
||||
\x25\xf2\x13\x77\x25\x8e\x0a\x79\xc2\x1d\xc2\x67\x22\x2f\xd1\x36\
|
||||
\xd1\x88\xd8\x43\x5c\x2a\x1e\x4e\xf2\x48\x2a\x4d\x7a\x92\xec\x91\
|
||||
\xbc\x35\x79\x24\xc5\x33\xa5\x2c\xe5\xb9\x84\x27\xa9\x90\xbc\x4c\
|
||||
\x0d\x4c\xdd\x9b\x3a\x9e\x16\x9a\x76\x20\x6d\x32\x3d\x3a\xbd\x31\
|
||||
\x83\x92\x91\x90\x71\x42\xaa\x21\x4d\x93\xb6\x67\xea\x67\xe6\x66\
|
||||
\x76\xcb\xac\x65\x85\xb2\xfe\xc5\x6e\x8b\xb7\x2f\x1e\x95\x07\xc9\
|
||||
\x6b\xb3\x90\xac\x05\x59\x2d\x0a\xb6\x42\xa6\xe8\x54\x5a\x28\xd7\
|
||||
\x2a\x07\xb2\x67\x65\x57\x66\xbf\xcd\x89\xca\x39\x96\xab\x9e\x2b\
|
||||
\xcd\xed\xcc\xb3\xca\xdb\x90\x37\x9c\xef\x9f\xff\xed\x12\xc2\x12\
|
||||
\xe1\x92\xb6\xa5\x86\x4b\x57\x2d\x1d\x58\xe6\xbd\xac\x6a\x39\xb2\
|
||||
\x3c\x71\x79\xdb\x0a\xe3\x15\x05\x2b\x86\x56\x06\xac\x3c\xb8\x8a\
|
||||
\xb6\x2a\x6d\xd5\x4f\xab\xed\x57\x97\xae\x7e\xbd\x26\x7a\x4d\x6b\
|
||||
\x81\x5e\xc1\xca\x82\xc1\xb5\x01\x6b\xeb\x0b\x55\x0a\xe5\x85\x7d\
|
||||
\xeb\xdc\xd7\xed\x5d\x4f\x58\x2f\x59\xdf\xb5\x61\xfa\x86\x9d\x1b\
|
||||
\x3e\x15\x89\x8a\xae\x14\xdb\x17\x97\x15\x7f\xd8\x28\xdc\x78\xe5\
|
||||
\x1b\x87\x6f\xca\xbf\x99\xdc\x94\xb4\xa9\xab\xc4\xb9\x64\xcf\x66\
|
||||
\xd2\x66\xe9\xe6\xde\x2d\x9e\x5b\x0e\x96\xaa\x97\xe6\x97\x0e\x6e\
|
||||
\x0d\xd9\xda\xb4\x0d\xdf\x56\xb4\xed\xf5\xf6\x45\xdb\x2f\x97\xcd\
|
||||
\x28\xdb\xbb\x83\xb6\x43\xb9\xa3\xbf\x3c\xb8\xbc\x65\xa7\xc9\xce\
|
||||
\xcd\x3b\x3f\x54\xa4\x54\xf4\x54\xfa\x54\x36\xee\xd2\xdd\xb5\x61\
|
||||
\xd7\xf8\x6e\xd1\xee\x1b\x7b\xbc\xf6\x34\xec\xd5\xdb\x5b\xbc\xf7\
|
||||
\xfd\x3e\xc9\xbe\xdb\x55\x01\x55\x4d\xd5\x66\xd5\x65\xfb\x49\xfb\
|
||||
\xb3\xf7\x3f\xae\x89\xaa\xe9\xf8\x96\xfb\x6d\x5d\xad\x4e\x6d\x71\
|
||||
\xed\xc7\x03\xd2\x03\xfd\x07\x23\x0e\xb6\xd7\xb9\xd4\xd5\x1d\xd2\
|
||||
\x3d\x54\x52\x8f\xd6\x2b\xeb\x47\x0e\xc7\x1f\xbe\xfe\x9d\xef\x77\
|
||||
\x2d\x0d\x36\x0d\x55\x8d\x9c\xc6\xe2\x23\x70\x44\x79\xe4\xe9\xf7\
|
||||
\x09\xdf\xf7\x1e\x0d\x3a\xda\x76\x8c\x7b\xac\xe1\x07\xd3\x1f\x76\
|
||||
\x1d\x67\x1d\x2f\x6a\x42\x9a\xf2\x9a\x46\x9b\x53\x9a\xfb\x5b\x62\
|
||||
\x5b\xba\x4f\xcc\x3e\xd1\xd6\xea\xde\x7a\xfc\x47\xdb\x1f\x0f\x9c\
|
||||
\x34\x3c\x59\x79\x4a\xf3\x54\xc9\x69\xda\xe9\x82\xd3\x93\x67\xf2\
|
||||
\xcf\x8c\x9d\x95\x9d\x7d\x7e\x2e\xf9\xdc\x60\xdb\xa2\xb6\x7b\xe7\
|
||||
\x63\xce\xdf\x6a\x0f\x6f\xef\xba\x10\x74\xe1\xd2\x45\xff\x8b\xe7\
|
||||
\x3b\xbc\x3b\xce\x5c\xf2\xb8\x74\xf2\xb2\xdb\xe5\x13\x57\xb8\x57\
|
||||
\x9a\xaf\x3a\x5f\x6d\xea\x74\xea\x3c\xfe\x93\xd3\x4f\xc7\xbb\x9c\
|
||||
\xbb\x9a\xae\xb9\x5c\x6b\xb9\xee\x7a\xbd\xb5\x7b\x66\xf7\xe9\x1b\
|
||||
\x9e\x37\xce\xdd\xf4\xbd\x79\xf1\x16\xff\xd6\xd5\x9e\x39\x3d\xdd\
|
||||
\xbd\xf3\x7a\x6f\xf7\xc5\xf7\xf5\xdf\x16\xdd\x7e\x72\x27\xfd\xce\
|
||||
\xcb\xbb\xd9\x77\x27\xee\xad\xbc\x4f\xbc\x5f\xf4\x40\xed\x41\xd9\
|
||||
\x43\xdd\x87\xd5\x3f\x5b\xfe\xdc\xd8\xef\xdc\x7f\x6a\xc0\x77\xa0\
|
||||
\xf3\xd1\xdc\x47\xf7\x06\x85\x83\xcf\xfe\x91\xf5\x8f\x0f\x43\x05\
|
||||
\x8f\x99\x8f\xcb\x86\x0d\x86\xeb\x9e\x38\x3e\x39\x39\xe2\x3f\x72\
|
||||
\xfd\xe9\xfc\xa7\x43\xcf\x64\xcf\x26\x9e\x17\xfe\xa2\xfe\xcb\xae\
|
||||
\x17\x16\x2f\x7e\xf8\xd5\xeb\xd7\xce\xd1\x98\xd1\xa1\x97\xf2\x97\
|
||||
\x93\xbf\x6d\x7c\xa5\xfd\xea\xc0\xeb\x19\xaf\xdb\xc6\xc2\xc6\x1e\
|
||||
\xbe\xc9\x78\x33\x31\x5e\xf4\x56\xfb\xed\xc1\x77\xdc\x77\x1d\xef\
|
||||
\xa3\xdf\x0f\x4f\xe4\x7c\x20\x7f\x28\xff\x68\xf9\xb1\xf5\x53\xd0\
|
||||
\xa7\xfb\x93\x19\x93\x93\xff\x04\x03\x98\xf3\xfc\x63\x33\x2d\xdb\
|
||||
\x00\x00\x00\x20\x63\x48\x52\x4d\x00\x00\x7a\x25\x00\x00\x80\x83\
|
||||
\x00\x00\xf9\xff\x00\x00\x80\xe9\x00\x00\x75\x30\x00\x00\xea\x60\
|
||||
\x00\x00\x3a\x98\x00\x00\x17\x6f\x92\x5f\xc5\x46\x00\x00\x02\x55\
|
||||
\x49\x44\x41\x54\x78\xda\x5c\x91\xcd\x8a\x1d\x55\x14\x85\xbf\x53\
|
||||
\x55\xdd\xe9\x4e\x2e\x69\xcc\x03\x04\x04\xa1\x1d\x18\x15\x32\x15\
|
||||
\x1c\x05\xae\xa3\x8c\x7c\x82\x40\xc4\x51\xa4\x85\xbc\x82\x23\x07\
|
||||
\xa2\x20\x08\x3e\x84\x8e\x04\x47\x82\xe0\x30\x12\x47\x81\x06\x21\
|
||||
\xf3\x98\xee\x7b\xab\xea\xfc\xee\xbd\x1c\x54\x75\xfb\x73\xe0\x70\
|
||||
\xd8\x83\xb5\xd6\xb7\xd7\x09\xef\x9e\x7f\xcc\x9d\xfe\x36\x27\xdd\
|
||||
\x86\x5b\xdd\x31\x87\xe1\xe0\x34\x10\x1e\x1b\xfe\x61\x51\x7d\x3f\
|
||||
\xab\x10\x3d\xff\x3e\x79\xfc\x65\xf2\xf8\xed\xe8\xf3\xf9\xac\xc4\
|
||||
\xec\x89\xac\x42\x77\xd2\x6d\x38\xe9\x36\x6c\xba\x9b\xdc\x08\x87\
|
||||
\x67\x5d\xe8\x9e\x19\x7e\x96\x55\xee\x47\x4f\xfd\xec\xa9\x4f\xca\
|
||||
\xf7\x8b\xea\x59\xa5\x3d\x37\xfc\xcc\x64\x38\x8e\x10\xc3\xa6\xbb\
|
||||
\xc9\x71\x77\x74\xd8\x87\xfe\x07\xc7\xb7\xcd\x8d\xa8\xcc\xe4\x91\
|
||||
\xe8\x99\xac\x42\x55\xa3\xa8\x92\x94\x8f\xb3\xca\x97\x59\xf5\x41\
|
||||
\x51\x7d\x58\x54\xcb\x70\x18\x06\x80\xaf\x9b\xda\xb6\xaa\x11\x95\
|
||||
\xd9\xfb\xc4\xe8\x91\xe4\x99\xa2\x8a\xe1\x98\x6c\x35\x29\x44\xcf\
|
||||
\xdb\xe4\xf9\x0b\x9a\x3e\x1f\x04\xf7\x8a\xea\x23\xd3\x92\x7c\x69\
|
||||
\x23\x97\x3e\x32\xfa\x4c\x56\xc1\xb4\xa0\x0a\x61\x72\x92\x32\xd5\
|
||||
\x2a\x44\x3d\xa1\xfa\x77\x43\x51\x7d\x5c\xd5\xfa\xb4\x26\xbf\xb6\
|
||||
\x3d\x17\xb6\x23\x2a\x53\xd5\x10\x02\x20\x10\x68\x32\x54\x1d\xb2\
|
||||
\x43\xf4\x9e\xa2\x4f\x87\xd9\xd3\xd6\x30\xa2\x2f\x06\x7b\x9f\x98\
|
||||
\x95\x28\xaa\xb8\x16\xf1\xd5\x51\x5b\xc5\xb3\x43\x74\xc8\xfa\x60\
|
||||
\x18\x7d\xbe\xdb\x30\xa2\xa7\xeb\xe2\xaa\x1a\x2e\x5d\xa7\x2f\x6a\
|
||||
\xa0\x09\x8a\x20\x39\x4c\x0e\xc9\xef\x0e\x7b\x9f\x68\x18\xd9\x0b\
|
||||
\x69\x6d\xfc\x6a\xef\xff\x88\x5d\x8b\x41\x5a\xd3\x67\x83\x28\x86\
|
||||
\xbd\xcf\x2f\xab\xea\x5b\x55\x8d\x4a\xa3\x52\xd1\xff\xd0\xd1\x2a\
|
||||
\xce\x5a\xf0\xc7\xf5\x16\xbd\xec\x76\x3e\xfe\x74\xe9\x23\x3b\x9f\
|
||||
\x88\x2d\x61\xd5\xa0\x0a\x4c\xff\xa4\x96\x55\xb8\x37\xb8\x34\xb8\
|
||||
\x6c\x30\x1a\x64\xff\x35\xf0\xfc\xbd\x7b\x14\x7f\x46\x53\x4f\x13\
|
||||
\xd7\xe4\x61\x7d\x9d\xa5\xb8\xc9\xe1\xa2\xc1\x85\x2d\x46\x55\xc6\
|
||||
\x41\x78\x7b\x20\xf9\x1f\x64\xff\x86\xac\x27\xb4\x35\xf1\xca\xc4\
|
||||
\x56\x92\xb4\x22\xef\xae\xc5\x10\xf8\x8a\xa3\xee\x7c\x58\x77\x7b\
|
||||
\x4a\xf4\x53\x92\x6f\xa9\x2b\xba\xfd\xab\xf5\xec\x0b\xf2\xec\xcb\
|
||||
\x0c\x3f\x72\xdc\x3d\xe5\x46\xa0\xc3\x05\xae\x42\xd3\x47\x14\xff\
|
||||
\x8c\xd9\x47\x76\x06\xaf\x1b\xfc\xd5\xe0\x55\x85\x57\x6d\xd9\x3d\
|
||||
\xfa\x88\xeb\x13\x0e\xc2\x43\x6e\x75\xc6\xed\x9e\xc0\x6f\xef\x2c\
|
||||
\xdf\x32\x1a\xec\x1d\x26\x7b\x93\xd9\x1f\x31\xfb\x03\x92\x9f\x52\
|
||||
\x05\x55\x2f\x70\xfd\x4c\x17\xbe\xe7\x28\xfc\xc9\xa6\x87\x3b\x03\
|
||||
\xbc\x31\xf0\xf7\x00\x1f\xdf\x11\x08\xaa\x52\x16\x46\x00\x00\x00\
|
||||
\x00\x49\x45\x4e\x44\xae\x42\x60\x82\
|
||||
"
|
||||
|
||||
qt_resource_name = "\
|
||||
\x00\x09\
|
||||
\x0c\x78\x54\x88\
|
||||
\x00\x6e\
|
||||
\x00\x65\x00\x77\x00\x50\x00\x72\x00\x65\x00\x66\x00\x69\x00\x78\
|
||||
\x00\x06\
|
||||
\x07\x03\x7d\xc3\
|
||||
\x00\x69\
|
||||
\x00\x6d\x00\x61\x00\x67\x00\x65\x00\x73\
|
||||
\x00\x08\
|
||||
\x0c\x57\x58\x67\
|
||||
\x00\x73\
|
||||
\x00\x65\x00\x6e\x00\x74\x00\x2e\x00\x70\x00\x6e\x00\x67\
|
||||
\x00\x0e\
|
||||
\x02\x47\x93\x47\
|
||||
\x00\x79\
|
||||
\x00\x65\x00\x6c\x00\x6c\x00\x6f\x00\x77\x00\x69\x00\x63\x00\x6f\x00\x6e\x00\x2e\x00\x70\x00\x6e\x00\x67\
|
||||
\x00\x08\
|
||||
\x0c\x47\x58\x67\
|
||||
\x00\x73\
|
||||
\x00\x65\x00\x6e\x00\x64\x00\x2e\x00\x70\x00\x6e\x00\x67\
|
||||
\x00\x0f\
|
||||
\x05\x46\x9a\xc7\
|
||||
\x00\x61\
|
||||
\x00\x64\x00\x64\x00\x72\x00\x65\x00\x73\x00\x73\x00\x62\x00\x6f\x00\x6f\x00\x6b\x00\x2e\x00\x70\x00\x6e\x00\x67\
|
||||
\x00\x09\
|
||||
\x09\x6b\xb7\xc7\
|
||||
\x00\x69\
|
||||
\x00\x6e\x00\x62\x00\x6f\x00\x78\x00\x2e\x00\x70\x00\x6e\x00\x67\
|
||||
\x00\x11\
|
||||
\x02\xa0\x44\xa7\
|
||||
\x00\x73\
|
||||
\x00\x75\x00\x62\x00\x73\x00\x63\x00\x72\x00\x69\x00\x70\x00\x74\x00\x69\x00\x6f\x00\x6e\x00\x73\x00\x2e\x00\x70\x00\x6e\x00\x67\
|
||||
\
|
||||
\x00\x0e\
|
||||
\x0a\x51\x2d\xe7\
|
||||
\x00\x69\
|
||||
\x00\x64\x00\x65\x00\x6e\x00\x74\x00\x69\x00\x74\x00\x69\x00\x65\x00\x73\x00\x2e\x00\x70\x00\x6e\x00\x67\
|
||||
\x00\x0b\
|
||||
\x0a\xd0\x22\xa7\
|
||||
\x00\x72\
|
||||
\x00\x65\x00\x64\x00\x69\x00\x63\x00\x6f\x00\x6e\x00\x2e\x00\x70\x00\x6e\x00\x67\
|
||||
\x00\x0d\
|
||||
\x02\xe8\x12\x87\
|
||||
\x00\x62\
|
||||
\x00\x6c\x00\x61\x00\x63\x00\x6b\x00\x6c\x00\x69\x00\x73\x00\x74\x00\x2e\x00\x70\x00\x6e\x00\x67\
|
||||
\x00\x11\
|
||||
\x07\x34\x2d\xc7\
|
||||
\x00\x6e\
|
||||
\x00\x65\x00\x74\x00\x77\x00\x6f\x00\x72\x00\x6b\x00\x73\x00\x74\x00\x61\x00\x74\x00\x75\x00\x73\x00\x2e\x00\x70\x00\x6e\x00\x67\
|
||||
\
|
||||
\x00\x0d\
|
||||
\x07\x76\xdf\x07\
|
||||
\x00\x67\
|
||||
\x00\x72\x00\x65\x00\x65\x00\x6e\x00\x69\x00\x63\x00\x6f\x00\x6e\x00\x2e\x00\x70\x00\x6e\x00\x67\
|
||||
"
|
||||
|
||||
qt_resource_struct = "\
|
||||
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\
|
||||
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x02\
|
||||
\x00\x00\x00\x18\x00\x02\x00\x00\x00\x0b\x00\x00\x00\x03\
|
||||
\x00\x00\x00\x40\x00\x00\x00\x00\x00\x01\x00\x00\x02\x28\
|
||||
\x00\x00\x00\xb4\x00\x00\x00\x00\x00\x01\x00\x00\x17\x9c\
|
||||
\x00\x00\x01\x1a\x00\x00\x00\x00\x00\x01\x00\x00\x2a\x64\
|
||||
\x00\x00\x00\x78\x00\x00\x00\x00\x00\x01\x00\x00\x12\x44\
|
||||
\x00\x00\x01\x3a\x00\x00\x00\x00\x00\x01\x00\x00\x2d\x58\
|
||||
\x00\x00\x01\x62\x00\x00\x00\x00\x00\x01\x00\x00\x2f\xd1\
|
||||
\x00\x00\x00\x9c\x00\x00\x00\x00\x00\x01\x00\x00\x14\xe9\
|
||||
\x00\x00\x00\xdc\x00\x00\x00\x00\x00\x01\x00\x00\x1a\x17\
|
||||
\x00\x00\x00\xfe\x00\x00\x00\x00\x00\x01\x00\x00\x1d\x81\
|
||||
\x00\x00\x00\x62\x00\x00\x00\x00\x00\x01\x00\x00\x0f\x09\
|
||||
\x00\x00\x00\x2a\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\
|
||||
"
|
||||
|
||||
def qInitResources():
|
||||
QtCore.qRegisterResourceData(0x01, qt_resource_struct, qt_resource_name, qt_resource_data)
|
||||
|
||||
def qCleanupResources():
|
||||
QtCore.qUnregisterResourceData(0x01, qt_resource_struct, qt_resource_name, qt_resource_data)
|
||||
|
||||
qInitResources()
|
3491
bitmessagemain.py
Normal file
3491
bitmessagemain.py
Normal file
|
@ -0,0 +1,3491 @@
|
|||
# Copyright (c) 2012 Jonathan Warren
|
||||
# Copyright (c) 2012 The Bitmessage developers
|
||||
# Distributed under the MIT/X11 software license. See the accompanying
|
||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#Right now, PyBitmessage only support connecting to stream 1. It doesn't yet contain logic to expand into further streams.
|
||||
|
||||
softwareVersion = '0.1.0'
|
||||
verbose = 2
|
||||
maximumAgeOfAnObjectThatIAmWillingToAccept = 216000 #Equals two days and 12 hours.
|
||||
lengthOfTimeToLeaveObjectsInInventory = 237600 #Equals two days and 18 hours. This should be longer than maximumAgeOfAnObjectThatIAmWillingToAccept so that we don't process messages twice.
|
||||
maximumAgeOfObjectsThatIAdvertiseToOthers = 216000 #Equals two days and 12 hours
|
||||
maximumAgeOfNodesThatIAdvertiseToOthers = 10800 #Equals three hours
|
||||
|
||||
|
||||
import sys
|
||||
try:
|
||||
from PyQt4.QtCore import *
|
||||
from PyQt4.QtGui import *
|
||||
except Exception, err:
|
||||
print 'Bitmessage requires PyQt. You can download it from http://www.riverbankcomputing.com/software/pyqt/download or by searching Google for \'PyQt Download\' (without quotes).'
|
||||
print 'Error message:', err
|
||||
sys.exit()
|
||||
import ConfigParser
|
||||
from bitmessageui import *
|
||||
from newaddressdialog import *
|
||||
from newsubscriptiondialog import *
|
||||
from settings import *
|
||||
from about import *
|
||||
from help import *
|
||||
from iconglossary import *
|
||||
from addresses import *
|
||||
import Queue
|
||||
from defaultKnownNodes import *
|
||||
import time
|
||||
import socket
|
||||
import threading
|
||||
import rsa
|
||||
from rsa.bigfile import *
|
||||
import hashlib
|
||||
from struct import *
|
||||
import pickle
|
||||
import random
|
||||
import sqlite3
|
||||
import threading #used for the locks, not for the threads
|
||||
import cStringIO
|
||||
from email.parser import Parser
|
||||
from time import strftime, localtime
|
||||
import os
|
||||
|
||||
#For each stream to which we connect, one outgoingSynSender thread will exist and will create 8 connections with peers.
|
||||
class outgoingSynSender(QThread):
|
||||
def __init__(self, parent = None):
|
||||
QThread.__init__(self, parent)
|
||||
self.selfInitiatedConnectionList = [] #This is a list of current connections (the thread pointers at least)
|
||||
self.alreadyAttemptedConnectionsList = [] #This is a list of nodes to which we have already attempted a connection
|
||||
|
||||
def setup(self,streamNumber):
|
||||
self.streamNumber = streamNumber
|
||||
|
||||
|
||||
def run(self):
|
||||
time.sleep(1)
|
||||
resetTime = int(time.time()) #used below to clear out the alreadyAttemptedConnectionsList periodically so that we will retry connecting to hosts to which we have already tried to connect.
|
||||
while True:
|
||||
#time.sleep(999999)#I'm using this to prevent connections for testing.
|
||||
if len(self.selfInitiatedConnectionList) < 8: #maximum number of outgoing connections = 8
|
||||
random.seed()
|
||||
HOST, = random.sample(knownNodes[self.streamNumber], 1)
|
||||
while HOST in self.alreadyAttemptedConnectionsList or HOST in connectedHostsList:
|
||||
#print 'choosing new sample'
|
||||
random.seed()
|
||||
HOST, = random.sample(knownNodes[self.streamNumber], 1)
|
||||
time.sleep(1)
|
||||
#Clear out the alreadyAttemptedConnectionsList every half hour so that this program will again attempt a connection to any nodes, even ones it has already tried.
|
||||
if (int(time.time()) - resetTime) > 1800:
|
||||
self.alreadyAttemptedConnectionsList = []
|
||||
resetTime = int(time.time())
|
||||
self.alreadyAttemptedConnectionsList.append(HOST)
|
||||
PORT, timeNodeLastSeen = knownNodes[self.streamNumber][HOST]
|
||||
print 'Trying an outgoing connection to', HOST, ':', PORT
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
try:
|
||||
sock.connect((HOST, PORT))
|
||||
rd = receiveDataThread()
|
||||
self.emit(SIGNAL("passObjectThrough(PyQt_PyObject)"),rd)
|
||||
rd.setup(sock,HOST,PORT,self.streamNumber,self.selfInitiatedConnectionList)
|
||||
rd.start()
|
||||
print self, 'connected to', HOST, 'during outgoing attempt.'
|
||||
|
||||
sd = sendDataThread()
|
||||
sd.setup(sock,HOST,PORT,self.streamNumber)
|
||||
sd.start()
|
||||
sd.sendVersionMessage()
|
||||
|
||||
except Exception, err:
|
||||
print 'Could NOT connect to', HOST, 'during outgoing attempt.', err
|
||||
PORT, timeLastSeen = knownNodes[self.streamNumber][HOST]
|
||||
if (int(time.time())-timeLastSeen) > 172800: # for nodes older than 48 hours old, delete from the knownNodes data-structure.
|
||||
if len(knownNodes[self.streamNumber]) > 1000: #as long as we have more than 1000 hosts in our list
|
||||
del knownNodes[self.streamNumber][HOST]
|
||||
print 'deleting ', HOST, 'from knownNodes because it is more than 48 hours old and we could not connect to it.'
|
||||
time.sleep(1)
|
||||
|
||||
#Only one singleListener thread will ever exist. It creates the receiveDataThread and sendDataThread for each incoming connection. Note that it cannot set the stream number because it is not known yet- the other node will have to tell us its stream number in a version message. If we don't care about their stream, we will close the connection (within the recversion function of the recieveData thread)
|
||||
class singleListener(QThread):
|
||||
def __init__(self, parent = None):
|
||||
QThread.__init__(self, parent)
|
||||
|
||||
|
||||
def run(self):
|
||||
|
||||
print 'bitmessage listener running'
|
||||
HOST = '' # Symbolic name meaning all available interfaces
|
||||
PORT = config.getint('bitmessagesettings', 'port')
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
#This option apparently avoids the TIME_WAIT state so that we can rebind faster
|
||||
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
sock.bind((HOST, PORT))
|
||||
sock.listen(2)
|
||||
self.incomingConnectionList = []
|
||||
|
||||
|
||||
while True:
|
||||
#for i in range(0,1): #uncomment this line and comment the line above this to accept only one connection.
|
||||
|
||||
|
||||
rd = receiveDataThread()
|
||||
a,(HOST,PORT) = sock.accept()
|
||||
while HOST in connectedHostsList:
|
||||
print 'incoming connection is from a host in connectedHostsList (we are already connected to it). Ignoring it.'
|
||||
a.close()
|
||||
a,(HOST,PORT) = sock.accept()
|
||||
self.emit(SIGNAL("passObjectThrough(PyQt_PyObject)"),rd)
|
||||
rd.setup(a,HOST,PORT,-1,self.incomingConnectionList)
|
||||
print self, 'connected to', HOST,'during INCOMING request.'
|
||||
rd.start()
|
||||
|
||||
|
||||
sd = sendDataThread()
|
||||
sd.setup(a,HOST,PORT,-1)
|
||||
sd.start()
|
||||
|
||||
|
||||
#This thread is created either by the synSenderThread(for outgoing connections) or the singleListenerThread(for incoming connectiosn).
|
||||
class receiveDataThread(QThread):
|
||||
def __init__(self, parent = None):
|
||||
QThread.__init__(self, parent)
|
||||
self.data = ''
|
||||
self.verackSent = False
|
||||
self.verackReceived = False
|
||||
|
||||
def setup(self,sock,HOST,port,streamNumber,selfInitiatedConnectionList):
|
||||
self.sock = sock
|
||||
self.HOST = HOST
|
||||
self.PORT = port
|
||||
self.sock.settimeout(600) #We'll send out a pong every 5 minutes to make sure the connection stays alive if there has been no other traffic to send lately.
|
||||
self.streamNumber = streamNumber
|
||||
self.selfInitiatedConnectionList = selfInitiatedConnectionList
|
||||
self.selfInitiatedConnectionList.append(self)
|
||||
self.payloadLength = 0
|
||||
self.receivedgetbiginv = False
|
||||
self.objectsThatWeHaveYetToGet = {}
|
||||
connectedHostsList[self.HOST] = 0
|
||||
self.connectionIsOrWasFullyEstablished = False #set to true after the remote node and I accept each other's version messages. This is needed to allow the user interface to accurately reflect the current number of connections.
|
||||
if self.streamNumber == -1: #This was an incoming connection. Send out a version message if we accept the other node's version message.
|
||||
self.initiatedConnection = False
|
||||
else:
|
||||
self.initiatedConnection = True
|
||||
|
||||
|
||||
def run(self):
|
||||
|
||||
while True:
|
||||
try:
|
||||
self.data = self.data + self.sock.recv(65536)
|
||||
except socket.timeout:
|
||||
printLock.acquire()
|
||||
print 'Timeout occurred waiting for data. Closing thread.'
|
||||
printLock.release()
|
||||
break
|
||||
except Exception, err:
|
||||
printLock.acquire()
|
||||
print 'Error receiving data. Closing receiveData thread.'
|
||||
printLock.release()
|
||||
break
|
||||
#print 'Received', repr(self.data)
|
||||
if self.data == "":
|
||||
printLock.acquire()
|
||||
print 'Socket timeout.'
|
||||
printLock.release()
|
||||
break
|
||||
else:
|
||||
self.processData()
|
||||
|
||||
|
||||
|
||||
try:
|
||||
self.sock.close()
|
||||
except Exception, err:
|
||||
print 'Within receiveDataThread run(), self.sock.close() failed.', err
|
||||
|
||||
try:
|
||||
self.selfInitiatedConnectionList.remove(self)
|
||||
print 'removed self from ConnectionList'
|
||||
except:
|
||||
pass
|
||||
broadcastToSendDataQueues((self.streamNumber, 'shutdown', self.HOST))
|
||||
if self.connectionIsOrWasFullyEstablished: #We don't want to decrement the number of connections and show the result if we never incremented it in the first place (which we only do if the connection is fully established- meaning that both nodes accepted each other's version packets.)
|
||||
connectionsCountLock.acquire()
|
||||
connectionsCount[self.streamNumber] -= 1
|
||||
self.emit(SIGNAL("updateNetworkStatusTab(PyQt_PyObject,PyQt_PyObject)"),self.streamNumber,connectionsCount[self.streamNumber])
|
||||
connectionsCountLock.release()
|
||||
del connectedHostsList[self.HOST]
|
||||
|
||||
def processData(self):
|
||||
global verbose
|
||||
if verbose >= 2:
|
||||
printLock.acquire()
|
||||
print 'self.data is currently ', repr(self.data)
|
||||
printLock.release()
|
||||
if self.data == "":
|
||||
pass
|
||||
elif self.data[0:4] != '\xe9\xbe\xb4\xd9':
|
||||
self.data = ""
|
||||
if verbose >= 2:
|
||||
#printLock.acquire()
|
||||
sys.stderr.write('The magic bytes were not correct. This may indicate a problem with the program code, or a transmission error occurred.\n')
|
||||
#printLock.release()
|
||||
else: #if there is no reason to discard the data we have so far,
|
||||
if len(self.data) < 20: #if so little of the data has arrived that we can't even unpack the payload length
|
||||
pass
|
||||
else:
|
||||
self.payloadLength, = unpack('>L',self.data[16:20])
|
||||
if len(self.data) >= self.payloadLength: #check if the whole message has arrived yet. If it has,...
|
||||
if self.data[20:24] == hashlib.sha512(hashlib.sha512(self.data[24:self.payloadLength+24]).digest()).digest()[0:4]:#test the checksum in the message. If it is correct...
|
||||
#print 'message checksum is correct'
|
||||
#The time we've last seen this node is obviously right now since we just received valid data from it. So update the knownNodes list so that other peers can be made aware of its existance.
|
||||
if self.initiatedConnection: #The remote port is only something we should share with others if it is the remote node's incoming port (rather than some random operating-system-assigned outgoing port).
|
||||
knownNodes[self.streamNumber][self.HOST] = (self.PORT,int(time.time()))
|
||||
remoteCommand = self.data[4:16]
|
||||
if verbose >= 2:
|
||||
print 'remoteCommand ', remoteCommand, 'from', self.HOST
|
||||
if remoteCommand == 'version\x00\x00\x00\x00\x00':
|
||||
self.recversion()
|
||||
elif remoteCommand == 'verack\x00\x00\x00\x00\x00\x00':
|
||||
self.recverack()
|
||||
elif remoteCommand == 'addr\x00\x00\x00\x00\x00\x00\x00\x00' and self.connectionIsOrWasFullyEstablished:
|
||||
self.recaddr()
|
||||
elif remoteCommand == 'getpubkey\x00\x00\x00' and self.connectionIsOrWasFullyEstablished:
|
||||
self.recgetpubkey()
|
||||
elif remoteCommand == 'pubkey\x00\x00\x00\x00\x00\x00' and self.connectionIsOrWasFullyEstablished:
|
||||
self.recpubkey()
|
||||
elif remoteCommand == 'inv\x00\x00\x00\x00\x00\x00\x00\x00\x00' and self.connectionIsOrWasFullyEstablished:
|
||||
self.recinv()
|
||||
elif remoteCommand == 'getdata\x00\x00\x00\x00\x00' and self.connectionIsOrWasFullyEstablished:
|
||||
self.recgetdata()
|
||||
elif remoteCommand == 'getbiginv\x00\x00\x00' and self.connectionIsOrWasFullyEstablished:
|
||||
self.sendBigInv()
|
||||
elif remoteCommand == 'msg\x00\x00\x00\x00\x00\x00\x00\x00\x00' and self.connectionIsOrWasFullyEstablished:
|
||||
self.recmsg()
|
||||
elif remoteCommand == 'broadcast\x00\x00\x00' and self.connectionIsOrWasFullyEstablished:
|
||||
self.recbroadcast()
|
||||
elif remoteCommand == 'getaddr\x00\x00\x00\x00\x00' and self.connectionIsOrWasFullyEstablished:
|
||||
self.sendaddr()
|
||||
elif remoteCommand == 'ping\x00\x00\x00\x00\x00\x00\x00\x00' and self.connectionIsOrWasFullyEstablished:
|
||||
self.sendpong()
|
||||
elif remoteCommand == 'pong\x00\x00\x00\x00\x00\x00\x00\x00' and self.connectionIsOrWasFullyEstablished:
|
||||
pass
|
||||
elif remoteCommand == 'alert\x00\x00\x00\x00\x00\x00\x00' and self.connectionIsOrWasFullyEstablished:
|
||||
pass
|
||||
|
||||
self.data = self.data[self.payloadLength+24:]#take this message out and then process the next message
|
||||
if self.data == '':
|
||||
while len(self.objectsThatWeHaveYetToGet) > 0:
|
||||
random.seed()
|
||||
objectHash, = random.sample(self.objectsThatWeHaveYetToGet, 1)
|
||||
if objectHash in inventory:
|
||||
print 'Inventory (in memory) already has object that we received in an inv message.'
|
||||
del self.objectsThatWeHaveYetToGet[objectHash]
|
||||
elif isInSqlInventory(objectHash):
|
||||
print 'Inventory (SQL on disk) already has object that we received in an inv message.'
|
||||
del self.objectsThatWeHaveYetToGet[objectHash]
|
||||
else:
|
||||
print 'processData function making request for object:', repr(objectHash)
|
||||
self.sendgetdata(objectHash)
|
||||
del self.objectsThatWeHaveYetToGet[objectHash] #It is possible that the remote node doesn't respond with the object. In that case, we'll very likely get it from someone else anyway.
|
||||
break
|
||||
print 'within processData, length of objectsThatWeHaveYetToGet is now', len(self.objectsThatWeHaveYetToGet)
|
||||
self.processData()
|
||||
|
||||
|
||||
#if self.versionSent == 0:
|
||||
# self.sendversion()
|
||||
'''if (self.versionRec == 1) and (self.getaddrthreadalreadycreated == 0):
|
||||
while (threading.activeCount() > maxGlobalThreads):#If there too many open threads, just wait. This includes full and half-open.
|
||||
time.sleep(0.1)
|
||||
printLock.acquire()
|
||||
print 'Starting a new getaddrSender thread'
|
||||
printLock.release()
|
||||
bar = getaddrSender((self.sock,self.addr))
|
||||
bar.daemon = True
|
||||
self.getaddrthreadalreadycreated = 1 #we're about to start it
|
||||
while True: #My goal is to try bar.start() until it succeedes
|
||||
while (threading.activeCount() > maxGlobalThreads):#If there too many open threads, just wait. This includes full and half-open.
|
||||
time.sleep(0.1)
|
||||
try:
|
||||
bar.start()
|
||||
except:
|
||||
maxGlobalThreads = maxGlobalThreads - 20
|
||||
sys.stderr.write('Problem! Your OS did not allow the starting of another thread. Reducing the number of threads to %s and trying again.\n' % maxGlobalThreads)
|
||||
continue #..the while loop again right now
|
||||
break '''
|
||||
else:
|
||||
print 'Checksum incorrect. Clearing messages and waiting for new data.'
|
||||
self.data = ''
|
||||
def sendpong(self):
|
||||
print 'Sending pong'
|
||||
self.sock.sendall('\xE9\xBE\xB4\xD9\x70\x6F\x6E\x67\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x82\x6D\xf0\x68')
|
||||
|
||||
def recverack(self):
|
||||
print 'verack received'
|
||||
self.verackReceived = True
|
||||
if self.verackSent == True:
|
||||
#We have thus both sent and received a verack.
|
||||
self.connectionFullyEstablished()
|
||||
|
||||
def connectionFullyEstablished(self):
|
||||
self.connectionIsOrWasFullyEstablished = True
|
||||
if not self.initiatedConnection:
|
||||
self.emit(SIGNAL("setStatusIcon(PyQt_PyObject)"),'green')
|
||||
#Update the 'Network Status' tab
|
||||
connectionsCountLock.acquire()
|
||||
connectionsCount[self.streamNumber] += 1
|
||||
self.emit(SIGNAL("updateNetworkStatusTab(PyQt_PyObject,PyQt_PyObject)"),self.streamNumber,connectionsCount[self.streamNumber])
|
||||
connectionsCountLock.release()
|
||||
self.sendaddr()
|
||||
remoteNodeIncomingPort, remoteNodeSeenTime = knownNodes[self.streamNumber][self.HOST]
|
||||
print 'within connectionFullyEstablished, self.HOST and remoteNodeIncomingPort:', self.HOST, remoteNodeIncomingPort
|
||||
print 'broadcasting addr from within connectionFullyEstablished function.'
|
||||
self.broadcastaddr([(int(time.time()), self.streamNumber, 1, self.HOST, remoteNodeIncomingPort)])
|
||||
if connectionsCount[self.streamNumber] > 150:
|
||||
print 'We are connected to too many people. Closing connection.'
|
||||
self.sock.close()
|
||||
return
|
||||
self.sendBigInv()
|
||||
|
||||
def sendBigInv(self): #I used capitals in for this function name because there is no such Bitmessage command as 'biginv'.
|
||||
if self.receivedgetbiginv:
|
||||
print 'We have already sent a big inv message to this peer. Ignoring request.'
|
||||
return
|
||||
else:
|
||||
self.receivedgetbiginv = True
|
||||
sqlLock.acquire()
|
||||
#Select all hashes which are younger than two days old and in this stream.
|
||||
t = (int(time.time())-172800,self.streamNumber)
|
||||
sqlSubmitQueue.put('''SELECT hash FROM inventory WHERE receivedtime>? and streamnumber=?''')
|
||||
sqlSubmitQueue.put(t)
|
||||
queryreturn = sqlReturnQueue.get()
|
||||
sqlLock.release()
|
||||
print 'sendBigInv pulled', len(queryreturn), 'items from SQL inventory.'
|
||||
bigInvList = {}
|
||||
for row in queryreturn:
|
||||
hash, = row
|
||||
bigInvList[hash] = 0
|
||||
#print 'bigInvList:', bigInvList
|
||||
for hash, storedValue in inventory.items():
|
||||
objectType, streamNumber, payload, receivedTime = storedValue
|
||||
if streamNumber == self.streamNumber and receivedTime > int(time.time())-172800:
|
||||
bigInvList[hash] = 0
|
||||
numberOfObjectsInInvMessage = 0
|
||||
payload = ''
|
||||
for hash, storedValue in bigInvList.items():
|
||||
payload += hash
|
||||
numberOfObjectsInInvMessage += 1
|
||||
if numberOfObjectsInInvMessage >= 50000: #We can only send a max of 50000 items per inv message but we may have more objects to advertise. They must be split up into multiple inv messages.
|
||||
sendinvMessageToJustThisOnePeer(numberOfObjectsInInvMessage,payload,)
|
||||
payload = ''
|
||||
numberOfObjectsInInvMessage = 0
|
||||
if numberOfObjectsInInvMessage > 0:
|
||||
self.sendinvMessageToJustThisOnePeer(numberOfObjectsInInvMessage,payload,)
|
||||
|
||||
#Notice that there is also a broadcastinv function for broadcasting invs to everyone in our stream.
|
||||
def sendinvMessageToJustThisOnePeer(self,numberOfObjects,payload,destination):
|
||||
payload = encodeVarint(numberOfObjects) + payload
|
||||
headerData = '\xe9\xbe\xb4\xd9' #magic bits, slighly different from Bitcoin's magic bits.
|
||||
headerData = headerData + 'inv\x00\x00\x00\x00\x00\x00\x00\x00\x00'
|
||||
headerData = headerData + pack('>L',len(payload))
|
||||
headerData = headerData + hashlib.sha512(hashlib.sha512(payload).digest()).digest()[:4]
|
||||
self.sock.send(headerData + payload)
|
||||
|
||||
#We have received a broadcast message
|
||||
def recbroadcast(self):
|
||||
#First we must check to make sure the proof of work is sufficient.
|
||||
POW, = unpack('>Q',hashlib.sha512(hashlib.sha512(self.data[24:24+self.payloadLength]).digest()).digest()[4:12])
|
||||
if POW > 2**64 / ((self.payloadLength+payloadLengthExtraBytes) * averageProofOfWorkNonceTrialsPerByte):
|
||||
print 'The proof of work in this broadcast message is insufficient. Ignoring message.'
|
||||
return
|
||||
embeddedTime, = unpack('>I',self.data[32:36])
|
||||
if embeddedTime > (int(time.time())+10800): #prevent funny business
|
||||
print 'The embedded time in this broadcast message is more than three hours in the future. That doesn\'t make sense. Ignoring message.'
|
||||
return
|
||||
if embeddedTime < (int(time.time())-maximumAgeOfAnObjectThatIAmWillingToAccept):
|
||||
print 'The embedded time in this broadcast message is too old. Ignoring message.'
|
||||
return
|
||||
if self.payloadLength < 66:
|
||||
print 'The payload length of this broadcast packet is unreasonably low. Someone is probably trying funny business. Ignoring message.'
|
||||
return
|
||||
|
||||
inventoryHash = calculateInventoryHash(self.data[24:self.payloadLength+24])
|
||||
if inventoryHash in inventory:
|
||||
print 'We have already received this broadcast object. Ignoring.'
|
||||
return
|
||||
elif isInSqlInventory(inventoryHash):
|
||||
print 'We have already received this broadcast object (it is stored on disk in the SQL inventory). Ignoring it.'
|
||||
return
|
||||
#It is valid so far. Let's let our peers know about it.
|
||||
objectType = 'broadcast'
|
||||
inventory[inventoryHash] = (objectType, self.streamNumber, self.data[24:self.payloadLength+24], embeddedTime)
|
||||
self.broadcastinv(inventoryHash)
|
||||
self.emit(SIGNAL("incrementNumberOfBroadcastsProcessed()"))
|
||||
|
||||
readPosition = 36
|
||||
broadcastVersion, broadcastVersionLength = decodeVarint(self.data[readPosition:readPosition+9])
|
||||
if broadcastVersion <> 1:
|
||||
#Cannot decode incoming broadcast versions higher than 1. Assuming the sender isn\' being silly, you should upgrade Bitmessage because this message shall be ignored.
|
||||
return
|
||||
readPosition += broadcastVersionLength
|
||||
sendersAddressVersion, sendersAddressVersionLength = decodeVarint(self.data[readPosition:readPosition+9])
|
||||
if sendersAddressVersion <> 1:
|
||||
#Cannot decode senderAddressVersion higher than 1. Assuming the sender isn\' being silly, you should upgrade Bitmessage because this message shall be ignored.
|
||||
return
|
||||
readPosition += sendersAddressVersionLength
|
||||
sendersStream, sendersStreamLength = decodeVarint(self.data[readPosition:readPosition+9])
|
||||
if sendersStream <= 0:
|
||||
return
|
||||
readPosition += sendersStreamLength
|
||||
sendersHash = self.data[readPosition:readPosition+20]
|
||||
if sendersHash not in broadcastSendersForWhichImWatching:
|
||||
return
|
||||
#At this point, this message claims to be from sendersHash and we are interested in it. We still have to hash the public key to make sure it is truly the key that matches the hash, and also check the signiture.
|
||||
readPosition += 20
|
||||
nLength, nLengthLength = decodeVarint(self.data[readPosition:readPosition+9])
|
||||
if nLength < 1:
|
||||
return
|
||||
readPosition += nLengthLength
|
||||
nString = self.data[readPosition:readPosition+nLength]
|
||||
readPosition += nLength
|
||||
eLength, eLengthLength = decodeVarint(self.data[readPosition:readPosition+9])
|
||||
if eLength < 1:
|
||||
return
|
||||
readPosition += eLengthLength
|
||||
eString = self.data[readPosition:readPosition+eLength]
|
||||
#We are now ready to hash the public key and verify that its hash matches the hash claimed in the message
|
||||
readPosition += eLength
|
||||
sha = hashlib.new('sha512')
|
||||
sha.update(nString+eString)
|
||||
ripe = hashlib.new('ripemd160')
|
||||
ripe.update(sha.digest())
|
||||
if ripe.digest() != sendersHash:
|
||||
#The sender of this message lied.
|
||||
return
|
||||
|
||||
readPositionAtBeginningOfMessageEncodingType = readPosition
|
||||
messageEncodingType, messageEncodingTypeLength = decodeVarint(self.data[readPosition:readPosition+9])
|
||||
if messageEncodingType == 0:
|
||||
return
|
||||
readPosition += messageEncodingTypeLength
|
||||
messageLength, messageLengthLength = decodeVarint(self.data[readPosition:readPosition+9])
|
||||
readPosition += messageLengthLength
|
||||
message = self.data[readPosition:readPosition+messageLength]
|
||||
readPosition += messageLength
|
||||
signature = self.data[readPosition:readPosition+nLength]
|
||||
print 'signature', repr(signature)
|
||||
sendersPubkey = rsa.PublicKey(convertStringToInt(nString),convertStringToInt(eString))
|
||||
#print 'senders Pubkey', sendersPubkey
|
||||
try:
|
||||
rsa.verify(self.data[readPositionAtBeginningOfMessageEncodingType:readPositionAtBeginningOfMessageEncodingType+messageEncodingTypeLength+messageLengthLength+messageLength],signature,sendersPubkey)
|
||||
print 'verify passed'
|
||||
except Exception, err:
|
||||
print 'verify failed', err
|
||||
return
|
||||
#verify passed
|
||||
fromAddress = encodeAddress(sendersAddressVersion,sendersStream,ripe.digest())
|
||||
print 'fromAddress:', fromAddress
|
||||
|
||||
if messageEncodingType == 2:
|
||||
headers = Parser().parsestr(message)
|
||||
subject = headers['subject']
|
||||
body = headers['body']
|
||||
elif messageEncodingType == 1:
|
||||
body = message
|
||||
subject = ''
|
||||
elif messageEncodingType == 0:
|
||||
print 'messageEncodingType == 0. Doing nothing with the message.'
|
||||
else:
|
||||
body = 'Unknown encoding type.\n\n' + repr(message)
|
||||
subject = ''
|
||||
|
||||
toAddress = '[Broadcast subscribers]'
|
||||
if messageEncodingType <> 0:
|
||||
sqlLock.acquire()
|
||||
t = (inventoryHash,toAddress,fromAddress,subject,int(time.time()),body,'inbox')
|
||||
sqlSubmitQueue.put('''INSERT INTO inbox VALUES (,?,?,?,?,?,?)''')
|
||||
sqlSubmitQueue.put(t)
|
||||
sqlReturnQueue.get()
|
||||
sqlLock.release()
|
||||
self.emit(SIGNAL("displayNewMessage(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"),inventoryHasy,toAddress,fromAddress,subject,body)
|
||||
|
||||
#We have received a msg message.
|
||||
def recmsg(self):
|
||||
#First we must check to make sure the proof of work is sufficient.
|
||||
'''sha = hashlib.new('sha512')
|
||||
sha.update(self.data[24:24+self.payloadLength])
|
||||
sha2 = hashlib.new('sha512')
|
||||
sha2.update(sha.digest())'''
|
||||
POW, = unpack('>Q',hashlib.sha512(hashlib.sha512(self.data[24:24+self.payloadLength]).digest()).digest()[4:12])
|
||||
print 'POW:', POW
|
||||
initialDecryptionSuccessful = False
|
||||
if POW > 2**64 / ((self.payloadLength+payloadLengthExtraBytes) * averageProofOfWorkNonceTrialsPerByte):
|
||||
print 'Proof of work in msg message insufficient.'
|
||||
return
|
||||
|
||||
readPosition = 32
|
||||
embeddedTime, = unpack('>I',self.data[readPosition:readPosition+4])
|
||||
if embeddedTime > int(time.time())+10800:
|
||||
print 'The time in the msg message is too new. Ignoring it. Time:', embeddedTime
|
||||
return
|
||||
if embeddedTime < int(time.time())-maximumAgeOfAnObjectThatIAmWillingToAccept:
|
||||
print 'The time in the msg message is too old. Ignoring it. Time:', embeddedTime
|
||||
return
|
||||
readPosition += 4
|
||||
inventoryHash = calculateInventoryHash(self.data[24:self.payloadLength+24])
|
||||
if inventoryHash in inventory:
|
||||
print 'We have already received this msg message. Ignoring.'
|
||||
return
|
||||
elif isInSqlInventory(inventoryHash):
|
||||
print 'We have already received this msg message (it is stored on disk in the SQL inventory). Ignoring it.'
|
||||
return
|
||||
streamNumberAsClaimedByMsg, streamNumberAsClaimedByMsgLength = decodeVarint(self.data[readPosition:readPosition+9])
|
||||
if streamNumberAsClaimedByMsg != self.streamNumber:
|
||||
print 'The stream number encoded in this msg (' + streamNumberAsClaimedByMsg + ') message does not match the stream number on which it was received. Ignoring it.'
|
||||
return
|
||||
readPosition += streamNumberAsClaimedByMsgLength
|
||||
#This msg message is valid. Let's let our peers know about it.
|
||||
objectType = 'msg'
|
||||
inventory[inventoryHash] = (objectType, self.streamNumber, self.data[24:self.payloadLength+24], embeddedTime)
|
||||
self.broadcastinv(inventoryHash)
|
||||
self.emit(SIGNAL("incrementNumberOfMessagesProcessed()"))
|
||||
|
||||
#Let's check whether this is a message acknowledgement bound for us.
|
||||
if self.data[readPosition:24+self.payloadLength] in ackdataForWhichImWatching:
|
||||
printLock.acquire()
|
||||
print 'This msg is an acknowledgement bound for me.'
|
||||
printLock.release()
|
||||
del ackdataForWhichImWatching[self.data[readPosition:24+self.payloadLength]]
|
||||
t = ('ackreceived',self.data[readPosition:24+self.payloadLength])
|
||||
sqlLock.acquire()
|
||||
sqlSubmitQueue.put('UPDATE sent SET status=? WHERE ackdata=?')
|
||||
sqlSubmitQueue.put(t)
|
||||
sqlReturnQueue.get()
|
||||
sqlLock.release()
|
||||
self.emit(SIGNAL("updateSentItemStatusByAckdata(PyQt_PyObject,PyQt_PyObject)"),self.data[readPosition:24+self.payloadLength],'Acknowledgement of the message received just now.')
|
||||
flushInventory() #so that we won't accidentially receive this message twice if the user restarts Bitmessage soon.
|
||||
return
|
||||
else:
|
||||
printLock.acquire()
|
||||
print 'This was NOT an acknowledgement bound for me. Msg potential ack data:', repr(self.data[readPosition:24+self.payloadLength])
|
||||
print 'ackdataForWhichImWatching', ackdataForWhichImWatching
|
||||
printLock.release()
|
||||
|
||||
#This is not an acknowledgement bound for me. See if it is a message bound for me by trying to decrypt it with my private keys.
|
||||
infile = cStringIO.StringIO(self.data[readPosition:self.payloadLength+24])
|
||||
outfile = cStringIO.StringIO()
|
||||
#print 'len(myAddressHashes.items()):', len(myAddressHashes.items())
|
||||
for key, value in myAddressHashes.items():
|
||||
try:
|
||||
decrypt_bigfile(infile, outfile, value)
|
||||
#The initial decryption passed though there is a small chance that the message isn't actually for me. We'll need to check that the 20 zeros are present.
|
||||
#print 'initial decryption successful using key', repr(key)
|
||||
initialDecryptionSuccessful = True
|
||||
printLock.acquire()
|
||||
print 'Initial decryption passed'
|
||||
printLock.release()
|
||||
break
|
||||
except Exception, err:
|
||||
infile.seek(0)
|
||||
#print 'Exception:', err
|
||||
#print 'outfile len is:', len(outfile.getvalue()),'data is:', repr(outfile.getvalue())
|
||||
#print 'Initial decryption failed using key', value
|
||||
#decryption failed for this key. The message is for someone else (or for a different key of mine).
|
||||
if initialDecryptionSuccessful and outfile.getvalue()[:20] == '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00': #this run of 0s allows the true message receiver to identify his message
|
||||
#This is clearly a message bound for me.
|
||||
flushInventory() #so that we won't accidentially receive this message twice if the user restarts Bitmessage soon.
|
||||
outfile.seek(0)
|
||||
data = outfile.getvalue()
|
||||
readPosition = 20 #To start reading past the 20 zero bytes
|
||||
messageVersion, messageVersionLength = decodeVarint(data[readPosition:readPosition+10])
|
||||
readPosition += messageVersionLength
|
||||
if messageVersion == 1:
|
||||
bitfieldBehavior = data[readPosition:readPosition+4]
|
||||
readPosition += 4
|
||||
sendersAddressVersionNumber, sendersAddressVersionNumberLength = decodeVarint(data[readPosition:readPosition+10])
|
||||
if sendersAddressVersionNumber == 1:
|
||||
readPosition += sendersAddressVersionNumberLength
|
||||
sendersStreamNumber, sendersStreamNumberLength = decodeVarint(data[readPosition:readPosition+10])
|
||||
readPosition += sendersStreamNumberLength
|
||||
|
||||
sendersNLength, sendersNLengthLength = decodeVarint(data[readPosition:readPosition+10])
|
||||
readPosition += sendersNLengthLength
|
||||
sendersN = data[readPosition:readPosition+sendersNLength]
|
||||
readPosition += sendersNLength
|
||||
sendersELength, sendersELengthLength = decodeVarint(data[readPosition:readPosition+10])
|
||||
readPosition += sendersELengthLength
|
||||
sendersE = data[readPosition:readPosition+sendersELength]
|
||||
readPosition += sendersELength
|
||||
endOfThePublicKeyPosition = readPosition
|
||||
|
||||
|
||||
messageEncodingType, messageEncodingTypeLength = decodeVarint(data[readPosition:readPosition+10])
|
||||
readPosition += messageEncodingTypeLength
|
||||
print 'Message Encoding Type:', messageEncodingType
|
||||
messageLength, messageLengthLength = decodeVarint(data[readPosition:readPosition+10])
|
||||
print 'message length:', messageLength
|
||||
readPosition += messageLengthLength
|
||||
message = data[readPosition:readPosition+messageLength]
|
||||
#print 'First 150 characters of message:', repr(message[:150])
|
||||
readPosition += messageLength
|
||||
ackLength, ackLengthLength = decodeVarint(data[readPosition:readPosition+10])
|
||||
#print 'ackLength:', ackLength
|
||||
readPosition += ackLengthLength
|
||||
ackData = data[readPosition:readPosition+ackLength]
|
||||
readPosition += ackLength
|
||||
payloadSigniture = data[readPosition:readPosition+sendersNLength] #We're using the length of the sender's n because it should match the signiture size.
|
||||
sendersPubkey = rsa.PublicKey(convertStringToInt(sendersN),convertStringToInt(sendersE))
|
||||
print 'senders Pubkey', sendersPubkey
|
||||
verifyPassed = False
|
||||
try:
|
||||
rsa.verify(data[:-len(payloadSigniture)],payloadSigniture, sendersPubkey)
|
||||
print 'verify passed'
|
||||
verifyPassed = True
|
||||
except Exception, err:
|
||||
print 'verify failed', err
|
||||
if verifyPassed:
|
||||
#Let's calculate the fromAddress.
|
||||
sha = hashlib.new('sha512')
|
||||
sha.update(sendersN+sendersE)
|
||||
ripe = hashlib.new('ripemd160')
|
||||
ripe.update(sha.digest())
|
||||
|
||||
#We have reached the end of the public key. Let's store it in case we want to reply to this person.
|
||||
#We don't have the correct nonce in order to send out a pubkey message so we'll just fill it with 1's. We won't be able to send this pubkey to others (without doing the proof of work ourselves, which this program is programmed to not do.)
|
||||
t = (ripe.digest(),False,'\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF'+data[20+messageVersionLength:endOfThePublicKeyPosition],int(time.time())+2419200) #after one month we may remove this pub key from our database.
|
||||
sqlLock.acquire()
|
||||
sqlSubmitQueue.put('''INSERT INTO pubkeys VALUES (?,?,?,?)''')
|
||||
sqlSubmitQueue.put(t)
|
||||
sqlReturnQueue.get()
|
||||
sqlLock.release()
|
||||
|
||||
blockMessage = False #Set to True if the user shouldn't see the message according to black or white lists.
|
||||
fromAddress = encodeAddress(sendersAddressVersionNumber,sendersStreamNumber,ripe.digest())
|
||||
if config.get('bitmessagesettings', 'blackwhitelist') == 'black':
|
||||
t = (fromAddress,)
|
||||
sqlLock.acquire()
|
||||
sqlSubmitQueue.put('''SELECT label, enabled FROM blacklist where address=?''')
|
||||
sqlSubmitQueue.put(t)
|
||||
queryreturn = sqlReturnQueue.get()
|
||||
sqlLock.release()
|
||||
for row in queryreturn:
|
||||
label, enabled = row
|
||||
if enabled:
|
||||
print 'Message ignored because address is in blacklist.'
|
||||
blockMessage = True
|
||||
else: #We're using a whitelist
|
||||
t = (fromAddress,)
|
||||
sqlLock.acquire()
|
||||
sqlSubmitQueue.put('''SELECT label, enabled FROM whitelist where address=?''')
|
||||
sqlSubmitQueue.put(t)
|
||||
queryreturn = sqlReturnQueue.get()
|
||||
sqlLock.release()
|
||||
if queryreturn == []:
|
||||
print 'Message ignored because address not in whitelist.'
|
||||
blockMessage = True
|
||||
for row in queryreturn: #It could be in the whitelist but disabled. Let's check.
|
||||
label, enabled = row
|
||||
if not enabled:
|
||||
print 'Message ignored because address in whitelist but not enabled.'
|
||||
blockMessage = True
|
||||
|
||||
if not blockMessage:
|
||||
print 'fromAddress:', fromAddress
|
||||
print 'First 150 characters of message:', repr(message[:150])
|
||||
|
||||
#Now I would like to find the destination address (my address). Right now all I have is the ripe hash. I realize that I
|
||||
#could have a data structure devoted to this task, or maintain an indexed table in the sql database, but I would prefer to
|
||||
#minimize the number of data structures this program uses, and searching linearly through a short list for each message
|
||||
#received doesn't take very long anyway.
|
||||
configSections = config.sections()
|
||||
for addressInKeysFile in configSections:
|
||||
if addressInKeysFile <> 'bitmessagesettings':
|
||||
status,addressVersionNumber,streamNumber,hash = decodeAddress(addressInKeysFile)
|
||||
if hash == key:
|
||||
toAddress = addressInKeysFile
|
||||
toLabel = config.get(addressInKeysFile, 'label')
|
||||
if toLabel == '':
|
||||
toLabel = addressInKeysFile
|
||||
|
||||
if messageEncodingType == 2:
|
||||
headers = Parser().parsestr(message)
|
||||
subject = headers['subject']
|
||||
body = headers['body']
|
||||
elif messageEncodingType == 1:
|
||||
body = message
|
||||
subject = ''
|
||||
elif messageEncodingType == 0:
|
||||
print 'messageEncodingType == 0. Doing nothing with the message. They probably just sent it so that we would store their public key or send their ack data for them.'
|
||||
else:
|
||||
body = 'Unknown encoding type.\n\n' + repr(message)
|
||||
subject = ''
|
||||
|
||||
if messageEncodingType <> 0:
|
||||
sqlLock.acquire()
|
||||
t = (inventoryHash,toAddress,fromAddress,subject,int(time.time()),body,'inbox')
|
||||
sqlSubmitQueue.put('''INSERT INTO inbox VALUES (?,?,?,?,?,?,?)''')
|
||||
sqlSubmitQueue.put(t)
|
||||
sqlReturnQueue.get()
|
||||
sqlLock.release()
|
||||
self.emit(SIGNAL("displayNewMessage(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"),inventoryHash,toAddress,fromAddress,subject,body)
|
||||
#Now let's send the acknowledgement
|
||||
POW, = unpack('>Q',hashlib.sha512(hashlib.sha512(ackData[24:]).digest()).digest()[4:12])
|
||||
if POW <= 2**64 / ((len(ackData[24:])+payloadLengthExtraBytes) * averageProofOfWorkNonceTrialsPerByte):
|
||||
print 'The POW is strong enough that this ackdataPayload will be accepted by the Bitmessage network.'
|
||||
#Currently PyBitmessage only supports sending a message with the acknowledgement in the form of a msg message. But future versions, and other clients, could send any object and this software will relay them. This can be used to relay identifying information, like your public key, through another Bitmessage host in case you believe that your Internet connection is being individually watched. You may pick a random address, hope its owner is online, and send a message with encoding type 0 so that they ignore the message but send your acknowledgement data over the network. If you send and receive many messages, it would also be clever to take someone else's acknowledgement data and use it for your own. Assuming that your message is delivered successfully, both will be acknowledged simultaneously (though if it is not delivered successfully, you will be in a pickle.)
|
||||
#print 'self.data before:', repr(self.data)
|
||||
self.data = self.data[:self.payloadLength+24] + ackData + self.data[self.payloadLength+24:]
|
||||
#print 'self.data after:', repr(self.data)
|
||||
'''if ackData[4:16] == 'msg\x00\x00\x00\x00\x00\x00\x00\x00\x00':
|
||||
inventoryHash = calculateInventoryHash(ackData[24:])
|
||||
#objectType = 'msg'
|
||||
#inventory[inventoryHash] = (objectType, self.streamNumber, ackData[24:], embeddedTime) #We should probably be storing the embeddedTime of the ackData, not the embeddedTime of the original incoming msg message, but this is probably close enough.
|
||||
#print 'sending the inv for the msg which is actually an acknowledgement (within sendmsg function)'
|
||||
#self.broadcastinv(inventoryHash)
|
||||
self.data[:payloadLength+24] + ackData + self.data[payloadLength+24:]
|
||||
elif ackData[4:16] == 'getpubkey\x00\x00\x00':
|
||||
#objectType = 'getpubkey'
|
||||
#inventory[inventoryHash] = (objectType, self.streamNumber, ackData[24:], embeddedTime) #We should probably be storing the embeddedTime of the ackData, not the embeddedTime of the original incoming msg message, but this is probably close enough.
|
||||
#print 'sending the inv for the getpubkey which is actually an acknowledgement (within sendmsg function)'
|
||||
self.data[:payloadLength+24] + ackData + self.data[payloadLength+24:]
|
||||
elif ackData[4:16] == 'pubkey\x00\x00\x00\x00\x00\x00':
|
||||
#objectType = 'pubkey'
|
||||
#inventory[inventoryHash] = (objectType, self.streamNumber, ackData[24:], embeddedTime) #We should probably be storing the embeddedTime of the ackData, not the embeddedTime of the original incoming msg message, but this is probably close enough.
|
||||
#print 'sending the inv for a pubkey which is actually an acknowledgement (within sendmsg function)'
|
||||
self.data[:payloadLength+24] + ackData + self.data[payloadLength+24:]
|
||||
elif ackData[4:16] == 'broadcast\x00\x00\x00':
|
||||
#objectType = 'broadcast'
|
||||
#inventory[inventoryHash] = (objectType, self.streamNumber, ackData[24:], embeddedTime) #We should probably be storing the embeddedTime of the ackData, not the embeddedTime of the original incoming msg message, but this is probably close enough.
|
||||
#print 'sending the inv for a broadcast which is actually an acknowledgement (within sendmsg function)'
|
||||
self.data[:payloadLength+24] + ackData + self.data[payloadLength+24:]'''
|
||||
else:
|
||||
print 'ACK POW not strong enough to be accepted by the Bitmessage network.'
|
||||
|
||||
else:
|
||||
print 'This program cannot decode messages from addresses with versions higher than 1. Ignoring.'
|
||||
statusbar = 'This program cannot decode messages from addresses with versions higher than 1. Ignoring it.'
|
||||
self.emit(SIGNAL("updateStatusBar(PyQt_PyObject)"),statusbar)
|
||||
else:
|
||||
print 'Error: Cannot decode incoming msg versions higher than 1. Assuming the sender isn\' being silly, you should upgrade Bitmessage because this message shall be ignored.'
|
||||
statusbar = 'Error: Cannot decode incoming msg versions higher than 1. Assuming the sender isn\' being silly, you should upgrade Bitmessage because this message shall be ignored.'
|
||||
self.emit(SIGNAL("updateStatusBar(PyQt_PyObject)"),statusbar)
|
||||
else:
|
||||
printLock.acquire()
|
||||
print 'Decryption unsuccessful.'
|
||||
printLock.release()
|
||||
infile.close()
|
||||
outfile.close()
|
||||
|
||||
#We have received a pubkey
|
||||
def recpubkey(self):
|
||||
inventoryHash = calculateInventoryHash(self.data[24:self.payloadLength+24])
|
||||
if inventoryHash in inventory:
|
||||
print 'We have already received this pubkey. Ignoring it.'
|
||||
return
|
||||
|
||||
#We must check to make sure the proof of work is sufficient.
|
||||
POW, = unpack('>Q',hashlib.sha512(hashlib.sha512(self.data[24:24+self.payloadLength]).digest()).digest()[4:12])
|
||||
print 'POW:', POW
|
||||
if POW > 2**64 / ((self.payloadLength+payloadLengthExtraBytes) * averageProofOfWorkNonceTrialsPerByte):
|
||||
printLock.acquire()
|
||||
print 'The Proof of Work in the pubkey message is insufficient. Ignoring it.'
|
||||
print 'pubkey payload length:', len(self.data[24:self.payloadLength+24])
|
||||
print repr(self.data[24:self.payloadLength+24])
|
||||
printLock.release()
|
||||
return
|
||||
|
||||
objectType = 'pubkey'
|
||||
inventory[inventoryHash] = (objectType, self.streamNumber, self.data[24:self.payloadLength+24], int(time.time()))
|
||||
self.broadcastinv(inventoryHash)
|
||||
self.emit(SIGNAL("incrementNumberOfPubkeysProcessed()"))
|
||||
|
||||
readPosition = 24 #for the message header
|
||||
readPosition += 8 #for the nonce
|
||||
bitfieldBehaviors = self.data[readPosition:readPosition+4]
|
||||
readPosition += 4 #for the bitfield of behaviors and features
|
||||
addressVersion, varintLength = decodeVarint(self.data[readPosition:readPosition+10])
|
||||
readPosition += varintLength
|
||||
streamNumber, varintLength = decodeVarint(self.data[readPosition:readPosition+10])
|
||||
readPosition += varintLength
|
||||
#ripe = self.data[readPosition:readPosition+20]
|
||||
#readPosition += 20 #for the ripe hash
|
||||
nLength, varintLength = decodeVarint(self.data[readPosition:readPosition+10])
|
||||
readPosition += varintLength
|
||||
nString = self.data[readPosition:readPosition+nLength]
|
||||
readPosition += nLength
|
||||
eLength, varintLength = decodeVarint(self.data[readPosition:readPosition+10])
|
||||
readPosition += varintLength
|
||||
eString = self.data[readPosition:readPosition+eLength]
|
||||
readPosition += eLength
|
||||
|
||||
sha = hashlib.new('sha512')
|
||||
sha.update(nString+eString)
|
||||
ripeHasher = hashlib.new('ripemd160')
|
||||
ripeHasher.update(sha.digest())
|
||||
ripe = ripeHasher.digest()
|
||||
|
||||
print 'within recpubkey, addressVersion', addressVersion
|
||||
print 'streamNumber', streamNumber
|
||||
print 'ripe', ripe
|
||||
print 'n=', convertStringToInt(nString)
|
||||
print 'e=', convertStringToInt(eString)
|
||||
|
||||
t = (ripe,True,self.data[24:24+self.payloadLength],int(time.time())+604800) #after one week we may remove this pub key from our database.
|
||||
sqlLock.acquire()
|
||||
sqlSubmitQueue.put('''INSERT INTO pubkeys VALUES (?,?,?,?)''')
|
||||
sqlSubmitQueue.put(t)
|
||||
sqlReturnQueue.get()
|
||||
sqlLock.release()
|
||||
print 'added foreign pubkey into our database'
|
||||
workerQueue.put(('newpubkey',(addressVersion,streamNumber,ripe)))
|
||||
|
||||
#We have received a getpubkey message
|
||||
def recgetpubkey(self):
|
||||
inventoryHash = calculateInventoryHash(self.data[24:self.payloadLength+24])
|
||||
if inventoryHash in inventory:
|
||||
print 'We have already received this getpubkey request. Ignoring it.'
|
||||
elif isInSqlInventory(inventoryHash):
|
||||
print 'We have already received this getpubkey request (it is stored on disk in the SQL inventory). Ignoring it.'
|
||||
else:
|
||||
objectType = 'pubkeyrequest'
|
||||
inventory[inventoryHash] = (objectType, self.streamNumber, self.data[24:self.payloadLength+24], int(time.time()))
|
||||
#First we must check to make sure the proof of work is sufficient.
|
||||
POW, = unpack('>Q',hashlib.sha512(hashlib.sha512(self.data[24:24+self.payloadLength]).digest()).digest()[4:12])
|
||||
print 'POW:', POW
|
||||
if POW > 2**64 / ((self.payloadLength+payloadLengthExtraBytes) * averageProofOfWorkNonceTrialsPerByte):
|
||||
print 'POW value in getpubkey message is insufficient. Ignoring it.'
|
||||
return
|
||||
#Now let us make sure that the getpubkey request isn't too old or with a fake (future) time.
|
||||
embeddedTime, = unpack('>I',self.data[32:36])
|
||||
if embeddedTime > int(time.time())+10800:
|
||||
print 'The time in this getpubkey message is too new. Ignoring it. Time:', embeddedTime
|
||||
return
|
||||
if embeddedTime < int(time.time())-maximumAgeOfAnObjectThatIAmWillingToAccept:
|
||||
print 'The time in this getpubkey message is too old. Ignoring it. Time:', embeddedTime
|
||||
return
|
||||
addressVersionNumber, addressVersionLength = decodeVarint(self.data[36:42])
|
||||
if addressVersionNumber > 1:
|
||||
print 'The addressVersionNumber of the pubkey is too high. Can\'t understand. Ignoring it.'
|
||||
return
|
||||
streamNumber, streamNumberLength = decodeVarint(self.data[36+addressVersionLength:42+addressVersionLength])
|
||||
if streamNumber <> self.streamNumber:
|
||||
print 'The streamNumber', streamNumber, 'doesn\'t match our stream number:', self.streamNumber
|
||||
return
|
||||
if self.data[36+addressVersionLength+streamNumberLength:56+addressVersionLength+streamNumberLength] in myAddressHashes:
|
||||
print 'Found getpubkey requested hash in my list of hashes.'
|
||||
#check to see whether we have already calculated the nonce and transmitted this key before
|
||||
sqlLock.acquire()#released at the bottom of this payload generation section
|
||||
t = (self.data[36+addressVersionLength+streamNumberLength:56+addressVersionLength+streamNumberLength],) #this prevents SQL injection
|
||||
sqlSubmitQueue.put('SELECT * FROM pubkeys WHERE hash=?')
|
||||
sqlSubmitQueue.put(t)
|
||||
queryreturn = sqlReturnQueue.get()
|
||||
#print 'queryreturn', queryreturn
|
||||
|
||||
if queryreturn == []:
|
||||
print 'pubkey request is for me but the pubkey is not in our database of pubkeys. Making it.'
|
||||
payload = '\x00\x00\x00\x01' #bitfield of features supported by me (see the wiki).
|
||||
payload += self.data[36:36+addressVersionLength+streamNumberLength]
|
||||
#print int(config.get(encodeAddress(addressVersionNumber,streamNumber,self.data[36+addressVersionLength+streamNumberLength:56+addressVersionLength+streamNumberLength]), 'n'))
|
||||
nString = convertIntToString(int(config.get(encodeAddress(addressVersionNumber,streamNumber,self.data[36+addressVersionLength+streamNumberLength:56+addressVersionLength+streamNumberLength]), 'n')))
|
||||
eString = convertIntToString(config.getint(encodeAddress(addressVersionNumber,streamNumber,self.data[36+addressVersionLength+streamNumberLength:56+addressVersionLength+streamNumberLength]), 'e'))
|
||||
payload += encodeVarint(len(nString))
|
||||
payload += nString
|
||||
payload += encodeVarint(len(eString))
|
||||
payload += eString
|
||||
|
||||
nonce = 0
|
||||
trialValue = 99999999999999999
|
||||
target = 2**64 / ((len(payload)+payloadLengthExtraBytes+8) * averageProofOfWorkNonceTrialsPerByte) #The 108 added to the payload length is 8 for the size of the nonce + 50 as an extra penalty simply for having this seperate message exist.
|
||||
print '(For pubkey message) Doing proof of work...'
|
||||
while trialValue > target:
|
||||
nonce += 1
|
||||
trialValue, = unpack('>Q',hashlib.sha512(hashlib.sha512(pack('>Q',nonce) + payload).digest()).digest()[4:12])
|
||||
print '(For pubkey message) Found proof of work', trialValue, 'Nonce:', nonce
|
||||
|
||||
payload = pack('>Q',nonce) + payload
|
||||
t = (self.data[36+addressVersionLength+streamNumberLength:56+addressVersionLength+streamNumberLength],True,payload,int(time.time())+1209600) #after two weeks (1,209,600 seconds), we may remove our own pub key from our database. It will be regenerated and put back in the database if it is requested.
|
||||
sqlSubmitQueue.put('''INSERT INTO pubkeys VALUES (?,?,?,?)''')
|
||||
sqlSubmitQueue.put(t)
|
||||
queryreturn = sqlReturnQueue.get()
|
||||
|
||||
#Now that we have the key either from getting it earlier or making it and storing it ourselves...
|
||||
t = (self.data[36+addressVersionLength+streamNumberLength:56+addressVersionLength+streamNumberLength],) #this prevents SQL injection
|
||||
sqlSubmitQueue.put('SELECT * FROM pubkeys WHERE hash=?')
|
||||
sqlSubmitQueue.put(t)
|
||||
queryreturn = sqlReturnQueue.get()
|
||||
|
||||
for row in queryreturn:
|
||||
hash, havecorrectnonce, payload, timeLastRequested = row
|
||||
if timeLastRequested < int(time.time())+604800: #if the last time anyone asked about this hash was this week, extend the time.
|
||||
t = (int(time.time())+604800,hash)
|
||||
sqlSubmitQueue.put('''UPDATE pubkeys set time=? WHERE hash=?''')
|
||||
sqlSubmitQueue.put(t)
|
||||
queryreturn = sqlReturnQueue.get()
|
||||
|
||||
sqlLock.release()
|
||||
|
||||
inventoryHash = calculateInventoryHash(payload)
|
||||
objectType = 'pubkey'
|
||||
inventory[inventoryHash] = (objectType, self.streamNumber, payload, int(time.time()))
|
||||
self.broadcastinv(inventoryHash)
|
||||
|
||||
else:
|
||||
print 'Hash in getpubkey is not mine.'
|
||||
#..but lets see if we have it stored from when it came in from someone else.
|
||||
t = (self.data[36+addressVersionLength+streamNumberLength:56+addressVersionLength+streamNumberLength],) #this prevents SQL injection
|
||||
sqlLock.acquire()
|
||||
sqlSubmitQueue.put('''SELECT hash, time FROM pubkeys WHERE hash=? AND havecorrectnonce='True' ''')
|
||||
sqlSubmitQueue.put(t)
|
||||
queryreturn = sqlReturnQueue.get()
|
||||
sqlLock.release()
|
||||
print 'queryreturn', queryreturn
|
||||
if queryreturn <> []:
|
||||
print 'we have the public key. sending it.'
|
||||
#We have it. Let's send it.
|
||||
for row in queryreturn:
|
||||
hash, timeLastRequested = row
|
||||
if timeLastRequested < int(time.time())+604800: #if the last time anyone asked about this hash was this week, extend the time.
|
||||
t = (int(time.time())+604800,hash)
|
||||
sqlSubmitQueue.put('''UPDATE pubkeys set time=? WHERE hash=?''')
|
||||
sqlSubmitQueue.put(t)
|
||||
queryreturn = sqlReturnQueue.get()
|
||||
inventoryHash = calculateInventoryHash(self.data[24:self.payloadLength+24])
|
||||
objectType = 'pubkey'
|
||||
inventory[inventoryHash] = (objectType, self.streamNumber, self.data[24:self.payloadLength+24], int(time.time()))
|
||||
self.broadcastinv(inventoryHash)
|
||||
else:
|
||||
#We don't have it. We'll need to forward the getpubkey request to our peers.
|
||||
print 'We don\' have the public key. Forwarding getpubkey message to peers.'
|
||||
broadcastToSendDataQueues((self.streamNumber,'send',self.data[:self.payloadLength+24]))
|
||||
|
||||
#We have received an inv message
|
||||
def recinv(self):
|
||||
numberOfItemsInInv, lengthOfVarint = decodeVarint(self.data[24:34])
|
||||
if numberOfItemsInInv == 1: #we'll just request this data from the person who advertised the object.
|
||||
for i in range(numberOfItemsInInv):
|
||||
if self.data[24+lengthOfVarint+(32*i):56+lengthOfVarint+(32*i)] in inventory:
|
||||
print 'Inventory (in memory) has inventory item already.'
|
||||
elif isInSqlInventory(self.data[24+lengthOfVarint+(32*i):56+lengthOfVarint+(32*i)]):
|
||||
print 'Inventory (SQL on disk) has inventory item already.'
|
||||
else:
|
||||
self.sendgetdata(self.data[24+lengthOfVarint+(32*i):56+lengthOfVarint+(32*i)])
|
||||
else:
|
||||
print 'inv message lists', numberOfItemsInInv, 'objects.'
|
||||
for i in range(numberOfItemsInInv): #upon finishing dealing with an incoming message, the receiveDataThread will request a random object from the peer. This way if we get multiple inv messages from multiple peers which list mostly the same objects, we will make getdata requests for different random objects from the various peers.
|
||||
#print 'Adding object to self.objectsThatWeHaveYetToGet.'
|
||||
self.objectsThatWeHaveYetToGet[self.data[24+lengthOfVarint+(32*i):56+lengthOfVarint+(32*i)]] = 0
|
||||
print 'length of objectsThatWeHaveYetToGet', len(self.objectsThatWeHaveYetToGet)
|
||||
|
||||
#Send a getdata message to our peer to request the object with the given hash
|
||||
def sendgetdata(self,hash):
|
||||
print 'sending getdata with hash', repr(hash)
|
||||
payload = '\x01' + hash
|
||||
headerData = '\xe9\xbe\xb4\xd9' #magic bits, slighly different from Bitcoin's magic bits.
|
||||
headerData = headerData + 'getdata\x00\x00\x00\x00\x00'
|
||||
headerData = headerData + pack('>L',len(payload)) #payload length. Note that we add an extra 8 for the nonce.
|
||||
'''sha = hashlib.new('sha512')
|
||||
sha.update(payload)
|
||||
sha2 = hashlib.new('sha512')
|
||||
sha2.update(sha.digest())'''
|
||||
headerData = headerData + hashlib.sha512(hashlib.sha512(payload).digest()).digest()[:4]
|
||||
self.sock.send(headerData + payload)
|
||||
|
||||
#We have received a getdata request from our peer
|
||||
def recgetdata(self):
|
||||
value, lengthOfVarint = decodeVarint(self.data[24:34])
|
||||
#print 'Number of items in getdata request:', value
|
||||
try:
|
||||
for i in range(value):
|
||||
hash = self.data[24+lengthOfVarint+(i*32):56+lengthOfVarint+(i*32)]
|
||||
print 'getdata request for item:', repr(hash), 'length', len(hash)
|
||||
#print 'inventory is', inventory
|
||||
if hash in inventory:
|
||||
objectType, streamNumber, payload, receivedTime = inventory[hash]
|
||||
self.sendData(objectType,payload)
|
||||
else:
|
||||
t = (hash,)
|
||||
sqlLock.acquire()
|
||||
sqlSubmitQueue.put('''select objecttype, payload from inventory where hash=?''')
|
||||
sqlSubmitQueue.put(t)
|
||||
queryreturn = sqlReturnQueue.get()
|
||||
sqlLock.release()
|
||||
if queryreturn <> []:
|
||||
for row in queryreturn:
|
||||
objectType, payload = row
|
||||
print 'Sending data out of inventory that came from sql.' #todo: remove line
|
||||
self.sendData(objectType,payload)
|
||||
else:
|
||||
print 'Someone asked for an object with a getdata which is not in either our memory inventory or our SQL inventory. That shouldn\'t have happened.'
|
||||
|
||||
except:
|
||||
pass #someone is probably trying to cause a program error by, for example, making a request for 10 items but only including the hashes for 5.
|
||||
|
||||
#Our peer has requested (in a getdata message) that we send an object.
|
||||
def sendData(self,objectType,payload):
|
||||
if objectType == 'pubkey':
|
||||
print 'sending pubkey'
|
||||
headerData = '\xe9\xbe\xb4\xd9' #magic bits, slighly different from Bitcoin's magic bits.
|
||||
headerData = headerData + 'pubkey\x00\x00\x00\x00\x00\x00'
|
||||
headerData = headerData + pack('>L',len(payload)) #payload length. Note that we add an extra 8 for the nonce.
|
||||
headerData = headerData + hashlib.sha512(hashlib.sha512(payload).digest()).digest()[:4]
|
||||
self.sock.send(headerData + payload)
|
||||
elif objectType == 'pubkeyrequest':
|
||||
print 'sending pubkeyrequest'
|
||||
headerData = '\xe9\xbe\xb4\xd9' #magic bits, slighly different from Bitcoin's magic bits.
|
||||
headerData = headerData + 'getpubkey\x00\x00\x00'
|
||||
headerData = headerData + pack('>L',len(payload)) #payload length. Note that we add an extra 8 for the nonce.
|
||||
headerData = headerData + hashlib.sha512(hashlib.sha512(payload).digest()).digest()[:4]
|
||||
self.sock.send(headerData + payload)
|
||||
elif objectType == 'msg':
|
||||
print 'sending msg'
|
||||
headerData = '\xe9\xbe\xb4\xd9' #magic bits, slighly different from Bitcoin's magic bits.
|
||||
headerData = headerData + 'msg\x00\x00\x00\x00\x00\x00\x00\x00\x00'
|
||||
headerData = headerData + pack('>L',len(payload)) #payload length. Note that we add an extra 8 for the nonce.
|
||||
headerData = headerData + hashlib.sha512(hashlib.sha512(payload).digest()).digest()[:4]
|
||||
self.sock.send(headerData + payload)
|
||||
elif objectType == 'broadcast':
|
||||
print 'sending broadcast'
|
||||
headerData = '\xe9\xbe\xb4\xd9' #magic bits, slighly different from Bitcoin's magic bits.
|
||||
headerData = headerData + 'broadcast\x00\x00\x00'
|
||||
headerData = headerData + pack('>L',len(payload)) #payload length. Note that we add an extra 8 for the nonce.
|
||||
headerData = headerData + hashlib.sha512(hashlib.sha512(payload).digest()).digest()[:4]
|
||||
self.sock.send(headerData + payload)
|
||||
elif objectType == 'getpubkey':
|
||||
print 'sending getpubkey'
|
||||
headerData = '\xe9\xbe\xb4\xd9' #magic bits, slighly different from Bitcoin's magic bits.
|
||||
headerData = headerData + 'getpubkey\x00\x00\x00' #version command
|
||||
headerData = headerData + pack('>L',len(payload)) #payload length
|
||||
headerData = headerData + hashlib.sha512(hashlib.sha512(payload).digest()).digest()[0:4]
|
||||
self.sock.send(headerData + payload)
|
||||
else:
|
||||
sys.stderr.write('Error: sendData has been asked to send a strange objectType: %s\n' % str(objectType))
|
||||
|
||||
#Send an inv message with just one hash to all of our peers
|
||||
def broadcastinv(self,hash):
|
||||
print 'sending inv'
|
||||
#payload = '\x01' + pack('>H',objectType) + hash
|
||||
payload = '\x01' + hash
|
||||
headerData = '\xe9\xbe\xb4\xd9' #magic bits, slighly different from Bitcoin's magic bits.
|
||||
headerData = headerData + 'inv\x00\x00\x00\x00\x00\x00\x00\x00\x00'
|
||||
headerData = headerData + pack('>L',len(payload))
|
||||
'''sha = hashlib.new('sha512')
|
||||
sha.update(payload)
|
||||
sha2 = hashlib.new('sha512')
|
||||
sha2.update(sha.digest())'''
|
||||
headerData = headerData + hashlib.sha512(hashlib.sha512(payload).digest()).digest()[:4]
|
||||
#self.sock.send(headerData + payload)
|
||||
broadcastToSendDataQueues((self.streamNumber, 'send', headerData + payload))
|
||||
print 'broadcasting inv with hash:', repr(hash)
|
||||
|
||||
#We have received an addr message.
|
||||
def recaddr(self):
|
||||
listOfAddressDetailsToBroadcastToPeers = []
|
||||
numberOfAddressesIncluded = 0
|
||||
numberOfAddressesIncluded, lengthOfNumberOfAddresses = decodeVarint(self.data[24:29])
|
||||
|
||||
if verbose >= 1:
|
||||
print 'addr message contains', numberOfAddressesIncluded, 'addresses.'
|
||||
#print 'lengthOfNumberOfAddresses', lengthOfNumberOfAddresses
|
||||
|
||||
if numberOfAddressesIncluded > 1000:
|
||||
return
|
||||
needToWriteKnownNodesToDisk = False
|
||||
for i in range(0,numberOfAddressesIncluded):
|
||||
try:
|
||||
if self.data[40+lengthOfNumberOfAddresses+(34*i):52+lengthOfNumberOfAddresses+(34*i)] != '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFF':
|
||||
printLock.acquire()
|
||||
print 'Skipping IPv6 address.', repr(self.data[40+lengthOfNumberOfAddresses+(34*i):56+lengthOfNumberOfAddresses+(34*i)])
|
||||
printLock.release()
|
||||
continue
|
||||
#print repr(self.data[6+lengthOfNumberOfAddresses+(34*i):18+lengthOfNumberOfAddresses+(34*i)])
|
||||
except Exception, err:
|
||||
if verbose >= 2:
|
||||
printLock.acquire()
|
||||
sys.stderr.write('ERROR TRYING TO UNPACK recaddr (to test for an IPv6 address). Message: %s\n' % str(err))
|
||||
printLock.release()
|
||||
break #giving up on unpacking any more. We should still be connected however.
|
||||
|
||||
try:
|
||||
recaddrStream, = unpack('>I',self.data[28+lengthOfNumberOfAddresses+(34*i):32+lengthOfNumberOfAddresses+(34*i)])
|
||||
except Exception, err:
|
||||
if verbose >= 2:
|
||||
printLock.acquire()
|
||||
sys.stderr.write('ERROR TRYING TO UNPACK recaddr (recaddrStream). Message: %s\n' % str(err))
|
||||
printLock.release()
|
||||
break #giving up on unpacking any more. We should still be connected however.
|
||||
|
||||
try:
|
||||
recaddrServices, = unpack('>Q',self.data[32+lengthOfNumberOfAddresses+(34*i):40+lengthOfNumberOfAddresses+(34*i)])
|
||||
except Exception, err:
|
||||
if verbose >= 2:
|
||||
printLock.acquire()
|
||||
sys.stderr.write('ERROR TRYING TO UNPACK recaddr (recaddrServices). Message: %s\n' % str(err))
|
||||
printLock.release()
|
||||
break #giving up on unpacking any more. We should still be connected however.
|
||||
|
||||
try:
|
||||
recaddrPort, = unpack('>H',self.data[56+lengthOfNumberOfAddresses+(34*i):58+lengthOfNumberOfAddresses+(34*i)])
|
||||
except Exception, err:
|
||||
if verbose >= 2:
|
||||
printLock.acquire()
|
||||
sys.stderr.write('ERROR TRYING TO UNPACK recaddr (recaddrPort). Message: %s\n' % str(err))
|
||||
printLock.release()
|
||||
break #giving up on unpacking any more. We should still be connected however.
|
||||
#print 'Within recaddr(): IP', recaddrIP, ', Port', recaddrPort, ', i', i
|
||||
hostFromAddrMessage = socket.inet_ntoa(self.data[52+lengthOfNumberOfAddresses+(34*i):56+lengthOfNumberOfAddresses+(34*i)])
|
||||
print 'hostFromAddrMessage', hostFromAddrMessage
|
||||
timeSomeoneElseReceivedMessageFromThisNode, = unpack('>I',self.data[24+lengthOfNumberOfAddresses+(34*i):28+lengthOfNumberOfAddresses+(34*i)]) #This is the 'time' value in the received addr message.
|
||||
if hostFromAddrMessage not in knownNodes[recaddrStream]:
|
||||
if len(knownNodes[recaddrStream]) < 20000 and timeSomeoneElseReceivedMessageFromThisNode > (int(time.time())-10800) and timeSomeoneElseReceivedMessageFromThisNode < (int(time.time()) + 10800): #If we have more than 20000 nodes in our list already then just forget about it. Also, make sure that the time that someone else received a message from this node is within three hours from now.
|
||||
knownNodes[recaddrStream][hostFromAddrMessage] = (recaddrPort, timeSomeoneElseReceivedMessageFromThisNode)
|
||||
print 'added new node', hostFromAddrMessage, 'to knownNodes.'
|
||||
needToWriteKnownNodesToDisk = True
|
||||
hostDetails = (timeSomeoneElseReceivedMessageFromThisNode, recaddrStream, recaddrServices, hostFromAddrMessage, recaddrPort)
|
||||
listOfAddressDetailsToBroadcastToPeers.append(hostDetails)
|
||||
else:
|
||||
PORT, timeLastReceivedMessageFromThisNode = knownNodes[recaddrStream][hostFromAddrMessage]#PORT in this case is either the port we used to connect to the remote node, or the port that was specified by someone else in a past addr message.
|
||||
if (timeLastReceivedMessageFromThisNode < timeSomeoneElseReceivedMessageFromThisNode) and (timeSomeoneElseReceivedMessageFromThisNode < int(time.time())):
|
||||
knownNodes[recaddrStream][hostFromAddrMessage] = (PORT, timeSomeoneElseReceivedMessageFromThisNode)
|
||||
if PORT != recaddrPort:
|
||||
sys.stderr.write('Strange occurance: The port specified in an addr message (%s) does not match the port (%s) that this program (or some other peer) used to connect to it (%s). Perhaps they changed their port or are using a strange NAT configuration.\n' % (str(recaddrPort), str(PORT), str(hostFromAddrMessage)))
|
||||
if needToWriteKnownNodesToDisk: #Runs if any nodes were new to us. Also, share those nodes with our peers.
|
||||
output = open(appdata + 'knownnodes.dat', 'wb')
|
||||
pickle.dump(knownNodes, output)
|
||||
output.close()
|
||||
self.broadcastaddr(listOfAddressDetailsToBroadcastToPeers)
|
||||
print 'knownNodes currently:', knownNodes
|
||||
|
||||
#Function runs when we want to broadcast an addr message to all of our peers. Runs when we learn of nodes that we didn't previously know about and want to share them with our peers.
|
||||
def broadcastaddr(self,listOfAddressDetailsToBroadcastToPeers):
|
||||
numberOfAddressesInAddrMessage = len(listOfAddressDetailsToBroadcastToPeers)
|
||||
payload = ''
|
||||
for hostDetails in listOfAddressDetailsToBroadcastToPeers:
|
||||
timeLastReceivedMessageFromThisNode, streamNumber, services, host, port = hostDetails
|
||||
payload += pack('>I',timeLastReceivedMessageFromThisNode)
|
||||
payload += pack('>I',streamNumber)
|
||||
payload += pack('>q',services) #service bit flags offered by this node
|
||||
payload += '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFF' + socket.inet_aton(host)
|
||||
payload += pack('>H',port)#remote port
|
||||
|
||||
payload = encodeVarint(numberOfAddressesInAddrMessage) + payload
|
||||
datatosend = '\xE9\xBE\xB4\xD9addr\x00\x00\x00\x00\x00\x00\x00\x00'
|
||||
datatosend = datatosend + pack('>L',len(payload)) #payload length
|
||||
datatosend = datatosend + hashlib.sha512(hashlib.sha512(payload).digest()).digest()[0:4]
|
||||
datatosend = datatosend + payload
|
||||
|
||||
if verbose >= 2:
|
||||
printLock.acquire()
|
||||
print 'Broadcasting addr with # of entries:', numberOfAddressesInAddrMessage
|
||||
printLock.release()
|
||||
broadcastToSendDataQueues((self.streamNumber, 'send', datatosend))
|
||||
|
||||
#Send a big addr message to our peer
|
||||
def sendaddr(self):
|
||||
addrsInMyStream = {}
|
||||
addrsInChildStreamLeft = {}
|
||||
addrsInChildStreamRight = {}
|
||||
print 'knownNodes', knownNodes
|
||||
|
||||
#We are going to share a maximum number of 1000 addrs with our peer. 500 from this stream, 250 from the left child stream, and 250 from the right child stream.
|
||||
|
||||
if len(knownNodes[self.streamNumber]) > 0:
|
||||
for i in range(500):
|
||||
random.seed()
|
||||
HOST, = random.sample(knownNodes[self.streamNumber], 1)
|
||||
addrsInMyStream[HOST] = knownNodes[self.streamNumber][HOST]
|
||||
if len(knownNodes[self.streamNumber*2]) > 0:
|
||||
for i in range(250):
|
||||
random.seed()
|
||||
HOST, = random.sample(knownNodes[self.streamNumber*2], 1)
|
||||
addrsInChildStreamLeft[HOST] = knownNodes[self.streamNumber*2][HOST]
|
||||
if len(knownNodes[(self.streamNumber*2)+1]) > 0:
|
||||
for i in range(250):
|
||||
random.seed()
|
||||
HOST, = random.sample(knownNodes[(self.streamNumber*2)+1], 1)
|
||||
addrsInChildStreamRight[HOST] = knownNodes[(self.streamNumber*2)+1][HOST]
|
||||
|
||||
numberOfAddressesInAddrMessage = 0
|
||||
payload = ''
|
||||
print 'addrsInMyStream.items()', addrsInMyStream.items()
|
||||
for HOST, value in addrsInMyStream.items():
|
||||
PORT, timeLastReceivedMessageFromThisNode = value
|
||||
if timeLastReceivedMessageFromThisNode > (int(time.time())- maximumAgeOfNodesThatIAdvertiseToOthers): #If it is younger than 3 hours old..
|
||||
numberOfAddressesInAddrMessage += 1
|
||||
payload += pack('>I',timeLastReceivedMessageFromThisNode)
|
||||
payload += pack('>I',self.streamNumber)
|
||||
payload += pack('>q',1) #service bit flags offered by this node
|
||||
payload += '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFF' + socket.inet_aton(HOST)
|
||||
payload += pack('>H',PORT)#remote port
|
||||
for HOST, value in addrsInChildStreamLeft.items():
|
||||
PORT, timeLastReceivedMessageFromThisNode = value
|
||||
if timeLastReceivedMessageFromThisNode > (int(time.time())- maximumAgeOfNodesThatIAdvertiseToOthers): #If it is younger than 3 hours old..
|
||||
numberOfAddressesInAddrMessage += 1
|
||||
payload += pack('>I',timeLastReceivedMessageFromThisNode)
|
||||
payload += pack('>I',self.streamNumber*2)
|
||||
payload += pack('>q',1) #service bit flags offered by this node
|
||||
payload += '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFF' + socket.inet_aton(HOST)
|
||||
payload += pack('>H',PORT)#remote port
|
||||
for HOST, value in addrsInChildStreamRight.items():
|
||||
PORT, timeLastReceivedMessageFromThisNode = value
|
||||
if timeLastReceivedMessageFromThisNode > (int(time.time())- maximumAgeOfNodesThatIAdvertiseToOthers): #If it is younger than 3 hours old..
|
||||
numberOfAddressesInAddrMessage += 1
|
||||
payload += pack('>I',timeLastReceivedMessageFromThisNode)
|
||||
payload += pack('>I',(self.streamNumber*2)+1)
|
||||
payload += pack('>q',1) #service bit flags offered by this node
|
||||
payload += '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFF' + socket.inet_aton(HOST)
|
||||
payload += pack('>H',PORT)#remote port
|
||||
|
||||
payload = encodeVarint(numberOfAddressesInAddrMessage) + payload
|
||||
datatosend = '\xE9\xBE\xB4\xD9addr\x00\x00\x00\x00\x00\x00\x00\x00'
|
||||
datatosend = datatosend + pack('>L',len(payload)) #payload length
|
||||
'''sha = hashlib.new('sha512')
|
||||
sha.update(payload)
|
||||
sha2 = hashlib.new('sha512')
|
||||
sha2.update(sha.digest())'''
|
||||
|
||||
datatosend = datatosend + hashlib.sha512(hashlib.sha512(payload).digest()).digest()[0:4]
|
||||
datatosend = datatosend + payload
|
||||
|
||||
if verbose >= 2:
|
||||
printLock.acquire()
|
||||
print 'Sending addr with # of entries:', numberOfAddressesInAddrMessage
|
||||
printLock.release()
|
||||
self.sock.send(datatosend)
|
||||
|
||||
#We have received a version message
|
||||
def recversion(self):
|
||||
if self.payloadLength < 83:
|
||||
self.data = ''
|
||||
return
|
||||
else:
|
||||
self.remoteProtocolVersion, = unpack('>L',self.data[24:28])
|
||||
#print 'remoteProtocolVersion', self.remoteProtocolVersion
|
||||
self.myExternalIP = socket.inet_ntoa(self.data[64:68])
|
||||
#print 'myExternalIP', self.myExternalIP
|
||||
self.remoteNodeIncomingPort, = unpack('>H',self.data[94:96])
|
||||
#print 'remoteNodeIncomingPort', self.remoteNodeIncomingPort
|
||||
#print 'self.data[96:104]', repr(self.data[96:104])
|
||||
#print 'eightBytesOfRandomDataUsedToDetectConnectionsToSelf', repr(eightBytesOfRandomDataUsedToDetectConnectionsToSelf)
|
||||
useragentLength, lengthOfUseragentVarint = decodeVarint(self.data[104:108])
|
||||
readPosition = 104 + lengthOfUseragentVarint + useragentLength
|
||||
#Note that PyBitmessage curreutnly currentl supports a single stream per connection.
|
||||
numberOfStreamsInVersionMessage, lengthOfNumberOfStreamsInVersionMessage = decodeVarint(self.data[readPosition:])
|
||||
readPosition += lengthOfNumberOfStreamsInVersionMessage
|
||||
self.streamNumber, lengthOfRemoteStreamNumber = decodeVarint(self.data[readPosition:])
|
||||
print 'Remote node stream number:', self.streamNumber
|
||||
#If this was an incoming connection, then the sendData thread doesn't know the stream. We have to set it.
|
||||
if not self.initiatedConnection:
|
||||
broadcastToSendDataQueues((0,'setStreamNumber',(self.HOST,self.streamNumber)))
|
||||
if self.streamNumber != 1:
|
||||
self.sock.close()
|
||||
printLock.acquire()
|
||||
print 'Closed connection to', self.HOST, 'because they are interested in stream', self.steamNumber,'.'
|
||||
printLock.release()
|
||||
self.data = ''
|
||||
return
|
||||
if self.data[96:104] == eightBytesOfRandomDataUsedToDetectConnectionsToSelf:
|
||||
self.sock.close()
|
||||
printLock.acquire()
|
||||
print 'Closing connection to myself: ', self.HOST
|
||||
printLock.release()
|
||||
self.data = ''
|
||||
return
|
||||
|
||||
knownNodes[self.streamNumber][self.HOST] = (self.remoteNodeIncomingPort, int(time.time()))
|
||||
output = open(appdata + 'knownnodes.dat', 'wb')
|
||||
pickle.dump(knownNodes, output)
|
||||
output.close()
|
||||
|
||||
|
||||
|
||||
#I've commented out this code because it should be up to the newer node to decide whether their protocol version is incompatiable with the remote node's version.
|
||||
'''if self.remoteProtocolVersion > 1:
|
||||
print 'The remote node''s protocol version is too new for this program to understand. Disconnecting. It is:', self.remoteProtocolVersion
|
||||
self.sock.close()
|
||||
self.selfInitiatedConnectionList.remove(self)
|
||||
else:'''
|
||||
self.sendverack()
|
||||
if self.initiatedConnection == False:
|
||||
self.sendversion()
|
||||
'''#Now that we have a friendly connection with this peer, we should advertise it to our other peers
|
||||
payload = '\x01'
|
||||
payload += pack('>I',int(time.time()))
|
||||
payload += pack('>I',self.streamNumber)
|
||||
payload += pack('>q',1) #service bit flags offered by this node
|
||||
payload += '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFF' + socket.inet_aton(self.HOST)
|
||||
payload += pack('>H',self.remoteNodeIncomingPort)#remote port
|
||||
datatosend = '\xE9\xBE\xB4\xD9addr\x00\x00\x00\x00\x00\x00\x00\x00'
|
||||
datatosend += pack('>L',len(payload)) #payload length
|
||||
datatosend += hashlib.sha512(hashlib.sha512(payload).digest()).digest()[0:4]
|
||||
datatosend += payload
|
||||
broadcastToSendDataQueues((self.streamNumber, 'send', datatosend))'''
|
||||
|
||||
#Sends a version message
|
||||
def sendversion(self):
|
||||
global softwareVersion
|
||||
payload = ''
|
||||
payload += pack('>L',1) #protocol version.
|
||||
payload += pack('>q',1) #bitflags of the services I offer.
|
||||
payload += pack('>q',int(time.time()))
|
||||
|
||||
payload += pack('>q',1) #boolservices of remote connection. How can I even know this for sure? This is probably ignored by the remote host.
|
||||
payload += '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFF' + socket.inet_aton(self.HOST)
|
||||
payload += pack('>H',self.PORT)#remote IPv6 and port
|
||||
|
||||
payload += pack('>q',1) #bitflags of the services I offer.
|
||||
payload += '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFF' + pack('>L',2130706433) # = 127.0.0.1. This will be ignored by the remote host. The actual remote connected IP will be used.
|
||||
payload += pack('>H',config.getint('bitmessagesettings', 'port'))#my external IPv6 and port
|
||||
|
||||
random.seed()
|
||||
payload += eightBytesOfRandomDataUsedToDetectConnectionsToSelf
|
||||
userAgent = '/PyBitmessage:' + softwareVersion + '/' #Length of userAgent must be less than 253.
|
||||
payload += pack('>B',len(userAgent)) #user agent string length. If the user agent is more than 252 bytes long, this code isn't going to work.
|
||||
payload += userAgent
|
||||
payload += encodeVarint(1) #The number of streams about which I care. PyBitmessage currently only supports 1.
|
||||
payload += encodeVarint(self.streamNumber)
|
||||
|
||||
datatosend = '\xe9\xbe\xb4\xd9' #magic bits, slighly different from Bitcoin's magic bits.
|
||||
datatosend = datatosend + 'version\x00\x00\x00\x00\x00' #version command
|
||||
datatosend = datatosend + pack('>L',len(payload)) #payload length
|
||||
datatosend = datatosend + hashlib.sha512(hashlib.sha512(payload).digest()).digest()[0:4]
|
||||
datatosend = datatosend + payload
|
||||
|
||||
printLock.acquire()
|
||||
print 'Sending version packet: ', repr(datatosend)
|
||||
printLock.release()
|
||||
self.sock.send(datatosend)
|
||||
#self.versionSent = 1
|
||||
|
||||
#Sends a verack message
|
||||
def sendverack(self):
|
||||
print 'Sending verack'
|
||||
self.sock.sendall('\xE9\xBE\xB4\xD9\x76\x65\x72\x61\x63\x6B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x82\x6D\xf0\x68')
|
||||
self.verackSent = True
|
||||
if self.verackReceived == True:
|
||||
self.connectionFullyEstablished()
|
||||
|
||||
#Every connection to a peer has a sendDataThread (and also a receiveDataThread).
|
||||
class sendDataThread(QThread):
|
||||
def __init__(self, parent = None):
|
||||
QThread.__init__(self, parent)
|
||||
self.mailbox = Queue.Queue()
|
||||
sendDataQueues.append(self.mailbox)
|
||||
self.data = ''
|
||||
|
||||
def setup(self,sock,HOST,PORT,streamNumber):
|
||||
self.sock = sock
|
||||
self.HOST = HOST
|
||||
self.PORT = PORT
|
||||
self.streamNumber = streamNumber
|
||||
self.lastTimeISentData = int(time.time()) #If this value increases beyond five minutes ago, we'll send a pong message to keep the connection alive.
|
||||
printLock.acquire()
|
||||
print 'The streamNumber of this sendDataThread at setup() is', self.streamNumber, self
|
||||
printLock.release()
|
||||
|
||||
def sendVersionMessage(self):
|
||||
|
||||
#Note that there is another copy of this version-sending code in the receiveData class which would need to be changed if you make changes here.
|
||||
global softwareVersion
|
||||
payload = ''
|
||||
payload += pack('>L',1) #protocol version.
|
||||
payload += pack('>q',1) #bitflags of the services I offer.
|
||||
payload += pack('>q',int(time.time()))
|
||||
|
||||
payload += pack('>q',1) #boolservices of remote connection. How can I even know this for sure? This is probably ignored by the remote host.
|
||||
payload += '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFF' + socket.inet_aton(self.HOST)
|
||||
payload += pack('>H',self.PORT)#remote IPv6 and port
|
||||
|
||||
payload += pack('>q',1) #bitflags of the services I offer.
|
||||
payload += '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFF' + pack('>L',2130706433) # = 127.0.0.1. This will be ignored by the remote host. The actual remote connected IP will be used.
|
||||
payload += pack('>H',config.getint('bitmessagesettings', 'port'))#my external IPv6 and port
|
||||
|
||||
random.seed()
|
||||
payload += eightBytesOfRandomDataUsedToDetectConnectionsToSelf
|
||||
userAgent = '/PyBitmessage:' + softwareVersion + '/' #Length of userAgent must be less than 253.
|
||||
payload += pack('>B',len(userAgent)) #user agent string length. If the user agent is more than 252 bytes long, this code isn't going to work.
|
||||
payload += userAgent
|
||||
payload += encodeVarint(1) #The number of streams about which I care. PyBitmessage currently only supports 1 per connection.
|
||||
payload += encodeVarint(self.streamNumber)
|
||||
|
||||
datatosend = '\xe9\xbe\xb4\xd9' #magic bits, slighly different from Bitcoin's magic bits.
|
||||
datatosend = datatosend + 'version\x00\x00\x00\x00\x00' #version command
|
||||
datatosend = datatosend + pack('>L',len(payload)) #payload length
|
||||
datatosend = datatosend + hashlib.sha512(hashlib.sha512(payload).digest()).digest()[0:4]
|
||||
datatosend = datatosend + payload
|
||||
|
||||
printLock.acquire()
|
||||
print 'Sending version packet: ', repr(datatosend)
|
||||
printLock.release()
|
||||
self.sock.send(datatosend)
|
||||
self.versionSent = 1
|
||||
|
||||
|
||||
def run(self):
|
||||
message = ''
|
||||
while True:
|
||||
deststream,command,data = self.mailbox.get()
|
||||
printLock.acquire()
|
||||
print 'within a sendDataThread, destream:', deststream,', Command:', command, self
|
||||
printLock.release()
|
||||
|
||||
if deststream == self.streamNumber or deststream == 0:
|
||||
if command == 'shutdown':
|
||||
if data == self.HOST or data == 'all':
|
||||
printLock.acquire()
|
||||
print 'sendDataThread thread (associated with', self.HOST,')', self, 'shutting down now.'
|
||||
self.sock.close()
|
||||
sendDataQueues.remove(self.mailbox)
|
||||
print 'len of sendDataQueues', len(sendDataQueues)
|
||||
printLock.release()
|
||||
break
|
||||
elif command == 'setStreamNumber':
|
||||
hostInMessage, specifiedStreamNumber = data
|
||||
if hostInMessage == self.HOST:
|
||||
printLock.acquire()
|
||||
print 'setting the stream number in the sendData thread to', specifiedStreamNumber, self
|
||||
printLock.release()
|
||||
self.streamNumber = specifiedStreamNumber
|
||||
elif command == 'send':
|
||||
try:
|
||||
#To prevent some network analysis, 'leak' the data out to our peer after waiting a sort random amount of time.
|
||||
random.seed()
|
||||
#time.sleep(random.randrange(0, 5)) todo: uncomment this line.
|
||||
self.sock.sendall(data)
|
||||
self.lastTimeISentData = int(time.time())
|
||||
except:
|
||||
print 'self.sock.sendall failed'
|
||||
self.sock.close()
|
||||
sendDataQueues.remove(self.mailbox)
|
||||
print 'sendDataThread thread', self, 'ending now'
|
||||
break
|
||||
elif command == 'pong':
|
||||
if self.lastTimeISentData < (int(time.time()) - 298):
|
||||
#Send out a pong message to keep the connection alive.
|
||||
print 'Sending pong to', self.HOST, 'to keep connection alive.'
|
||||
try:
|
||||
self.sock.sendall('\xE9\xBE\xB4\xD9\x70\x6F\x6E\x67\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x82\x6D\xf0\x68')
|
||||
self.lastTimeISentData = int(time.time())
|
||||
except:
|
||||
print 'self.sock.send pong failed'
|
||||
self.sock.close()
|
||||
sendDataQueues.remove(self.mailbox)
|
||||
print 'sendDataThread thread', self, 'ending now'
|
||||
break
|
||||
|
||||
#Wen you want to command a sendDataThread to do something, like shutdown or send some data, this function puts your data into the queues for each of the sendDataThreads. The sendDataThreads are responsible for putting their queue into (and out of) the sendDataQueues list.
|
||||
def broadcastToSendDataQueues(data):
|
||||
#print 'running broadcastToSendDataQueues'
|
||||
for q in sendDataQueues:
|
||||
q.put((data))
|
||||
|
||||
def flushInventory():
|
||||
#Note that the singleCleanerThread clears out the inventory dictionary from time to time, although it only clears things that have been in the dictionary for a long time. This clears the inventory dictionary Now.
|
||||
sqlLock.acquire()
|
||||
for hash, storedValue in inventory.items():
|
||||
objectType, streamNumber, payload, receivedTime = storedValue
|
||||
t = (hash,objectType,streamNumber,payload,receivedTime)
|
||||
sqlSubmitQueue.put('''INSERT INTO inventory VALUES (?,?,?,?,?)''')
|
||||
sqlSubmitQueue.put(t)
|
||||
sqlReturnQueue.get()
|
||||
del inventory[hash]
|
||||
sqlLock.release()
|
||||
|
||||
def isInSqlInventory(hash):
|
||||
t = (hash,)
|
||||
sqlLock.acquire()
|
||||
sqlSubmitQueue.put('''select hash from inventory where hash=?''')
|
||||
sqlSubmitQueue.put(t)
|
||||
queryreturn = sqlReturnQueue.get()
|
||||
sqlLock.release()
|
||||
if queryreturn == []:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
def convertIntToString(n):
|
||||
a = __builtins__.hex(n)
|
||||
if a[-1:] == 'L':
|
||||
a = a[:-1]
|
||||
if (len(a) % 2) == 0:
|
||||
return a[2:].decode('hex')
|
||||
else:
|
||||
return ('0'+a[2:]).decode('hex')
|
||||
|
||||
def convertStringToInt(s):
|
||||
return int(s.encode('hex'), 16)
|
||||
|
||||
#This thread exists because SQLITE3 is so un-threadsafe that we must submit queries to it and it puts results back in a different queue. They won't let us just use locks.
|
||||
class sqlThread(QThread):
|
||||
def __init__(self, parent = None):
|
||||
QThread.__init__(self, parent)
|
||||
|
||||
def run(self):
|
||||
self.conn = sqlite3.connect(appdata + 'messages.dat' )
|
||||
self.conn.text_factory = str
|
||||
self.cur = self.conn.cursor()
|
||||
try:
|
||||
self.cur.execute( '''CREATE TABLE inbox (msgid blob, toaddress text, fromaddress text, subject text, received text, message text, folder text, UNIQUE(msgid) ON CONFLICT REPLACE)''' )
|
||||
self.cur.execute( '''CREATE TABLE sent (msgid blob, toaddress text, toripe blob, fromaddress text, subject text, message text, ackdata blob, lastactiontime integer, status text, pubkeyretrynumber integer, msgretrynumber integer, folder text)''' )
|
||||
self.cur.execute( '''CREATE TABLE subscriptions (label text, address text, enabled bool)''' )
|
||||
self.cur.execute( '''CREATE TABLE addressbook (label text, address text)''' )
|
||||
self.cur.execute( '''CREATE TABLE blacklist (label text, address text, enabled bool)''' )
|
||||
self.cur.execute( '''CREATE TABLE whitelist (label text, address text, enabled bool)''' )
|
||||
self.cur.execute( '''CREATE TABLE pubkeys (hash blob, havecorrectnonce bool, transmitdata blob, time blob, UNIQUE(hash, havecorrectnonce, transmitdata) ON CONFLICT REPLACE)''' )
|
||||
self.cur.execute( '''CREATE TABLE inventory (hash blob, objecttype text, streamnumber int, payload blob, receivedtime integer, UNIQUE(hash) ON CONFLICT REPLACE)''' )
|
||||
self.cur.execute( '''CREATE TABLE knownnodes (timelastseen int, stream int, services blob, host blob, port blob, UNIQUE(host) ON CONFLICT REPLACE)''' ) #This table isn't used in the program yet but I have a feeling that we'll need it.
|
||||
|
||||
self.conn.commit()
|
||||
print 'Created messages database file'
|
||||
except Exception, err:
|
||||
if str(err) == 'table inbox already exists':
|
||||
print 'Database file already exists.'
|
||||
else:
|
||||
sys.stderr.write('ERROR trying to create database file (message.dat). Error message: %s\n' % str(err))
|
||||
sys.exit()
|
||||
|
||||
try:
|
||||
testpayload = '\x00\x00'
|
||||
t = ('1234','True',testpayload,'12345678')
|
||||
self.cur.execute( '''INSERT INTO pubkeys VALUES(?,?,?,?)''',t)
|
||||
self.conn.commit()
|
||||
self.cur.execute('''SELECT transmitdata FROM pubkeys WHERE hash='1234' ''')
|
||||
queryreturn = self.cur.fetchall()
|
||||
for row in queryreturn:
|
||||
transmitdata, = row
|
||||
self.cur.execute('''DELETE FROM pubkeys WHERE hash='1234' ''')
|
||||
self.conn.commit()
|
||||
if transmitdata == '':
|
||||
sys.stderr.write('Problem: The version of SQLite you have cannot store Null values. Please download and install the latest revision of your version of Python (for example, the latest Python 2.7 revision) and try again. Exiting.\n')
|
||||
sys.exit()
|
||||
except Exception, err:
|
||||
print err
|
||||
|
||||
while True:
|
||||
item = sqlSubmitQueue.get()
|
||||
parameters = sqlSubmitQueue.get()
|
||||
#print 'item', item
|
||||
#print 'parameters', parameters
|
||||
self.cur.execute(item, parameters)
|
||||
sqlReturnQueue.put(self.cur.fetchall())
|
||||
sqlSubmitQueue.task_done()
|
||||
self.conn.commit()
|
||||
|
||||
|
||||
'''The singleCleaner class is a timer-driven thread that cleans data structures to free memory, resends messages when a remote node doesn't respond, and sends pong messages to keep connections alive if the network isn't busy.
|
||||
It cleans these data structures in memory:
|
||||
inventory (moves data to the on-disk sql database)
|
||||
|
||||
It cleans these tables on the disk:
|
||||
inventory (clears data more than 2 days and 12 hours old)
|
||||
pubkeys (clears data older than the date specified in the table. This is because we won't want to hold pubkeys that show up randomly as long as those that we have actually have used.)
|
||||
|
||||
It resends messages when there has been no response:
|
||||
resends getpubkey messages in two days (then 4 days, then 8 days, etc...)
|
||||
resends msg messages in two days (then 4 days, then 8 days, etc...)
|
||||
|
||||
|
||||
'''
|
||||
class singleCleaner(QThread):
|
||||
def __init__(self, parent = None):
|
||||
QThread.__init__(self, parent)
|
||||
|
||||
def run(self):
|
||||
timeWeLastClearedInventoryAndPubkeysTables = 0
|
||||
|
||||
while True:
|
||||
time.sleep(300)
|
||||
sqlLock.acquire()
|
||||
for hash, storedValue in inventory.items():
|
||||
objectType, streamNumber, payload, receivedTime = storedValue
|
||||
if int(time.time())- 3600 > receivedTime:
|
||||
t = (hash,objectType,streamNumber,payload,receivedTime)
|
||||
sqlSubmitQueue.put('''INSERT INTO inventory VALUES (?,?,?,?,?)''')
|
||||
sqlSubmitQueue.put(t)
|
||||
sqlReturnQueue.get()
|
||||
del inventory[hash]
|
||||
sqlLock.release()
|
||||
broadcastToSendDataQueues((0, 'pong', 'no data')) #commands the sendData threads to send out a pong message if they haven't sent anything else in the last five minutes. The socket timeout-time is 10 minutes.
|
||||
if timeWeLastClearedInventoryAndPubkeysTables < int(time.time()) - 7380:
|
||||
timeWeLastClearedInventoryAndPubkeysTables = int(time.time())
|
||||
#inventory (moves data from the inventory data structure to the on-disk sql database)
|
||||
sqlLock.acquire()
|
||||
#inventory (clears data more than 2 days and 12 hours old)
|
||||
t = (int(time.time())-lengthOfTimeToLeaveObjectsInInventory,)
|
||||
sqlSubmitQueue.put('''DELETE FROM inventory WHERE receivedtime<?''')
|
||||
sqlSubmitQueue.put(t)
|
||||
sqlReturnQueue.get()
|
||||
|
||||
#pubkeys (clears data older than the date specified in the table. This is because we won't want to hold pubkeys that show up randomly as long as those that we have actually have used (unless someone can come up with a decent attack based on this behavior.))
|
||||
t = (int(time.time()),)
|
||||
sqlSubmitQueue.put('''DELETE FROM pubkeys WHERE time<?''')
|
||||
sqlSubmitQueue.put(t)
|
||||
sqlReturnQueue.get()
|
||||
|
||||
t = ()
|
||||
sqlSubmitQueue.put('''select toaddress, toripe, fromaddress, subject, message, ackdata, lastactiontime, status, pubkeyretrynumber, msgretrynumber FROM sent WHERE (status='findingpubkey' OR status='sentmessage') ''')
|
||||
sqlSubmitQueue.put(t)
|
||||
queryreturn = sqlReturnQueue.get()
|
||||
for row in queryreturn:
|
||||
toaddress, toripe, fromaddress, subject, message, ackdata, lastactiontime, status, pubkeyretrynumber, msgretrynumber = row
|
||||
if status == 'findingpubkey':
|
||||
if int(time.time()) - lastactiontime > (maximumAgeOfAnObjectThatIAmWillingToAccept * (2 ** (pubkeyretrynumber))):
|
||||
print 'It has been a long time and we haven\'t heard a response to our getpubkey request. Sending again.'
|
||||
try:
|
||||
del neededPubkeys[toripe]
|
||||
except:
|
||||
pass
|
||||
workerQueue.put(('sendmessage',toaddress))
|
||||
t = (int(time.time()),pubkeyretrynumber+1,toripe)
|
||||
sqlSubmitQueue.put('''UPDATE sent SET lastactiontime=?, pubkeyretrynumber=? WHERE toripe=?''')
|
||||
sqlSubmitQueue.put(t)
|
||||
sqlReturnQueue.get()
|
||||
#self.emit(SIGNAL("updateSentItemStatusByHash(PyQt_PyObject,PyQt_PyObject)"),toripe,'Public key requested again. ' + strftime(config.get('bitmessagesettings', 'timeformat'),localtime(int(time.time()))))
|
||||
else:# status == sentmessage
|
||||
if int(time.time()) - lastactiontime > (maximumAgeOfAnObjectThatIAmWillingToAccept * (2 ** (msgretrynumber))):
|
||||
print 'It has been a long time and we haven\'t heard an acknowledgement to our msg. Sending again.'
|
||||
t = (int(time.time()),msgretrynumber+1,'findingpubkey',ackdata)
|
||||
sqlSubmitQueue.put('''UPDATE sent SET lastactiontime=?, msgretrynumber=?, status=? WHERE ackdata=?''')
|
||||
sqlSubmitQueue.put(t)
|
||||
sqlReturnQueue.get()
|
||||
#self.emit(SIGNAL("updateSentItemStatusByAckdata(PyQt_PyObject,PyQt_PyObject)"),ackdata,'Message sent again because the acknowledgement was never received. ' + strftime(config.get('bitmessagesettings', 'timeformat'),localtime(int(time.time()))))
|
||||
workerQueue.put(('sendmessage',toaddress))
|
||||
sqlLock.release()
|
||||
|
||||
#This thread, of which there is only one, does the heavy lifting: calculating POWs.
|
||||
class singleWorker(QThread):
|
||||
def __init__(self, parent = None):
|
||||
QThread.__init__(self, parent)
|
||||
|
||||
def run(self):
|
||||
sqlLock.acquire()
|
||||
sqlSubmitQueue.put('SELECT toripe FROM sent WHERE status=?')
|
||||
sqlSubmitQueue.put(('findingpubkey',))
|
||||
queryreturn = sqlReturnQueue.get()
|
||||
sqlLock.release()
|
||||
for row in queryreturn:
|
||||
toripe, = row
|
||||
neededPubkeys[toripe] = 0
|
||||
|
||||
self.sendBroadcast() #just in case there are any proof of work tasks for Broadcasts that have yet to be sent.
|
||||
|
||||
#Now let us see if there are any proofs of work for msg messages that we have yet to complete..
|
||||
sqlLock.acquire()
|
||||
t = ('doingpow',)
|
||||
sqlSubmitQueue.put('SELECT toripe FROM sent WHERE status=?')
|
||||
sqlSubmitQueue.put(t)
|
||||
queryreturn = sqlReturnQueue.get()
|
||||
sqlLock.release()
|
||||
for row in queryreturn:
|
||||
toripe, = row
|
||||
self.sendMsg(toripe)
|
||||
|
||||
while True:
|
||||
command, data = workerQueue.get()
|
||||
#statusbar = 'The singleWorker thread is working on work.'
|
||||
#self.emit(SIGNAL("updateStatusBar(PyQt_PyObject)"),statusbar)
|
||||
if command == 'sendmessage':
|
||||
toAddress = data
|
||||
toStatus,toAddressVersionNumber,toStreamNumber,toRipe = decodeAddress(toAddress)
|
||||
#print 'message type', type(message)
|
||||
#print repr(message.toUtf8())
|
||||
#print str(message.toUtf8())
|
||||
sqlLock.acquire()
|
||||
sqlSubmitQueue.put('SELECT * FROM pubkeys WHERE hash=?')
|
||||
sqlSubmitQueue.put((toRipe,))
|
||||
queryreturn = sqlReturnQueue.get()
|
||||
sqlLock.release()
|
||||
#print 'queryreturn', queryreturn
|
||||
if queryreturn == []:
|
||||
#We'll need to request the pub key because we don't have it.
|
||||
if not toRipe in neededPubkeys:
|
||||
neededPubkeys[toRipe] = 0
|
||||
print 'requesting pubkey:', repr(toRipe)
|
||||
self.requestPubKey(toAddressVersionNumber,toStreamNumber,toRipe)
|
||||
else:
|
||||
print 'We have already requested this pubkey (the ripe hash is in neededPubkeys). We will re-request again soon.'
|
||||
self.emit(SIGNAL("updateSentItemStatusByHash(PyQt_PyObject,PyQt_PyObject)"),toRipe,'Public key was requested earlier. Receiver must be offline. Will retry.')
|
||||
else:
|
||||
print 'We already have the necessary public key.'
|
||||
self.sendMsg(toRipe)
|
||||
elif command == 'sendbroadcast':
|
||||
print 'Within WorkerThread, processing sendbroadcast command.'
|
||||
fromAddress,subject,message = data
|
||||
self.sendBroadcast()
|
||||
|
||||
elif command == 'newpubkey':
|
||||
toAddressVersion,toStreamNumber,toRipe = data
|
||||
if toRipe in neededPubkeys:
|
||||
print 'We have been awaiting the arrival of this pubkey.'
|
||||
del neededPubkeys[toRipe]
|
||||
self.sendMsg(toRipe)
|
||||
else:
|
||||
print 'We don\'t need this pub key. We didn\'t ask for it. Pubkey hash:', repr(toRipe)
|
||||
|
||||
workerQueue.task_done()
|
||||
|
||||
def sendBroadcast(self):
|
||||
sqlLock.acquire()
|
||||
t = ('broadcastpending',)
|
||||
sqlSubmitQueue.put('SELECT fromaddress, subject, message, ackdata FROM sent WHERE status=?')
|
||||
sqlSubmitQueue.put(t)
|
||||
queryreturn = sqlReturnQueue.get()
|
||||
sqlLock.release()
|
||||
for row in queryreturn:
|
||||
#print 'within sendMsg, row is:', row
|
||||
#msgid, toaddress, toripe, fromaddress, subject, message, ackdata, lastactiontime, status = row
|
||||
fromaddress, subject, body, ackdata = row
|
||||
messageToTransmit = '\x02'
|
||||
messageToTransmit += encodeVarint(len('Subject:' + subject + '\n' + 'Body:' + body)) #Type 2 is simple UTF-8 message encoding.
|
||||
messageToTransmit += 'Subject:' + subject + '\n' + 'Body:' + body
|
||||
|
||||
#We need the all the integers for our private key in order to sign our message, and we need our public key to send with the message.
|
||||
n = config.getint(fromaddress, 'n')
|
||||
e = config.getint(fromaddress, 'e')
|
||||
d = config.getint(fromaddress, 'd')
|
||||
p = config.getint(fromaddress, 'p')
|
||||
q = config.getint(fromaddress, 'q')
|
||||
nString = convertIntToString(n)
|
||||
eString = convertIntToString(e)
|
||||
myPubkey = rsa.PublicKey(n,e)
|
||||
myPrivatekey = rsa.PrivateKey(n,e,d,p,q)
|
||||
status,addressVersionNumber,streamNumber,ripe = decodeAddress(fromaddress)
|
||||
|
||||
#The payload of the broadcast message starts with a POW, but that will be added later.
|
||||
payload = pack('>I',(int(time.time())))
|
||||
payload += encodeVarint(1) #broadcast version
|
||||
payload += encodeVarint(addressVersionNumber)
|
||||
payload += encodeVarint(streamNumber)
|
||||
payload += ripe
|
||||
payload += encodeVarint(len(nString))
|
||||
payload += nString
|
||||
payload += encodeVarint(len(eString))
|
||||
payload += eString
|
||||
payload += messageToTransmit
|
||||
signature = rsa.sign(messageToTransmit,myPrivatekey,'SHA-512')
|
||||
print 'signature', repr(signature)
|
||||
payload += signature
|
||||
|
||||
print 'nString', repr(nString)
|
||||
print 'eString', repr(eString)
|
||||
|
||||
nonce = 0
|
||||
trialValue = 99999999999999999
|
||||
target = 2**64 / ((len(payload)+payloadLengthExtraBytes+8) * averageProofOfWorkNonceTrialsPerByte)
|
||||
print '(For broadcast message) Doing proof of work...'
|
||||
while trialValue > target:
|
||||
nonce += 1
|
||||
trialValue, = unpack('>Q',hashlib.sha512(hashlib.sha512(pack('>Q',nonce) + payload).digest()).digest()[4:12])
|
||||
print '(For broadcast message) Found proof of work', trialValue, 'Nonce:', nonce
|
||||
|
||||
payload = pack('>Q',nonce) + payload
|
||||
|
||||
inventoryHash = calculateInventoryHash(payload)
|
||||
objectType = 'broadcast'
|
||||
inventory[inventoryHash] = (objectType, streamNumber, payload, int(time.time()))
|
||||
print 'sending inv (within sendBroadcast function)'
|
||||
payload = '\x01' + inventoryHash
|
||||
headerData = '\xe9\xbe\xb4\xd9' #magic bits, slighly different from Bitcoin's magic bits.
|
||||
headerData = headerData + 'inv\x00\x00\x00\x00\x00\x00\x00\x00\x00'
|
||||
headerData = headerData + pack('>L',len(payload)) #payload length. Note that we add an extra 8 for the nonce.
|
||||
headerData = headerData + hashlib.sha512(hashlib.sha512(payload).digest()).digest()[:4]
|
||||
broadcastToSendDataQueues((streamNumber, 'send', headerData + payload))
|
||||
|
||||
self.emit(SIGNAL("updateSentItemStatusByAckdata(PyQt_PyObject,PyQt_PyObject)"),ackdata,'Broadcast sent at '+strftime(config.get('bitmessagesettings', 'timeformat'),localtime(int(time.time()))))
|
||||
|
||||
#Update the status of the message in the 'sent' table to have a 'broadcastsent' status
|
||||
sqlLock.acquire()
|
||||
t = ('broadcastsent',int(time.time()),fromaddress, subject, body,'broadcastpending')
|
||||
sqlSubmitQueue.put('UPDATE sent SET status=?, lastactiontime=? WHERE fromaddress=? AND subject=? AND message=? AND status=?')
|
||||
sqlSubmitQueue.put(t)
|
||||
queryreturn = sqlReturnQueue.get()
|
||||
sqlLock.release()
|
||||
|
||||
def sendMsg(self,toRipe):
|
||||
sqlLock.acquire()
|
||||
t = ('doingpow','findingpubkey',toRipe)
|
||||
sqlSubmitQueue.put('UPDATE sent SET status=? WHERE status=? AND toripe=?')
|
||||
sqlSubmitQueue.put(t)
|
||||
queryreturn = sqlReturnQueue.get()
|
||||
|
||||
t = ('doingpow',toRipe)
|
||||
sqlSubmitQueue.put('SELECT toaddress, fromaddress, subject, message, ackdata FROM sent WHERE status=? AND toripe=?')
|
||||
sqlSubmitQueue.put(t)
|
||||
queryreturn = sqlReturnQueue.get()
|
||||
sqlLock.release()
|
||||
for row in queryreturn:
|
||||
toaddress, fromaddress, subject, message, ackdata = row
|
||||
status,addressVersionNumber,toStreamNumber,hash = decodeAddress(toaddress)
|
||||
#if hash == toRipe:
|
||||
self.emit(SIGNAL("updateSentItemStatusByAckdata(PyQt_PyObject,PyQt_PyObject)"),ackdata,'Doing work necessary to send the message.')
|
||||
printLock.acquire()
|
||||
print 'Found the necessary message that needs to be sent with this pubkey.'
|
||||
print 'First 150 characters of message:', message[:150]
|
||||
printLock.release()
|
||||
payload = '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' #this run of nulls allows the true message receiver to identify his message
|
||||
payload += '\x01' #Message version.
|
||||
payload += '\x00\x00\x00\x01'
|
||||
fromStatus,fromAddressVersionNumber,fromStreamNumber,fromHash = decodeAddress(fromaddress)
|
||||
payload += encodeVarint(fromAddressVersionNumber)
|
||||
payload += encodeVarint(fromStreamNumber)
|
||||
|
||||
sendersN = convertIntToString(config.getint(fromaddress, 'n'))
|
||||
payload += encodeVarint(len(sendersN))
|
||||
payload += sendersN
|
||||
|
||||
sendersE = convertIntToString(config.getint(fromaddress, 'e'))
|
||||
payload += encodeVarint(len(sendersE))
|
||||
payload += sendersE
|
||||
|
||||
payload += '\x02' #Type 2 is simple UTF-8 message encoding.
|
||||
messageToTransmit = 'Subject:' + subject + '\n' + 'Body:' + message
|
||||
payload += encodeVarint(len(messageToTransmit))
|
||||
payload += messageToTransmit
|
||||
|
||||
#Later, if anyone impliments clients that don't send the ack_data, then we should probably check here to make sure that the receiver will make use of this ack_data and not attach it if not.
|
||||
fullAckPayload = self.generateFullAckMessage(ackdata,fromStreamNumber)
|
||||
payload += encodeVarint(len(fullAckPayload))
|
||||
payload += fullAckPayload
|
||||
sendersPrivKey = rsa.PrivateKey(config.getint(fromaddress, 'n'),config.getint(fromaddress, 'e'),config.getint(fromaddress, 'd'),config.getint(fromaddress, 'p'),config.getint(fromaddress, 'q'))
|
||||
|
||||
payload += rsa.sign(payload,sendersPrivKey,'SHA-512')
|
||||
|
||||
sqlLock.acquire()
|
||||
sqlSubmitQueue.put('SELECT * FROM pubkeys WHERE hash=?')
|
||||
sqlSubmitQueue.put((toRipe,))
|
||||
queryreturn = sqlReturnQueue.get()
|
||||
sqlLock.release()
|
||||
|
||||
for row in queryreturn:
|
||||
hash, havecorrectnonce, pubkeyPayload, timeLastRequested = row
|
||||
|
||||
readPosition = 8 #to bypass the nonce
|
||||
bitfieldBehaviors = pubkeyPayload[8:12]
|
||||
readPosition += 4 #to bypass the bitfield of behaviors
|
||||
addressVersion, addressVersionLength = decodeVarint(pubkeyPayload[readPosition:readPosition+10])
|
||||
readPosition += addressVersionLength
|
||||
streamNumber, streamNumberLength = decodeVarint(pubkeyPayload[readPosition:readPosition+10])
|
||||
readPosition += streamNumberLength
|
||||
nLength, nLengthLength = decodeVarint(pubkeyPayload[readPosition:readPosition+10])
|
||||
readPosition += nLengthLength
|
||||
n = convertStringToInt(pubkeyPayload[readPosition:readPosition+nLength])
|
||||
readPosition += nLength
|
||||
eLength, eLengthLength = decodeVarint(pubkeyPayload[readPosition:readPosition+10])
|
||||
readPosition += eLengthLength
|
||||
e = convertStringToInt(pubkeyPayload[readPosition:readPosition+eLength])
|
||||
receiversPubkey = rsa.PublicKey(n,e)
|
||||
|
||||
infile = cStringIO.StringIO(payload)
|
||||
outfile = cStringIO.StringIO()
|
||||
#print 'Encrypting using public key:', receiversPubkey
|
||||
encrypt_bigfile(infile,outfile,receiversPubkey)
|
||||
|
||||
encrypted = outfile.getvalue()
|
||||
infile.close()
|
||||
outfile.close()
|
||||
|
||||
nonce = 0
|
||||
trialValue = 99999999999999999
|
||||
embeddedTime = pack('>I',(int(time.time())))
|
||||
encodedStreamNumber = encodeVarint(toStreamNumber)
|
||||
#We are now dropping the unencrypted data in payload since it has already been encrypted and replacing it with the encrypted payload that we will send out.
|
||||
payload = embeddedTime + encodedStreamNumber + encrypted
|
||||
target = 2**64 / ((len(payload)+payloadLengthExtraBytes+8) * averageProofOfWorkNonceTrialsPerByte)
|
||||
print '(For msg message) Doing proof of work...'
|
||||
print 'target', target
|
||||
while trialValue > target:
|
||||
nonce += 1
|
||||
trialValue, = unpack('>Q',hashlib.sha512(hashlib.sha512(pack('>Q',nonce) + payload).digest()).digest()[4:12])
|
||||
print '(For msg message) Found proof of work', trialValue, 'Nonce:', nonce
|
||||
|
||||
payload = pack('>Q',nonce) + payload
|
||||
|
||||
inventoryHash = calculateInventoryHash(payload)
|
||||
objectType = 'msg'
|
||||
inventory[inventoryHash] = (objectType, toStreamNumber, payload, int(time.time()))
|
||||
self.emit(SIGNAL("updateSentItemStatusByAckdata(PyQt_PyObject,PyQt_PyObject)"),ackdata,'Message sent. Waiting on acknowledgement. Sent on ' + strftime(config.get('bitmessagesettings', 'timeformat'),localtime(int(time.time()))))
|
||||
print 'sending inv (within sendmsg function)'
|
||||
payload = '\x01' + inventoryHash
|
||||
headerData = '\xe9\xbe\xb4\xd9' #magic bits, slighly different from Bitcoin's magic bits.
|
||||
headerData = headerData + 'inv\x00\x00\x00\x00\x00\x00\x00\x00\x00'
|
||||
headerData = headerData + pack('>L',len(payload)) #payload length. Note that we add an extra 8 for the nonce.
|
||||
headerData = headerData + hashlib.sha512(hashlib.sha512(payload).digest()).digest()[:4]
|
||||
broadcastToSendDataQueues((toStreamNumber, 'send', headerData + payload))
|
||||
|
||||
#Update the status of the message in the 'sent' table to have a 'sent' status
|
||||
sqlLock.acquire()
|
||||
t = ('sentmessage',toaddress, fromaddress, subject, message,'doingpow')
|
||||
sqlSubmitQueue.put('UPDATE sent SET status=? WHERE toaddress=? AND fromaddress=? AND subject=? AND message=? AND status=?')
|
||||
sqlSubmitQueue.put(t)
|
||||
queryreturn = sqlReturnQueue.get()
|
||||
|
||||
#Update the time in the pubkey sql database so that we'll hold the foreign pubkey for quite a while longer
|
||||
t = (int(time.time())+31449600,toRipe) #Hold the pubkey for an entire year from today
|
||||
sqlSubmitQueue.put('UPDATE pubkeys SET time=? WHERE hash=?')
|
||||
sqlSubmitQueue.put(t)
|
||||
queryreturn = sqlReturnQueue.get()
|
||||
|
||||
sqlLock.release()
|
||||
|
||||
|
||||
def requestPubKey(self,addressVersionNumber,streamNumber,ripe):
|
||||
payload = pack('>I',int(time.time()))
|
||||
payload += encodeVarint(addressVersionNumber)
|
||||
payload += encodeVarint(streamNumber)
|
||||
payload += ripe
|
||||
nonce = 0
|
||||
trialValue = 99999999999999999
|
||||
#print 'trial value', trialValue
|
||||
statusbar = 'Doing the computations necessary to request the recipient''s public key. (Doing the proof-of-work.)'
|
||||
self.emit(SIGNAL("updateStatusBar(PyQt_PyObject)"),statusbar)
|
||||
self.emit(SIGNAL("updateSentItemStatusByHash(PyQt_PyObject,PyQt_PyObject)"),ripe,'Doing work necessary to request public key.')
|
||||
print 'Doing proof-of-work necessary to send getpubkey message.'
|
||||
target = 2**64 / ((len(payload)+payloadLengthExtraBytes+8) * averageProofOfWorkNonceTrialsPerByte)
|
||||
while trialValue > target:
|
||||
nonce += 1
|
||||
trialValue, = unpack('>Q',hashlib.sha512(hashlib.sha512(pack('>Q',nonce) + payload).digest()).digest()[4:12])
|
||||
print 'Found proof of work', trialValue, 'Nonce:', nonce
|
||||
|
||||
payload = pack('>Q',nonce) + payload
|
||||
inventoryHash = calculateInventoryHash(payload)
|
||||
objectType = 'getpubkey'
|
||||
inventory[inventoryHash] = (objectType, streamNumber, payload, int(time.time()))
|
||||
print 'sending inv (for the getpubkey message)'
|
||||
#payload = '\x01' + pack('>H',objectType) + hash
|
||||
payload = '\x01' + inventoryHash
|
||||
headerData = '\xe9\xbe\xb4\xd9' #magic bits, slighly different from Bitcoin's magic bits.
|
||||
headerData = headerData + 'inv\x00\x00\x00\x00\x00\x00\x00\x00\x00'
|
||||
headerData = headerData + pack('>L',len(payload))
|
||||
headerData = headerData + hashlib.sha512(hashlib.sha512(payload).digest()).digest()[:4]
|
||||
broadcastToSendDataQueues((streamNumber, 'send', headerData + payload))
|
||||
|
||||
self.emit(SIGNAL("updateStatusBar(PyQt_PyObject)"),'Broacasting the public key request. The recipient''s software must be on. This program will auto-retry if they are offline.')
|
||||
self.emit(SIGNAL("updateSentItemStatusByHash(PyQt_PyObject,PyQt_PyObject)"),ripe,'Sending public key request. Waiting for reply. Requested at ' + strftime(config.get('bitmessagesettings', 'timeformat'),localtime(int(time.time()))))
|
||||
broadcastToSendDataQueues((streamNumber, 'send', headerData + payload))
|
||||
|
||||
def generateFullAckMessage(self,ackdata,toStreamNumber):
|
||||
nonce = 0
|
||||
trialValue = 99999999999999999
|
||||
embeddedTime = pack('>I',(int(time.time())))
|
||||
encodedStreamNumber = encodeVarint(toStreamNumber)
|
||||
payload = embeddedTime + encodedStreamNumber + ackdata
|
||||
target = 2**64 / ((len(payload)+payloadLengthExtraBytes+8) * averageProofOfWorkNonceTrialsPerByte)
|
||||
print '(For ack message) Doing proof of work...'
|
||||
while trialValue > target:
|
||||
nonce += 1
|
||||
trialValue, = unpack('>Q',hashlib.sha512(hashlib.sha512(pack('>Q',nonce) + payload).digest()).digest()[4:12])
|
||||
print '(For ack message) Found proof of work', trialValue, 'Nonce:', nonce
|
||||
payload = pack('>Q',nonce) + payload
|
||||
headerData = '\xe9\xbe\xb4\xd9' #magic bits, slighly different from Bitcoin's magic bits.
|
||||
headerData = headerData + 'msg\x00\x00\x00\x00\x00\x00\x00\x00\x00'
|
||||
headerData = headerData + pack('>L',len(payload))
|
||||
headerData = headerData + hashlib.sha512(hashlib.sha512(payload).digest()).digest()[:4]
|
||||
return headerData + payload
|
||||
|
||||
class addressGenerator(QThread):
|
||||
def __init__(self, parent = None):
|
||||
QThread.__init__(self, parent)
|
||||
|
||||
def setup(self,streamNumber,label):
|
||||
self.streamNumber = streamNumber
|
||||
self.label = label
|
||||
|
||||
def run(self):
|
||||
statusbar = 'Generating new ' + str(config.getint('bitmessagesettings', 'bitstrength')) + ' bit RSA key. This takes a minute on average. If you want to generate multiple addresses now, you can; they will queue.'
|
||||
self.emit(SIGNAL("updateStatusBar(PyQt_PyObject)"),statusbar)
|
||||
(pubkey, privkey) = rsa.newkeys(config.getint('bitmessagesettings', 'bitstrength'))
|
||||
print privkey['n']
|
||||
print privkey['e']
|
||||
print privkey['d']
|
||||
print privkey['p']
|
||||
print privkey['q']
|
||||
|
||||
sha = hashlib.new('sha512')
|
||||
#sha.update(str(pubkey.n)+str(pubkey.e))
|
||||
sha.update(convertIntToString(pubkey.n)+convertIntToString(pubkey.e))
|
||||
ripe = hashlib.new('ripemd160')
|
||||
ripe.update(sha.digest())
|
||||
address = encodeAddress(1,self.streamNumber,ripe.digest())
|
||||
|
||||
self.emit(SIGNAL("updateStatusBar(PyQt_PyObject)"),'Finished generating address. Writing to keys.dat')
|
||||
config.add_section(address)
|
||||
config.set(address,'label',self.label)
|
||||
config.set(address,'enabled','true')
|
||||
config.set(address,'n',str(privkey['n']))
|
||||
config.set(address,'e',str(privkey['e']))
|
||||
config.set(address,'d',str(privkey['d']))
|
||||
config.set(address,'p',str(privkey['p']))
|
||||
config.set(address,'q',str(privkey['q']))
|
||||
with open(appdata + 'keys.dat', 'wb') as configfile:
|
||||
config.write(configfile)
|
||||
|
||||
self.emit(SIGNAL("updateStatusBar(PyQt_PyObject)"),'Done generating address')
|
||||
self.emit(SIGNAL("writeNewAddressToTable(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"),self.label,address,str(self.streamNumber))
|
||||
|
||||
|
||||
'''class streamThread(QThread):
|
||||
def __init__(self, parent = None):
|
||||
QThread.__init__(self, parent)
|
||||
self.mailbox = Queue.Queue()
|
||||
streamQueues.append(self.mailbox)
|
||||
self.sendDataQueues = []
|
||||
|
||||
def __del__(self):
|
||||
self.wait()
|
||||
|
||||
|
||||
def broadcastTosendDataQueues(self,data):
|
||||
for q in self.sendDataQueues:
|
||||
q.put(data)
|
||||
|
||||
def setup(self,streamNumber):
|
||||
self.streamNumber = streamNumber
|
||||
|
||||
|
||||
|
||||
def run(self):
|
||||
#self.listOfSendDataThreads = []
|
||||
for i in range(1,2):
|
||||
x = sendDataThread()
|
||||
#self.listOfSendDataThreads.append(x)
|
||||
x.setup(i,self.sendDataQueues)
|
||||
#x.daemon = False
|
||||
x.start()
|
||||
#print 'length of listOfSendDataThreads', len(self.listOfSendDataThreads)
|
||||
|
||||
|
||||
while True:
|
||||
print self.streamNumber
|
||||
data = self.mailbox.get()
|
||||
if data == 'shutdown':
|
||||
self.broadcastTosendDataQueues('shutdown')
|
||||
print 'Stream thread', self, 'shutting down now'
|
||||
print 'len of streamQueues', len(streamQueues)
|
||||
while len(self.sendDataQueues) > 0 :
|
||||
pass
|
||||
streamQueues.remove(self.mailbox)
|
||||
return
|
||||
print self, 'received a message:', data
|
||||
returnedthing = str(self)+"dololly"
|
||||
self.emit(SIGNAL("updatebox(PyQt_PyObject)"),returnedthing)'''
|
||||
|
||||
#time.sleep(1)
|
||||
#while True:
|
||||
# print 'test'
|
||||
# time.sleep(1)
|
||||
|
||||
class iconGlossaryDialog(QtGui.QDialog):
|
||||
def __init__(self,parent):
|
||||
QtGui.QWidget.__init__(self, parent)
|
||||
self.ui = Ui_iconGlossaryDialog()
|
||||
self.ui.setupUi(self)
|
||||
self.parent = parent
|
||||
self.ui.labelPortNumber.setText('You are using TCP port ' + str(config.getint('bitmessagesettings', 'port')) + '. (This can be changed in the settings).')
|
||||
|
||||
class helpDialog(QtGui.QDialog):
|
||||
def __init__(self,parent):
|
||||
QtGui.QWidget.__init__(self, parent)
|
||||
self.ui = Ui_helpDialog()
|
||||
self.ui.setupUi(self)
|
||||
self.parent = parent
|
||||
self.ui.labelHelpURI.setOpenExternalLinks(True)
|
||||
|
||||
class aboutDialog(QtGui.QDialog):
|
||||
def __init__(self,parent):
|
||||
QtGui.QWidget.__init__(self, parent)
|
||||
self.ui = Ui_aboutDialog()
|
||||
self.ui.setupUi(self)
|
||||
self.parent = parent
|
||||
self.ui.labelVersion.setText('version ' + softwareVersion)
|
||||
|
||||
class settingsDialog(QtGui.QDialog):
|
||||
def __init__(self,parent):
|
||||
QtGui.QWidget.__init__(self, parent)
|
||||
self.ui = Ui_settingsDialog()
|
||||
self.ui.setupUi(self)
|
||||
self.parent = parent
|
||||
self.ui.checkBoxStartOnLogon.setChecked(config.getboolean('bitmessagesettings', 'startonlogon'))
|
||||
self.ui.checkBoxMinimizeToTray.setChecked(config.getboolean('bitmessagesettings', 'minimizetotray'))
|
||||
self.ui.lineEditTCPPort.setText(str(config.get('bitmessagesettings', 'port')))
|
||||
self.ui.checkBoxShowTrayNotifications.setChecked(config.getboolean('bitmessagesettings', 'showtraynotifications'))
|
||||
self.ui.checkBoxStartInTray.setChecked(config.getboolean('bitmessagesettings', 'startintray'))
|
||||
if 'darwin' in sys.platform:
|
||||
self.ui.checkBoxStartOnLogon.setDisabled(True)
|
||||
self.ui.labelSettingsNote.setText('Some options have been disabled because they haven\'t yet been implimented for your operating system.')
|
||||
elif 'linux' in sys.platform:
|
||||
pass
|
||||
|
||||
class NewSubscriptionDialog(QtGui.QDialog):
|
||||
def __init__(self,parent):
|
||||
QtGui.QWidget.__init__(self, parent)
|
||||
self.ui = Ui_NewSubscriptionDialog() #Jonathan changed this line
|
||||
self.ui.setupUi(self) #Jonathan left this line alone
|
||||
self.parent = parent
|
||||
QtCore.QObject.connect(self.ui.lineEditSubscriptionAddress, QtCore.SIGNAL("textChanged(QString)"), self.subscriptionAddressChanged)
|
||||
|
||||
def subscriptionAddressChanged(self,QString):
|
||||
status,a,b,c = decodeAddress(str(QString))
|
||||
if status == 'missingbm':
|
||||
self.ui.labelSubscriptionAddressCheck.setText('The address should start with ''BM-''')
|
||||
elif status == 'checksumfailed':
|
||||
self.ui.labelSubscriptionAddressCheck.setText('The address is not typed or copied correctly (the checksum failed).')
|
||||
elif status == 'versiontoohigh':
|
||||
self.ui.labelSubscriptionAddressCheck.setText('The version number of this address is higher than this software can support. Please upgrade Bitmessage.')
|
||||
elif status == 'invalidcharacters':
|
||||
self.ui.labelSubscriptionAddressCheck.setText('The address contains invalid characters.')
|
||||
elif status == 'success':
|
||||
self.ui.labelSubscriptionAddressCheck.setText('Address is valid.')
|
||||
|
||||
class NewAddressDialog(QtGui.QDialog):
|
||||
def __init__(self, parent):
|
||||
QtGui.QWidget.__init__(self, parent)
|
||||
self.ui = Ui_NewAddressDialog() #Jonathan changed this line
|
||||
self.ui.setupUi(self) #Jonathan left this line alone
|
||||
self.parent = parent
|
||||
row = 1
|
||||
while self.parent.ui.tableWidgetYourIdentities.item(row-1,1):
|
||||
self.ui.radioButtonExisting.click()
|
||||
#print self.parent.ui.tableWidgetYourIdentities.item(row-1,1).text()
|
||||
self.ui.comboBoxExisting.addItem(self.parent.ui.tableWidgetYourIdentities.item(row-1,1).text())
|
||||
row += 1
|
||||
|
||||
|
||||
|
||||
class MyForm(QtGui.QMainWindow):
|
||||
def __init__(self, parent=None):
|
||||
QtGui.QWidget.__init__(self, parent)
|
||||
self.ui = Ui_MainWindow() #Jonathan changed this line
|
||||
self.ui.setupUi(self) #Jonathan left this line alone
|
||||
|
||||
if 'win' in sys.platform:
|
||||
#Auto-startup for Windows
|
||||
RUN_PATH = "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run"
|
||||
self.settings = QSettings(RUN_PATH, QSettings.NativeFormat)
|
||||
self.settings.remove("PyBitmessage") #In case the user moves the program and the registry entry is no longer valid, this will delete the old registry entry.
|
||||
if config.getboolean('bitmessagesettings', 'startonlogon'):
|
||||
self.settings.setValue("PyBitmessage",sys.argv[0])
|
||||
elif 'darwin' in sys.platform:
|
||||
#startup for mac
|
||||
pass
|
||||
elif 'linux' in sys.platform:
|
||||
#startup for linux
|
||||
pass
|
||||
|
||||
self.trayIcon = QtGui.QSystemTrayIcon(self)
|
||||
self.trayIcon.setIcon( QtGui.QIcon(':/newPrefix/images/inbox.png') )
|
||||
traySignal = "activated(QSystemTrayIcon::ActivationReason)"
|
||||
QtCore.QObject.connect(self.trayIcon, QtCore.SIGNAL(traySignal), self.__icon_activated)
|
||||
menu = QtGui.QMenu()
|
||||
self.exitAction = menu.addAction("Exit", self.close)
|
||||
self.trayIcon.setContextMenu(menu)
|
||||
|
||||
#FILE MENU and other buttons
|
||||
QtCore.QObject.connect(self.ui.actionExit, QtCore.SIGNAL("triggered()"), self.close)
|
||||
QtCore.QObject.connect(self.ui.actionManageKeys, QtCore.SIGNAL("triggered()"), self.click_actionManageKeys)
|
||||
QtCore.QObject.connect(self.ui.pushButtonNewAddress, QtCore.SIGNAL("clicked()"), self.click_NewAddressDialog)
|
||||
QtCore.QObject.connect(self.ui.comboBoxSendFrom, QtCore.SIGNAL("activated(int)"),self.redrawLabelFrom)
|
||||
QtCore.QObject.connect(self.ui.pushButtonAddAddressBook, QtCore.SIGNAL("clicked()"), self.click_pushButtonAddAddressBook)
|
||||
QtCore.QObject.connect(self.ui.pushButtonAddSubscription, QtCore.SIGNAL("clicked()"), self.click_pushButtonAddSubscription)
|
||||
QtCore.QObject.connect(self.ui.pushButtonAddBlacklist, QtCore.SIGNAL("clicked()"), self.click_pushButtonAddBlacklist)
|
||||
QtCore.QObject.connect(self.ui.pushButtonSend, QtCore.SIGNAL("clicked()"), self.click_pushButtonSend)
|
||||
QtCore.QObject.connect(self.ui.pushButtonLoadFromAddressBook, QtCore.SIGNAL("clicked()"), self.click_pushButtonLoadFromAddressBook)
|
||||
QtCore.QObject.connect(self.ui.radioButtonBlacklist, QtCore.SIGNAL("clicked()"), self.click_radioButtonBlacklist)
|
||||
QtCore.QObject.connect(self.ui.radioButtonWhitelist, QtCore.SIGNAL("clicked()"), self.click_radioButtonWhitelist)
|
||||
QtCore.QObject.connect(self.ui.pushButtonStatusIcon, QtCore.SIGNAL("clicked()"), self.click_pushButtonStatusIcon)
|
||||
QtCore.QObject.connect(self.ui.actionSettings, QtCore.SIGNAL("triggered()"), self.click_actionSettings)
|
||||
QtCore.QObject.connect(self.ui.actionAbout, QtCore.SIGNAL("triggered()"), self.click_actionAbout)
|
||||
QtCore.QObject.connect(self.ui.actionHelp, QtCore.SIGNAL("triggered()"), self.click_actionHelp)
|
||||
|
||||
#Popup menu for the Inbox tab
|
||||
self.ui.inboxContextMenuToolbar = QtGui.QToolBar()
|
||||
# Actions
|
||||
self.actionReply = self.ui.inboxContextMenuToolbar.addAction("Reply", self.on_action_Reply)
|
||||
self.actionAddSenderToAddressBook = self.ui.inboxContextMenuToolbar.addAction("Add sender to your Address Book", self.on_action_addSenderToAddressBook)
|
||||
self.actionTrashInboxMessage = self.ui.inboxContextMenuToolbar.addAction("Move to Trash", self.on_action_InboxTrash)
|
||||
#self.actionDisable = self.ui.inboxContextMenuToolbar.addAction("Disable", self.on_action_disable)
|
||||
#self.actionClipboard = self.ui.inboxContextMenuToolbar.addAction("Copy address to clipboard", self.on_action_clipboard)
|
||||
self.ui.tableWidgetInbox.setContextMenuPolicy( QtCore.Qt.CustomContextMenu )
|
||||
self.connect(self.ui.tableWidgetInbox, QtCore.SIGNAL('customContextMenuRequested(const QPoint&)'), self.on_context_menuInbox)
|
||||
self.popMenuInbox = QtGui.QMenu( self )
|
||||
self.popMenuInbox.addAction( self.actionReply )
|
||||
self.popMenuInbox.addAction( self.actionAddSenderToAddressBook )
|
||||
self.popMenuInbox.addSeparator()
|
||||
self.popMenuInbox.addAction( self.actionTrashInboxMessage )
|
||||
|
||||
|
||||
#Popup menu for the Your Identities tab
|
||||
self.ui.addressContextMenuToolbar = QtGui.QToolBar()
|
||||
# Actions
|
||||
self.actionNew = self.ui.addressContextMenuToolbar.addAction("New", self.on_action_new)
|
||||
self.actionEnable = self.ui.addressContextMenuToolbar.addAction("Enable", self.on_action_enable)
|
||||
self.actionDisable = self.ui.addressContextMenuToolbar.addAction("Disable", self.on_action_disable)
|
||||
self.actionClipboard = self.ui.addressContextMenuToolbar.addAction("Copy address to clipboard", self.on_action_clipboard)
|
||||
self.ui.tableWidgetYourIdentities.setContextMenuPolicy( QtCore.Qt.CustomContextMenu )
|
||||
self.connect(self.ui.tableWidgetYourIdentities, QtCore.SIGNAL('customContextMenuRequested(const QPoint&)'), self.on_context_menuYourIdentities)
|
||||
self.popMenu = QtGui.QMenu( self )
|
||||
self.popMenu.addAction( self.actionNew )
|
||||
self.popMenu.addSeparator()
|
||||
self.popMenu.addAction( self.actionClipboard )
|
||||
self.popMenu.addSeparator()
|
||||
self.popMenu.addAction( self.actionEnable )
|
||||
self.popMenu.addAction( self.actionDisable )
|
||||
|
||||
#Popup menu for the Address Book page
|
||||
self.ui.addressBookContextMenuToolbar = QtGui.QToolBar()
|
||||
# Actions
|
||||
self.actionAddressBookNew = self.ui.addressBookContextMenuToolbar.addAction("New", self.on_action_AddressBookNew)
|
||||
self.actionAddressBookDelete = self.ui.addressBookContextMenuToolbar.addAction("Delete", self.on_action_AddressBookDelete)
|
||||
self.actionAddressBookClipboard = self.ui.addressBookContextMenuToolbar.addAction("Copy address to clipboard", self.on_action_AddressBookClipboard)
|
||||
self.actionAddressBookSend = self.ui.addressBookContextMenuToolbar.addAction("Send message to this address", self.on_action_AddressBookSend)
|
||||
self.ui.tableWidgetAddressBook.setContextMenuPolicy( QtCore.Qt.CustomContextMenu )
|
||||
self.connect(self.ui.tableWidgetAddressBook, QtCore.SIGNAL('customContextMenuRequested(const QPoint&)'), self.on_context_menuAddressBook)
|
||||
self.popMenuAddressBook = QtGui.QMenu( self )
|
||||
self.popMenuAddressBook.addAction( self.actionAddressBookNew )
|
||||
self.popMenuAddressBook.addAction( self.actionAddressBookDelete )
|
||||
self.popMenuAddressBook.addSeparator()
|
||||
self.popMenuAddressBook.addAction( self.actionAddressBookSend )
|
||||
self.popMenuAddressBook.addAction( self.actionAddressBookClipboard )
|
||||
|
||||
|
||||
#Popup menu for the Subscriptions page
|
||||
self.ui.subscriptionsContextMenuToolbar = QtGui.QToolBar()
|
||||
# Actions
|
||||
self.actionsubscriptionsNew = self.ui.subscriptionsContextMenuToolbar.addAction("New", self.on_action_SubscriptionsNew)
|
||||
self.actionsubscriptionsDelete = self.ui.subscriptionsContextMenuToolbar.addAction("Delete", self.on_action_SubscriptionsDelete)
|
||||
self.actionsubscriptionsClipboard = self.ui.subscriptionsContextMenuToolbar.addAction("Copy address to clipboard", self.on_action_SubscriptionsClipboard)
|
||||
self.ui.tableWidgetSubscriptions.setContextMenuPolicy( QtCore.Qt.CustomContextMenu )
|
||||
self.connect(self.ui.tableWidgetSubscriptions, QtCore.SIGNAL('customContextMenuRequested(const QPoint&)'), self.on_context_menuSubscriptions)
|
||||
self.popMenuSubscriptions = QtGui.QMenu( self )
|
||||
self.popMenuSubscriptions.addAction( self.actionsubscriptionsNew )
|
||||
self.popMenuSubscriptions.addAction( self.actionsubscriptionsDelete )
|
||||
self.popMenuSubscriptions.addSeparator()
|
||||
self.popMenuSubscriptions.addAction( self.actionsubscriptionsClipboard )
|
||||
|
||||
|
||||
#Initialize the user's list of addresses on the 'Your Identities' tab.
|
||||
configSections = config.sections()
|
||||
for addressInKeysFile in configSections:
|
||||
if addressInKeysFile <> 'bitmessagesettings':
|
||||
isEnabled = config.getboolean(addressInKeysFile, 'enabled')
|
||||
newItem = QtGui.QTableWidgetItem(unicode(config.get(addressInKeysFile, 'label'),'utf-8)'))
|
||||
if not isEnabled:
|
||||
newItem.setTextColor(QtGui.QColor(128,128,128))
|
||||
self.ui.tableWidgetYourIdentities.insertRow(0)
|
||||
self.ui.tableWidgetYourIdentities.setItem(0, 0, newItem)
|
||||
newItem = QtGui.QTableWidgetItem(addressInKeysFile)
|
||||
newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled )
|
||||
if not isEnabled:
|
||||
newItem.setTextColor(QtGui.QColor(128,128,128))
|
||||
self.ui.tableWidgetYourIdentities.setItem(0, 1, newItem)
|
||||
newItem = QtGui.QTableWidgetItem(str(addressStream(addressInKeysFile)))
|
||||
newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled )
|
||||
if not isEnabled:
|
||||
newItem.setTextColor(QtGui.QColor(128,128,128))
|
||||
self.ui.tableWidgetYourIdentities.setItem(0, 2, newItem)
|
||||
if isEnabled:
|
||||
status,addressVersionNumber,streamNumber,hash = decodeAddress(addressInKeysFile)
|
||||
|
||||
self.sqlLookup = sqlThread()
|
||||
self.sqlLookup.start()
|
||||
|
||||
self.reloadMyAddressHashes()
|
||||
self.reloadBroadcastSendersForWhichImWatching()
|
||||
|
||||
|
||||
#Load inbox from messages database file
|
||||
sqlSubmitQueue.put('''SELECT msgid, toaddress, fromaddress, subject, received, message FROM inbox where folder='inbox' ORDER BY received''')
|
||||
sqlSubmitQueue.put('')
|
||||
queryreturn = sqlReturnQueue.get()
|
||||
for row in queryreturn:
|
||||
msgid, toAddress, fromAddress, subject, received, message, = row
|
||||
|
||||
|
||||
try:
|
||||
if toAddress == '[Broadcast subscribers]':
|
||||
toLabel = '[Broadcast subscribers]'
|
||||
else:
|
||||
toLabel = config.get(toAddress, 'label')
|
||||
except:
|
||||
toLabel = ''
|
||||
if toLabel == '':
|
||||
toLabel = toAddress
|
||||
|
||||
fromLabel = ''
|
||||
t = (fromAddress,)
|
||||
sqlSubmitQueue.put('''select label from addressbook where address=?''')
|
||||
sqlSubmitQueue.put(t)
|
||||
queryreturn = sqlReturnQueue.get()
|
||||
|
||||
if queryreturn <> []:
|
||||
for row in queryreturn:
|
||||
fromLabel, = row
|
||||
|
||||
self.ui.tableWidgetInbox.insertRow(0)
|
||||
newItem = QtGui.QTableWidgetItem(unicode(toLabel,'utf-8'))
|
||||
newItem.setData(Qt.UserRole,str(toAddress))
|
||||
self.ui.tableWidgetInbox.setItem(0,0,newItem)
|
||||
if fromLabel == '':
|
||||
newItem = QtGui.QTableWidgetItem(unicode(fromAddress,'utf-8'))
|
||||
else:
|
||||
newItem = QtGui.QTableWidgetItem(unicode(fromLabel,'utf-8'))
|
||||
newItem.setData(Qt.UserRole,str(fromAddress))
|
||||
self.ui.tableWidgetInbox.setItem(0,1,newItem)
|
||||
newItem = QtGui.QTableWidgetItem(unicode(subject,'utf-8'))
|
||||
newItem.setData(Qt.UserRole,unicode(message,'utf-8)'))
|
||||
self.ui.tableWidgetInbox.setItem(0,2,newItem)
|
||||
newItem = QtGui.QTableWidgetItem(strftime(config.get('bitmessagesettings', 'timeformat'),localtime(int(received))))
|
||||
newItem.setData(Qt.UserRole,QByteArray(msgid))
|
||||
self.ui.tableWidgetInbox.setItem(0,3,newItem)
|
||||
#self.ui.textEditInboxMessage.setText(self.ui.tableWidgetInbox.item(0,2).data(Qt.UserRole).toPyObject())
|
||||
|
||||
#Load Sent items from database
|
||||
sqlSubmitQueue.put('SELECT toaddress, fromaddress, subject, message, status, ackdata, lastactiontime FROM sent ORDER BY lastactiontime')
|
||||
sqlSubmitQueue.put('')
|
||||
queryreturn = sqlReturnQueue.get()
|
||||
for row in queryreturn:
|
||||
toAddress, fromAddress, subject, message, status, ackdata, lastactiontime = row
|
||||
try:
|
||||
fromLabel = config.get(fromAddress, 'label')
|
||||
except:
|
||||
fromLabel = ''
|
||||
if fromLabel == '':
|
||||
fromLabel = fromAddress
|
||||
|
||||
toLabel = ''
|
||||
t = (toAddress,)
|
||||
sqlSubmitQueue.put('''select label from addressbook where address=?''')
|
||||
sqlSubmitQueue.put(t)
|
||||
queryreturn = sqlReturnQueue.get()
|
||||
|
||||
if queryreturn <> []:
|
||||
for row in queryreturn:
|
||||
toLabel, = row
|
||||
|
||||
self.ui.tableWidgetSent.insertRow(0)
|
||||
if toLabel == '':
|
||||
newItem = QtGui.QTableWidgetItem(unicode(toAddress,'utf-8'))
|
||||
else:
|
||||
newItem = QtGui.QTableWidgetItem(unicode(toLabel,'utf-8'))
|
||||
newItem.setData(Qt.UserRole,str(toAddress))
|
||||
self.ui.tableWidgetSent.setItem(0,0,newItem)
|
||||
if fromLabel == '':
|
||||
newItem = QtGui.QTableWidgetItem(unicode(fromAddress,'utf-8'))
|
||||
else:
|
||||
newItem = QtGui.QTableWidgetItem(unicode(fromLabel,'utf-8'))
|
||||
newItem.setData(Qt.UserRole,str(fromAddress))
|
||||
self.ui.tableWidgetSent.setItem(0,1,newItem)
|
||||
newItem = QtGui.QTableWidgetItem(unicode(subject,'utf-8'))
|
||||
newItem.setData(Qt.UserRole,unicode(message,'utf-8)'))
|
||||
self.ui.tableWidgetSent.setItem(0,2,newItem)
|
||||
if status == 'findingpubkey':
|
||||
newItem = QtGui.QTableWidgetItem('Waiting on their public key. Will request it again soon.')
|
||||
elif status == 'sentmessage':
|
||||
newItem = QtGui.QTableWidgetItem('Message sent. Waiting on acknowledgement. Sent at ' + strftime(config.get('bitmessagesettings', 'timeformat'),localtime(lastactiontime)))
|
||||
elif status == 'doingpow':
|
||||
newItem = QtGui.QTableWidgetItem('Need to do work to send message. Work is queued.')
|
||||
elif status == 'ackreceived':
|
||||
newItem = QtGui.QTableWidgetItem('Acknowledgement of the message received ' + strftime(config.get('bitmessagesettings', 'timeformat'),localtime(int(lastactiontime))))
|
||||
elif status == 'broadcastpending':
|
||||
newItem = QtGui.QTableWidgetItem('Doing the work necessary to send broadcast...')
|
||||
elif status == 'broadcastsent':
|
||||
newItem = QtGui.QTableWidgetItem('Broadcast on ' + strftime(config.get('bitmessagesettings', 'timeformat'),localtime(int(lastactiontime))))
|
||||
else:
|
||||
newItem = QtGui.QTableWidgetItem('Unknown status. ' + strftime(config.get('bitmessagesettings', 'timeformat'),localtime(int(lastactiontime))))
|
||||
newItem.setData(Qt.UserRole,ackdata)
|
||||
self.ui.tableWidgetSent.setItem(0,3,newItem)
|
||||
|
||||
#Initialize the address book
|
||||
sqlSubmitQueue.put('SELECT * FROM addressbook')
|
||||
sqlSubmitQueue.put('')
|
||||
queryreturn = sqlReturnQueue.get()
|
||||
for row in queryreturn:
|
||||
label, address = row
|
||||
self.ui.tableWidgetAddressBook.insertRow(0)
|
||||
newItem = QtGui.QTableWidgetItem(unicode(label,'utf-8'))
|
||||
self.ui.tableWidgetAddressBook.setItem(0,0,newItem)
|
||||
newItem = QtGui.QTableWidgetItem(address)
|
||||
newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled )
|
||||
self.ui.tableWidgetAddressBook.setItem(0,1,newItem)
|
||||
|
||||
#Initialize the Subscriptions
|
||||
sqlSubmitQueue.put('SELECT label, address FROM subscriptions')
|
||||
sqlSubmitQueue.put('')
|
||||
queryreturn = sqlReturnQueue.get()
|
||||
for row in queryreturn:
|
||||
label, address = row
|
||||
self.ui.tableWidgetSubscriptions.insertRow(0)
|
||||
newItem = QtGui.QTableWidgetItem(unicode(label,'utf-8'))
|
||||
self.ui.tableWidgetSubscriptions.setItem(0,0,newItem)
|
||||
newItem = QtGui.QTableWidgetItem(address)
|
||||
newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled )
|
||||
self.ui.tableWidgetSubscriptions.setItem(0,1,newItem)
|
||||
|
||||
#Initialize the Blacklist or Whitelist
|
||||
if config.get('bitmessagesettings', 'blackwhitelist') == 'black':
|
||||
self.loadBlackWhiteList()
|
||||
else:
|
||||
self.ui.tabWidget.setTabText(6,'Whitelist')
|
||||
self.ui.radioButtonWhitelist.click()
|
||||
self.loadBlackWhiteList()
|
||||
|
||||
|
||||
#Initialize the ackdataForWhichImWatching data structure using data from the sql database.
|
||||
sqlSubmitQueue.put('''SELECT ackdata FROM sent where (status='sentmessage' OR status='doingpow')''')
|
||||
sqlSubmitQueue.put('')
|
||||
queryreturn = sqlReturnQueue.get()
|
||||
for row in queryreturn:
|
||||
ackdata, = row
|
||||
print 'Watching for ackdata', repr(ackdata)
|
||||
ackdataForWhichImWatching[ackdata] = 0
|
||||
|
||||
QtCore.QObject.connect(self.ui.tableWidgetYourIdentities, QtCore.SIGNAL("itemChanged(QTableWidgetItem *)"), self.tableWidgetYourIdentitiesItemChanged)
|
||||
QtCore.QObject.connect(self.ui.tableWidgetAddressBook, QtCore.SIGNAL("itemChanged(QTableWidgetItem *)"), self.tableWidgetAddressBookItemChanged)
|
||||
QtCore.QObject.connect(self.ui.tableWidgetSubscriptions, QtCore.SIGNAL("itemChanged(QTableWidgetItem *)"), self.tableWidgetSubscriptionsItemChanged)
|
||||
QtCore.QObject.connect(self.ui.tableWidgetInbox, QtCore.SIGNAL("itemClicked(QTableWidgetItem *)"), self.tableWidgetInboxItemClicked)
|
||||
QtCore.QObject.connect(self.ui.tableWidgetSent, QtCore.SIGNAL("itemClicked(QTableWidgetItem *)"), self.tableWidgetSentItemClicked)
|
||||
|
||||
#Put the colored icon on the status bar
|
||||
#self.ui.pushButtonStatusIcon.setIcon(QIcon(":/newPrefix/images/yellowicon.png"))
|
||||
self.statusbar = self.statusBar()
|
||||
self.statusbar.insertPermanentWidget(0,self.ui.pushButtonStatusIcon)
|
||||
self.ui.labelStartupTime.setText('Since startup on ' + strftime(config.get('bitmessagesettings', 'timeformat'),localtime(int(time.time()))))
|
||||
self.numberOfMessagesProcessed = 0
|
||||
self.numberOfBroadcastsProcessed = 0
|
||||
self.numberOfPubkeysProcessed = 0
|
||||
|
||||
#Below this point, it would be good if all of the necessary global data structures were initialized.
|
||||
|
||||
self.rerenderComboBoxSendFrom()
|
||||
|
||||
self.listOfOutgoingSynSenderThreads = [] #if we don't maintain this list, the threads will get garbage-collected.
|
||||
|
||||
self.connectToStream(1)
|
||||
|
||||
self.singleListenerThread = singleListener()
|
||||
self.singleListenerThread.start()
|
||||
QtCore.QObject.connect(self.singleListenerThread, QtCore.SIGNAL("passObjectThrough(PyQt_PyObject)"), self.connectObjectToSignals)
|
||||
|
||||
|
||||
self.singleCleanerThread = singleCleaner()
|
||||
self.singleCleanerThread.start()
|
||||
QtCore.QObject.connect(self.singleCleanerThread, QtCore.SIGNAL("updateSentItemStatusByHash(PyQt_PyObject,PyQt_PyObject)"), self.updateSentItemStatusByHash)
|
||||
|
||||
self.workerThread = singleWorker()
|
||||
|
||||
#self.workerThread.setup(workerQueue)
|
||||
self.workerThread.start()
|
||||
QtCore.QObject.connect(self.workerThread, QtCore.SIGNAL("updateSentItemStatusByHash(PyQt_PyObject,PyQt_PyObject)"), self.updateSentItemStatusByHash)
|
||||
QtCore.QObject.connect(self.workerThread, QtCore.SIGNAL("updateSentItemStatusByAckdata(PyQt_PyObject,PyQt_PyObject)"), self.updateSentItemStatusByAckdata)
|
||||
|
||||
def click_actionManageKeys(self):
|
||||
reply = QtGui.QMessageBox.question(self, 'Open keys.dat?','You may manage your keys by editing the keys.dat file stored in\n' + appdata + '\nIt is important that you back up this file. Would you like to open the file now? (Be sure to close Bitmessage before making any changes.)', QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
|
||||
|
||||
if reply == QtGui.QMessageBox.Yes:
|
||||
self.openKeysFile()
|
||||
else:
|
||||
pass
|
||||
|
||||
def openKeysFile(self):
|
||||
if 'linux' in sys.platform:
|
||||
subprocess.call(["xdg-open", file])
|
||||
else:
|
||||
os.startfile(appdata + '\\keys.dat')
|
||||
|
||||
def changeEvent(self, event):
|
||||
if config.getboolean('bitmessagesettings', 'minimizetotray'):
|
||||
if event.type() == QtCore.QEvent.WindowStateChange:
|
||||
if self.windowState() & QtCore.Qt.WindowMinimized:
|
||||
self.hide()
|
||||
self.trayIcon.show()
|
||||
#self.hidden = True
|
||||
if 'win' in sys.platform:
|
||||
self.setWindowFlags(Qt.ToolTip)
|
||||
elif event.oldState() & QtCore.Qt.WindowMinimized:
|
||||
#The window state has just been changed to Normal/Maximised/FullScreen
|
||||
pass
|
||||
#QtGui.QWidget.changeEvent(self, event)
|
||||
|
||||
def __icon_activated(self, reason):
|
||||
if reason == QtGui.QSystemTrayIcon.Trigger:
|
||||
self.trayIcon.hide()
|
||||
self.setWindowFlags(Qt.Window)
|
||||
self.show()
|
||||
if 'win' in sys.platform:
|
||||
self.setWindowState(self.windowState() & ~QtCore.Qt.WindowMinimized | QtCore.Qt.WindowActive)
|
||||
self.activateWindow()
|
||||
|
||||
def incrementNumberOfMessagesProcessed(self):
|
||||
self.numberOfMessagesProcessed += 1
|
||||
self.ui.labelMessageCount.setText('Processed ' + str(self.numberOfMessagesProcessed) + ' person-to-person messages.')
|
||||
|
||||
def incrementNumberOfBroadcastsProcessed(self):
|
||||
self.numberOfBroadcastsProcessed += 1
|
||||
self.ui.labelBroadcastCount.setText('Processed ' + str(self.numberOfBroadcastsProcessed) + ' broadcast messages.')
|
||||
|
||||
def incrementNumberOfPubkeysProcessed(self):
|
||||
self.numberOfPubkeysProcessed += 1
|
||||
self.ui.labelPubkeyCount.setText('Processed ' + str(self.numberOfPubkeysProcessed) + ' public keys.')
|
||||
|
||||
def updateNetworkStatusTab(self,streamNumber,connectionCount):
|
||||
global statusIconColor
|
||||
print 'updating network status tab'
|
||||
totalNumberOfConnectionsFromAllStreams = 0 #One would think we could use len(sendDataQueues) for this, but sendData threads don't remove themselves from sendDataQueues fast enough for len(sendDataQueues) to be accurate here.
|
||||
for currentRow in range(self.ui.tableWidgetConnectionCount.rowCount()):
|
||||
rowStreamNumber = int(self.ui.tableWidgetConnectionCount.item(currentRow,0).text())
|
||||
if streamNumber == rowStreamNumber:
|
||||
self.ui.tableWidgetConnectionCount.item(currentRow,1).setText(str(connectionCount))
|
||||
totalNumberOfConnectionsFromAllStreams += connectionCount
|
||||
self.ui.labelTotalConnections.setText('Total Connections: ' + str(totalNumberOfConnectionsFromAllStreams))
|
||||
if totalNumberOfConnectionsFromAllStreams > 0 and statusIconColor == 'red': #FYI: The 'singlelistener' thread sets the icon color to green when it receives an incoming connection, meaning that the user's firewall is configured correctly.
|
||||
self.setStatusIcon('yellow')
|
||||
elif totalNumberOfConnectionsFromAllStreams == 0:
|
||||
self.setStatusIcon('red')
|
||||
|
||||
def setStatusIcon(self,color):
|
||||
global statusIconColor
|
||||
print 'setting status icon color'
|
||||
if color == 'red':
|
||||
self.ui.pushButtonStatusIcon.setIcon(QIcon(":/newPrefix/images/redicon.png"))
|
||||
statusIconColor = 'red'
|
||||
if color == 'yellow':
|
||||
self.ui.pushButtonStatusIcon.setIcon(QIcon(":/newPrefix/images/yellowicon.png"))
|
||||
statusIconColor = 'yellow'
|
||||
if color == 'green':
|
||||
self.ui.pushButtonStatusIcon.setIcon(QIcon(":/newPrefix/images/greenicon.png"))
|
||||
statusIconColor = 'green'
|
||||
|
||||
def updateSentItemStatusByHash(self,toRipe,textToDisplay):
|
||||
for i in range(self.ui.tableWidgetSent.rowCount()):
|
||||
toAddress = str(self.ui.tableWidgetSent.item(i,0).data(Qt.UserRole).toPyObject())
|
||||
# messageState = str(self.ui.tableWidgetSent.item(i,3).data(Qt.UserRole).toPyObject())
|
||||
status,addressVersionNumber,streamNumber,ripe = decodeAddress(toAddress)
|
||||
if ripe == toRipe:
|
||||
self.ui.tableWidgetSent.item(i,3).setText(unicode(textToDisplay,'utf-8'))
|
||||
#if textToDisplay == 'Sent':
|
||||
# self.ui.tableWidgetSent.item(i,3).setData(Qt.UserRole,'sent')
|
||||
|
||||
def updateSentItemStatusByAckdata(self,ackdata,textToDisplay):
|
||||
for i in range(self.ui.tableWidgetSent.rowCount()):
|
||||
toAddress = str(self.ui.tableWidgetSent.item(i,0).data(Qt.UserRole).toPyObject())
|
||||
tableAckdata = self.ui.tableWidgetSent.item(i,3).data(Qt.UserRole).toPyObject()
|
||||
status,addressVersionNumber,streamNumber,ripe = decodeAddress(toAddress)
|
||||
if ackdata == tableAckdata:
|
||||
self.ui.tableWidgetSent.item(i,3).setText(unicode(textToDisplay,'utf-8'))
|
||||
#if textToDisplay == 'Sent':
|
||||
# self.ui.tableWidgetSent.item(i,3).setData(Qt.UserRole,'sent')
|
||||
|
||||
def rerenderInboxFromLabels(self):
|
||||
for i in range(self.ui.tableWidgetInbox.rowCount()):
|
||||
addressToLookup = str(self.ui.tableWidgetInbox.item(i,1).data(Qt.UserRole).toPyObject())
|
||||
fromLabel = ''
|
||||
t = (addressToLookup,)
|
||||
sqlLock.acquire()
|
||||
sqlSubmitQueue.put('''select label from addressbook where address=?''')
|
||||
sqlSubmitQueue.put(t)
|
||||
queryreturn = sqlReturnQueue.get()
|
||||
sqlLock.release()
|
||||
|
||||
if queryreturn <> []:
|
||||
for row in queryreturn:
|
||||
fromLabel, = row
|
||||
self.ui.tableWidgetInbox.item(i,1).setText(unicode(fromLabel,'utf-8'))
|
||||
else:
|
||||
#It might be a broadcast message. We should check for that label.
|
||||
sqlLock.acquire()
|
||||
sqlSubmitQueue.put('''select label from subscriptions where address=?''')
|
||||
sqlSubmitQueue.put(t)
|
||||
queryreturn = sqlReturnQueue.get()
|
||||
sqlLock.release()
|
||||
|
||||
if queryreturn <> []:
|
||||
for row in queryreturn:
|
||||
fromLabel, = row
|
||||
self.ui.tableWidgetInbox.item(i,1).setText(unicode(fromLabel,'utf-8'))
|
||||
|
||||
|
||||
def rerenderInboxToLabels(self):
|
||||
for i in range(self.ui.tableWidgetInbox.rowCount()):
|
||||
toAddress = str(self.ui.tableWidgetInbox.item(i,0).data(Qt.UserRole).toPyObject())
|
||||
try:
|
||||
toLabel = config.get(toAddress, 'label')
|
||||
except:
|
||||
toLabel = ''
|
||||
if toLabel == '':
|
||||
toLabel = toAddress
|
||||
self.ui.tableWidgetInbox.item(i,0).setText(unicode(toLabel,'utf-8'))
|
||||
|
||||
def rerenderSentFromLabels(self):
|
||||
for i in range(self.ui.tableWidgetSent.rowCount()):
|
||||
fromAddress = str(self.ui.tableWidgetSent.item(i,1).data(Qt.UserRole).toPyObject())
|
||||
try:
|
||||
fromLabel = config.get(fromAddress, 'label')
|
||||
except:
|
||||
fromLabel = ''
|
||||
if fromLabel == '':
|
||||
fromLabel = fromAddress
|
||||
self.ui.tableWidgetSent.item(i,1).setText(unicode(fromLabel,'utf-8'))
|
||||
|
||||
def rerenderSentToLabels(self):
|
||||
for i in range(self.ui.tableWidgetSent.rowCount()):
|
||||
addressToLookup = str(self.ui.tableWidgetSent.item(i,0).data(Qt.UserRole).toPyObject())
|
||||
toLabel = ''
|
||||
t = (addressToLookup,)
|
||||
sqlSubmitQueue.put('''select label from addressbook where address=?''')
|
||||
sqlSubmitQueue.put(t)
|
||||
queryreturn = sqlReturnQueue.get()
|
||||
|
||||
if queryreturn <> []:
|
||||
for row in queryreturn:
|
||||
toLabel, = row
|
||||
self.ui.tableWidgetSent.item(i,0).setText(unicode(toLabel,'utf-8'))
|
||||
|
||||
def click_pushButtonSend(self):
|
||||
print 'User clicked \'Send\''
|
||||
self.statusBar().showMessage('')
|
||||
toAddresses = str(self.ui.lineEditTo.text())
|
||||
fromAddress = str(self.ui.labelFrom.text())
|
||||
subject = str(self.ui.lineEditSubject.text().toUtf8())
|
||||
message = str(self.ui.textEditMessage.document().toPlainText().toUtf8())
|
||||
if self.ui.radioButtonSpecific.isChecked(): #To send a message to specific people (rather than broadcast)
|
||||
toAddressesList = [s.strip() for s in toAddresses.replace(',', ';').split(';')]
|
||||
toAddressesList = list(set(toAddressesList)) #remove duplicate addresses
|
||||
for toAddress in toAddressesList:
|
||||
if toAddress <> '':
|
||||
status,addressVersionNumber,streamNumber,ripe = decodeAddress(toAddress)
|
||||
if status <> 'success':
|
||||
print 'Status bar!', 'Error: Could not decode', toAddress, ':', status
|
||||
if status == 'missingbm':
|
||||
self.statusBar().showMessage('Error: Bitmessage addresses start with BM- Please check ' + toAddress)
|
||||
if status == 'checksumfailed':
|
||||
self.statusBar().showMessage('Error: The address ' + toAddress+' is not typed or copied correctly. Please check it.')
|
||||
if status == 'invalidcharacters':
|
||||
self.statusBar().showMessage('Error: The address '+ toAddress+ ' contains invalid characters. Please check it.')
|
||||
if status == 'versiontoohigh':
|
||||
self.statusBar().showMessage('Error: The address version in '+ toAddress+ ' is too high. Either you need to upgrade your Bitmessage software or your acquaintance is being clever.')
|
||||
elif fromAddress == '':
|
||||
print 'Status bar!', 'Error: you must specify a From address.'
|
||||
self.statusBar().showMessage('Error: You must specify a From address. If you don''t have one, go to the ''Your Identities'' tab.')
|
||||
else:
|
||||
self.statusBar().showMessage('')
|
||||
|
||||
ackdata = ''
|
||||
for i in range(4): #This will make 32 bytes of random data.
|
||||
random.seed()
|
||||
ackdata += pack('>Q',random.randrange(1, 18446744073709551615))
|
||||
ackdataForWhichImWatching[ackdata] = 0
|
||||
print 'ackdataForWhichImWatching within pushButtonSend', repr(ackdataForWhichImWatching)
|
||||
sqlLock.acquire()
|
||||
t = ('',toAddress,ripe,fromAddress,subject,message,ackdata,int(time.time()),'findingpubkey',1,1,'sent')
|
||||
sqlSubmitQueue.put('''INSERT INTO sent VALUES (?,?,?,?,?,?,?,?,?,?,?,?)''')
|
||||
sqlSubmitQueue.put(t)
|
||||
sqlReturnQueue.get()
|
||||
sqlLock.release()
|
||||
workerQueue.put(('sendmessage',toAddress))
|
||||
|
||||
try:
|
||||
fromLabel = config.get(fromAddress, 'label')
|
||||
except:
|
||||
fromLabel = ''
|
||||
if fromLabel == '':
|
||||
fromLabel = fromAddress
|
||||
|
||||
toLabel = ''
|
||||
|
||||
t = (toAddress,)
|
||||
sqlLock.acquire()
|
||||
sqlSubmitQueue.put('''select label from addressbook where address=?''')
|
||||
sqlSubmitQueue.put(t)
|
||||
queryreturn = sqlReturnQueue.get()
|
||||
sqlLock.release()
|
||||
if queryreturn <> []:
|
||||
for row in queryreturn:
|
||||
toLabel, = row
|
||||
|
||||
self.ui.tableWidgetSent.insertRow(0)
|
||||
if toLabel == '':
|
||||
newItem = QtGui.QTableWidgetItem(unicode(toAddress,'utf-8'))
|
||||
else:
|
||||
newItem = QtGui.QTableWidgetItem(unicode(toLabel,'utf-8'))
|
||||
newItem.setData(Qt.UserRole,str(toAddress))
|
||||
self.ui.tableWidgetSent.setItem(0,0,newItem)
|
||||
|
||||
if fromLabel == '':
|
||||
newItem = QtGui.QTableWidgetItem(unicode(fromAddress,'utf-8'))
|
||||
else:
|
||||
newItem = QtGui.QTableWidgetItem(unicode(fromLabel,'utf-8'))
|
||||
newItem.setData(Qt.UserRole,str(fromAddress))
|
||||
self.ui.tableWidgetSent.setItem(0,1,newItem)
|
||||
newItem = QtGui.QTableWidgetItem(unicode(subject,'utf-8)'))
|
||||
newItem.setData(Qt.UserRole,unicode(message,'utf-8)'))
|
||||
self.ui.tableWidgetSent.setItem(0,2,newItem)
|
||||
newItem = QtGui.QTableWidgetItem('Just pressed ''send'' '+strftime(config.get('bitmessagesettings', 'timeformat'),localtime(int(time.time()))))
|
||||
newItem.setData(Qt.UserRole,ackdata)
|
||||
self.ui.tableWidgetSent.setItem(0,3,newItem)
|
||||
|
||||
self.ui.textEditSentMessage.setText(self.ui.tableWidgetSent.item(0,2).data(Qt.UserRole).toPyObject())
|
||||
|
||||
self.ui.labelFrom.setText('')
|
||||
self.ui.tabWidget.setCurrentIndex(2)
|
||||
else:
|
||||
self.statusBar().showMessage('Your \'To\' field is empty.')
|
||||
else: #User selected 'Broadcast'
|
||||
if fromAddress == '':
|
||||
print 'Status bar!', 'Error: you must specify a From address.'
|
||||
self.statusBar().showMessage('Error: You must specify a From address. If you don\'t have one, go to the \'Your Identities\' tab.')
|
||||
else:
|
||||
self.statusBar().showMessage('')
|
||||
ackdata = ''
|
||||
#We don't actually need the ackdata for acknowledgement since this is a broadcast message, but we can use it to update the user interface when the POW is done generating.
|
||||
for i in range(4): #This will make 32 bytes of random data.
|
||||
random.seed()
|
||||
ackdata += pack('>Q',random.randrange(1, 18446744073709551615))
|
||||
toAddress = '[Broadcast subscribers]'
|
||||
ripe = ''
|
||||
sqlLock.acquire()
|
||||
t = ('',toAddress,ripe,fromAddress,subject,message,ackdata,int(time.time()),'broadcastpending',1,1,'sent')
|
||||
sqlSubmitQueue.put('''INSERT INTO sent VALUES (?,?,?,?,?,?,?,?,?,?,?,?)''')
|
||||
sqlSubmitQueue.put(t)
|
||||
sqlReturnQueue.get()
|
||||
sqlLock.release()
|
||||
|
||||
workerQueue.put(('sendbroadcast',(fromAddress,subject,message)))
|
||||
|
||||
try:
|
||||
fromLabel = config.get(fromAddress, 'label')
|
||||
except:
|
||||
fromLabel = ''
|
||||
if fromLabel == '':
|
||||
fromLabel = fromAddress
|
||||
|
||||
toLabel = '[Broadcast subscribers]'
|
||||
|
||||
self.ui.tableWidgetSent.insertRow(0)
|
||||
newItem = QtGui.QTableWidgetItem(unicode(toLabel,'utf-8'))
|
||||
newItem.setData(Qt.UserRole,str(toAddress))
|
||||
self.ui.tableWidgetSent.setItem(0,0,newItem)
|
||||
|
||||
if fromLabel == '':
|
||||
newItem = QtGui.QTableWidgetItem(unicode(fromAddress,'utf-8'))
|
||||
else:
|
||||
newItem = QtGui.QTableWidgetItem(unicode(fromLabel,'utf-8'))
|
||||
newItem.setData(Qt.UserRole,str(fromAddress))
|
||||
self.ui.tableWidgetSent.setItem(0,1,newItem)
|
||||
newItem = QtGui.QTableWidgetItem(unicode(subject,'utf-8)'))
|
||||
newItem.setData(Qt.UserRole,unicode(message,'utf-8)'))
|
||||
self.ui.tableWidgetSent.setItem(0,2,newItem)
|
||||
#newItem = QtGui.QTableWidgetItem('Doing work necessary to send broadcast...'+strftime(config.get('bitmessagesettings', 'timeformat'),localtime(int(time.time()))))
|
||||
newItem = QtGui.QTableWidgetItem('Doing work necessary to send broadcast...')
|
||||
newItem.setData(Qt.UserRole,ackdata)
|
||||
self.ui.tableWidgetSent.setItem(0,3,newItem)
|
||||
|
||||
self.ui.textEditSentMessage.setText(self.ui.tableWidgetSent.item(0,2).data(Qt.UserRole).toPyObject())
|
||||
|
||||
self.ui.labelFrom.setText('')
|
||||
self.ui.tabWidget.setCurrentIndex(2)
|
||||
|
||||
|
||||
|
||||
def click_pushButtonLoadFromAddressBook(self):
|
||||
self.ui.tabWidget.setCurrentIndex(5)
|
||||
for i in range(4):
|
||||
time.sleep(0.1)
|
||||
self.statusBar().showMessage('')
|
||||
time.sleep(0.1)
|
||||
self.statusBar().showMessage('Right click an entry in your address book and select \'Send message to this address\'.')
|
||||
|
||||
def redrawLabelFrom(self,index):
|
||||
self.ui.labelFrom.setText(self.ui.comboBoxSendFrom.itemData(index).toPyObject())
|
||||
|
||||
def rerenderComboBoxSendFrom(self):
|
||||
self.ui.comboBoxSendFrom.clear()
|
||||
self.ui.labelFrom.setText('')
|
||||
configSections = config.sections()
|
||||
for addressInKeysFile in configSections:
|
||||
if addressInKeysFile <> 'bitmessagesettings':
|
||||
isEnabled = config.getboolean(addressInKeysFile, 'enabled') #I realize that this is poor programming practice but I don't care. It's easier for others to read.
|
||||
if isEnabled:
|
||||
self.ui.comboBoxSendFrom.insertItem(0,unicode(config.get(addressInKeysFile, 'label'),'utf-8'),addressInKeysFile)
|
||||
|
||||
def connectToStream(self,streamNumber):
|
||||
connectionsCount[streamNumber] = 0
|
||||
|
||||
#Add a line to the Connection Count table on the Network Status tab with a 'zero' connection count. This will be updated as necessary by another function.
|
||||
self.ui.tableWidgetConnectionCount.insertRow(0)
|
||||
newItem = QtGui.QTableWidgetItem(str(streamNumber))
|
||||
newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled )
|
||||
self.ui.tableWidgetConnectionCount.setItem(0,0,newItem)
|
||||
newItem = QtGui.QTableWidgetItem('0')
|
||||
newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled )
|
||||
self.ui.tableWidgetConnectionCount.setItem(0,1,newItem)
|
||||
|
||||
a = outgoingSynSender()
|
||||
self.listOfOutgoingSynSenderThreads.append(a)
|
||||
QtCore.QObject.connect(a, QtCore.SIGNAL("passObjectThrough(PyQt_PyObject)"), self.connectObjectToSignals)
|
||||
a.setup(streamNumber)
|
||||
a.start()
|
||||
|
||||
def connectObjectToSignals(self,object):
|
||||
QtCore.QObject.connect(object, QtCore.SIGNAL("updateStatusBar(PyQt_PyObject)"), self.updateStatusBar)
|
||||
QtCore.QObject.connect(object, QtCore.SIGNAL("displayNewMessage(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"), self.displayNewMessage)
|
||||
QtCore.QObject.connect(object, QtCore.SIGNAL("updateSentItemStatusByHash(PyQt_PyObject,PyQt_PyObject)"), self.updateSentItemStatusByHash)
|
||||
QtCore.QObject.connect(object, QtCore.SIGNAL("updateSentItemStatusByAckdata(PyQt_PyObject,PyQt_PyObject)"), self.updateSentItemStatusByAckdata)
|
||||
QtCore.QObject.connect(object, QtCore.SIGNAL("updateNetworkStatusTab(PyQt_PyObject,PyQt_PyObject)"), self.updateNetworkStatusTab)
|
||||
QtCore.QObject.connect(object, QtCore.SIGNAL("incrementNumberOfMessagesProcessed()"), self.incrementNumberOfMessagesProcessed)
|
||||
QtCore.QObject.connect(object, QtCore.SIGNAL("incrementNumberOfPubkeysProcessed()"), self.incrementNumberOfPubkeysProcessed)
|
||||
QtCore.QObject.connect(object, QtCore.SIGNAL("incrementNumberOfBroadcastsProcessed()"), self.incrementNumberOfBroadcastsProcessed)
|
||||
QtCore.QObject.connect(object, QtCore.SIGNAL("setStatusIcon(PyQt_PyObject)"), self.setStatusIcon)
|
||||
|
||||
def displayNewMessage(self,inventoryHash,toAddress,fromAddress,subject,message):
|
||||
'''print 'test signals displayNewMessage'
|
||||
print 'toAddress', toAddress
|
||||
print 'fromAddress', fromAddress
|
||||
print 'message', message'''
|
||||
|
||||
fromLabel = ''
|
||||
sqlLock.acquire()
|
||||
t = (fromAddress,)
|
||||
sqlSubmitQueue.put('''select label from addressbook where address=?''')
|
||||
sqlSubmitQueue.put(t)
|
||||
queryreturn = sqlReturnQueue.get()
|
||||
sqlLock.release()
|
||||
if queryreturn <> []:
|
||||
for row in queryreturn:
|
||||
fromLabel, = row
|
||||
else:
|
||||
#There might be a label in the subscriptions table
|
||||
sqlLock.acquire()
|
||||
t = (fromAddress,)
|
||||
sqlSubmitQueue.put('''select label from subscriptions where address=?''')
|
||||
sqlSubmitQueue.put(t)
|
||||
queryreturn = sqlReturnQueue.get()
|
||||
sqlLock.release()
|
||||
if queryreturn <> []:
|
||||
for row in queryreturn:
|
||||
fromLabel, = row
|
||||
|
||||
try:
|
||||
if toAddress == '[Broadcast subscribers]':
|
||||
toLabel = '[Broadcast subscribers]'
|
||||
else:
|
||||
toLabel = config.get(toAddress, 'label')
|
||||
except:
|
||||
toLabel = ''
|
||||
if toLabel == '':
|
||||
toLabel = toAddress
|
||||
|
||||
#msgid, toaddress, fromaddress, subject, received, message = row
|
||||
newItem = QtGui.QTableWidgetItem(unicode(toLabel,'utf-8'))
|
||||
newItem.setData(Qt.UserRole,str(toAddress))
|
||||
self.ui.tableWidgetInbox.insertRow(0)
|
||||
self.ui.tableWidgetInbox.setItem(0,0,newItem)
|
||||
|
||||
if fromLabel == '':
|
||||
newItem = QtGui.QTableWidgetItem(unicode(fromAddress,'utf-8'))
|
||||
if config.getboolean('bitmessagesettings', 'showtraynotifications'):
|
||||
self.trayIcon.showMessage('New Message', 'New message from '+ fromAddress, 1, 2000)
|
||||
else:
|
||||
newItem = QtGui.QTableWidgetItem(unicode(fromLabel,'utf-8'))
|
||||
if config.getboolean('bitmessagesettings', 'showtraynotifications'):
|
||||
self.trayIcon.showMessage('New Message', 'New message from '+fromLabel, 1, 2000)
|
||||
newItem.setData(Qt.UserRole,str(fromAddress))
|
||||
self.ui.tableWidgetInbox.setItem(0,1,newItem)
|
||||
newItem = QtGui.QTableWidgetItem(unicode(subject,'utf-8)'))
|
||||
newItem.setData(Qt.UserRole,unicode(message,'utf-8)'))
|
||||
self.ui.tableWidgetInbox.setItem(0,2,newItem)
|
||||
newItem = QtGui.QTableWidgetItem(strftime(config.get('bitmessagesettings', 'timeformat'),localtime(int(time.time()))))
|
||||
newItem.setData(Qt.UserRole,inventoryHash)
|
||||
self.ui.tableWidgetInbox.setItem(0,3,newItem)
|
||||
|
||||
self.ui.textEditInboxMessage.setText(self.ui.tableWidgetInbox.item(0,2).data(Qt.UserRole).toPyObject())
|
||||
|
||||
|
||||
def click_pushButtonAddAddressBook(self):
|
||||
print 'click_pushButtonAddAddressBook'
|
||||
self.NewSubscriptionDialogInstance = NewSubscriptionDialog(self)
|
||||
|
||||
if self.NewSubscriptionDialogInstance.exec_():
|
||||
if self.NewSubscriptionDialogInstance.ui.labelSubscriptionAddressCheck.text() == 'Address is valid.':
|
||||
#First we must check to see if the address is already in the address book. The user cannot add it again or else it will cause problems when updating and deleting the entry.
|
||||
sqlLock.acquire()
|
||||
t = (str(self.NewSubscriptionDialogInstance.ui.lineEditSubscriptionAddress.text()),)
|
||||
sqlSubmitQueue.put('''select * from addressbook where address=?''')
|
||||
sqlSubmitQueue.put(t)
|
||||
queryreturn = sqlReturnQueue.get()
|
||||
sqlLock.release()
|
||||
if queryreturn == []:
|
||||
self.ui.tableWidgetAddressBook.insertRow(0)
|
||||
newItem = QtGui.QTableWidgetItem(unicode(self.NewSubscriptionDialogInstance.ui.newsubscriptionlabel.text().toUtf8(),'utf-8'))
|
||||
self.ui.tableWidgetAddressBook.setItem(0,0,newItem)
|
||||
newItem = QtGui.QTableWidgetItem(self.NewSubscriptionDialogInstance.ui.lineEditSubscriptionAddress.text())
|
||||
newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled )
|
||||
self.ui.tableWidgetAddressBook.setItem(0,1,newItem)
|
||||
t = (str(self.NewSubscriptionDialogInstance.ui.newsubscriptionlabel.text().toUtf8()),str(self.NewSubscriptionDialogInstance.ui.lineEditSubscriptionAddress.text()))
|
||||
sqlLock.acquire()
|
||||
sqlSubmitQueue.put('''INSERT INTO addressbook VALUES (?,?)''')
|
||||
sqlSubmitQueue.put(t)
|
||||
queryreturn = sqlReturnQueue.get()
|
||||
sqlLock.release()
|
||||
self.rerenderInboxFromLabels()
|
||||
else:
|
||||
self.statusBar().showMessage('Error: You cannot add the same address to your address book twice. Try renaming the existing one if you want.')
|
||||
else:
|
||||
self.statusBar().showMessage('The address you entered was invalid. Ignoring it.')
|
||||
|
||||
def click_pushButtonAddSubscription(self):
|
||||
print 'click_pushButtonAddSubscription'
|
||||
self.NewSubscriptionDialogInstance = NewSubscriptionDialog(self)
|
||||
|
||||
if self.NewSubscriptionDialogInstance.exec_():
|
||||
if self.NewSubscriptionDialogInstance.ui.labelSubscriptionAddressCheck.text() == 'Address is valid.':
|
||||
#First we must check to see if the address is already in the address book. The user cannot add it again or else it will cause problems when updating and deleting the entry.
|
||||
sqlLock.acquire()
|
||||
t = (str(self.NewSubscriptionDialogInstance.ui.lineEditSubscriptionAddress.text()),)
|
||||
sqlSubmitQueue.put('''select * from subscriptions where address=?''')
|
||||
sqlSubmitQueue.put(t)
|
||||
queryreturn = sqlReturnQueue.get()
|
||||
sqlLock.release()
|
||||
if queryreturn == []:
|
||||
self.ui.tableWidgetSubscriptions.insertRow(0)
|
||||
newItem = QtGui.QTableWidgetItem(unicode(self.NewSubscriptionDialogInstance.ui.newsubscriptionlabel.text().toUtf8(),'utf-8'))
|
||||
self.ui.tableWidgetSubscriptions.setItem(0,0,newItem)
|
||||
newItem = QtGui.QTableWidgetItem(self.NewSubscriptionDialogInstance.ui.lineEditSubscriptionAddress.text())
|
||||
newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled )
|
||||
self.ui.tableWidgetSubscriptions.setItem(0,1,newItem)
|
||||
t = (str(self.NewSubscriptionDialogInstance.ui.newsubscriptionlabel.text().toUtf8()),str(self.NewSubscriptionDialogInstance.ui.lineEditSubscriptionAddress.text()),True)
|
||||
sqlLock.acquire()
|
||||
sqlSubmitQueue.put('''INSERT INTO subscriptions VALUES (?,?,?)''')
|
||||
sqlSubmitQueue.put(t)
|
||||
queryreturn = sqlReturnQueue.get()
|
||||
sqlLock.release()
|
||||
self.rerenderInboxFromLabels()
|
||||
self.reloadBroadcastSendersForWhichImWatching()
|
||||
else:
|
||||
self.statusBar().showMessage('Error: You cannot add the same address to your subsciptions twice. Perhaps rename the existing one if you want.')
|
||||
else:
|
||||
self.statusBar().showMessage('The address you entered was invalid. Ignoring it.')
|
||||
|
||||
def loadBlackWhiteList(self):
|
||||
#Initialize the Blacklist or Whitelist table
|
||||
listType = config.get('bitmessagesettings', 'blackwhitelist')
|
||||
if listType == 'black':
|
||||
sqlSubmitQueue.put('''SELECT label, address FROM blacklist''')
|
||||
else:
|
||||
sqlSubmitQueue.put('''SELECT label, address FROM whitelist''')
|
||||
sqlSubmitQueue.put('')
|
||||
queryreturn = sqlReturnQueue.get()
|
||||
for row in queryreturn:
|
||||
label, address = row
|
||||
self.ui.tableWidgetBlacklist.insertRow(0)
|
||||
newItem = QtGui.QTableWidgetItem(unicode(label,'utf-8'))
|
||||
self.ui.tableWidgetBlacklist.setItem(0,0,newItem)
|
||||
newItem = QtGui.QTableWidgetItem(address)
|
||||
newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled )
|
||||
self.ui.tableWidgetBlacklist.setItem(0,1,newItem)
|
||||
|
||||
def click_pushButtonStatusIcon(self):
|
||||
print 'click_pushButtonStatusIcon'
|
||||
self.iconGlossaryInstance = iconGlossaryDialog(self)
|
||||
if self.iconGlossaryInstance.exec_():
|
||||
pass
|
||||
|
||||
def click_actionHelp(self):
|
||||
self.helpDialogInstance = helpDialog(self)
|
||||
self.helpDialogInstance.exec_()
|
||||
|
||||
def click_actionAbout(self):
|
||||
self.aboutDialogInstance = aboutDialog(self)
|
||||
self.aboutDialogInstance.exec_()
|
||||
|
||||
def click_actionSettings(self):
|
||||
self.settingsDialogInstance = settingsDialog(self)
|
||||
if self.settingsDialogInstance.exec_():
|
||||
config.set('bitmessagesettings', 'startonlogon', str(self.settingsDialogInstance.ui.checkBoxStartOnLogon.isChecked()))
|
||||
config.set('bitmessagesettings', 'minimizetotray', str(self.settingsDialogInstance.ui.checkBoxMinimizeToTray.isChecked()))
|
||||
config.set('bitmessagesettings', 'showtraynotifications', str(self.settingsDialogInstance.ui.checkBoxShowTrayNotifications.isChecked()))
|
||||
config.set('bitmessagesettings', 'startintray', str(self.settingsDialogInstance.ui.checkBoxStartInTray.isChecked()))
|
||||
if int(config.get('bitmessagesettings','port')) != int(self.settingsDialogInstance.ui.lineEditTCPPort.text()):
|
||||
QMessageBox.about(self, "Restart", "You must restart Bitmessage for the port number change to take effect.")
|
||||
config.set('bitmessagesettings', 'port', str(self.settingsDialogInstance.ui.lineEditTCPPort.text()))
|
||||
with open(appdata + 'keys.dat', 'wb') as configfile:
|
||||
config.write(configfile)
|
||||
|
||||
if 'win' in sys.platform:
|
||||
#Auto-startup for Windows
|
||||
RUN_PATH = "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run"
|
||||
self.settings = QSettings(RUN_PATH, QSettings.NativeFormat)
|
||||
if config.getboolean('bitmessagesettings', 'startonlogon'):
|
||||
self.settings.setValue("PyBitmessage",sys.argv[0])
|
||||
else:
|
||||
self.settings.remove("PyBitmessage")
|
||||
elif 'darwin' in sys.platform:
|
||||
#startup for mac
|
||||
pass
|
||||
elif 'linux' in sys.platform:
|
||||
#startup for linux
|
||||
pass
|
||||
|
||||
def click_radioButtonBlacklist(self):
|
||||
if config.get('bitmessagesettings', 'blackwhitelist') == 'white':
|
||||
config.set('bitmessagesettings','blackwhitelist','black')
|
||||
with open(appdata + 'keys.dat', 'wb') as configfile:
|
||||
config.write(configfile)
|
||||
#self.ui.tableWidgetBlacklist.clearContents()
|
||||
self.ui.tableWidgetBlacklist.setRowCount(0)
|
||||
self.loadBlackWhiteList()
|
||||
self.ui.tabWidget.setTabText(6,'Blacklist')
|
||||
|
||||
|
||||
def click_radioButtonWhitelist(self):
|
||||
if config.get('bitmessagesettings', 'blackwhitelist') == 'black':
|
||||
config.set('bitmessagesettings','blackwhitelist','white')
|
||||
with open(appdata + 'keys.dat', 'wb') as configfile:
|
||||
config.write(configfile)
|
||||
#self.ui.tableWidgetBlacklist.clearContents()
|
||||
self.ui.tableWidgetBlacklist.setRowCount(0)
|
||||
self.loadBlackWhiteList()
|
||||
self.ui.tabWidget.setTabText(6,'Whitelist')
|
||||
|
||||
def click_pushButtonAddBlacklist(self):
|
||||
print 'click_pushButtonAddBlacklist'
|
||||
self.NewBlacklistDialogInstance = NewSubscriptionDialog(self)
|
||||
|
||||
if self.NewBlacklistDialogInstance.exec_():
|
||||
if self.NewBlacklistDialogInstance.ui.labelSubscriptionAddressCheck.text() == 'Address is valid.':
|
||||
#First we must check to see if the address is already in the address book. The user cannot add it again or else it will cause problems when updating and deleting the entry.
|
||||
sqlLock.acquire()
|
||||
t = (str(self.NewBlacklistDialogInstance.ui.lineEditSubscriptionAddress.text()),)
|
||||
if config.get('bitmessagesettings', 'blackwhitelist') == 'black':
|
||||
sqlSubmitQueue.put('''select * from blacklist where address=?''')
|
||||
else:
|
||||
sqlSubmitQueue.put('''select * from whitelist where address=?''')
|
||||
sqlSubmitQueue.put(t)
|
||||
queryreturn = sqlReturnQueue.get()
|
||||
sqlLock.release()
|
||||
if queryreturn == []:
|
||||
self.ui.tableWidgetBlacklist.insertRow(0)
|
||||
newItem = QtGui.QTableWidgetItem(unicode(self.NewBlacklistDialogInstance.ui.newsubscriptionlabel.text().toUtf8(),'utf-8'))
|
||||
self.ui.tableWidgetBlacklist.setItem(0,0,newItem)
|
||||
newItem = QtGui.QTableWidgetItem(self.NewBlacklistDialogInstance.ui.lineEditSubscriptionAddress.text())
|
||||
newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled )
|
||||
self.ui.tableWidgetBlacklist.setItem(0,1,newItem)
|
||||
t = (str(self.NewBlacklistDialogInstance.ui.newsubscriptionlabel.text().toUtf8()),str(self.NewBlacklistDialogInstance.ui.lineEditSubscriptionAddress.text()),True)
|
||||
sqlLock.acquire()
|
||||
if config.get('bitmessagesettings', 'blackwhitelist') == 'black':
|
||||
sqlSubmitQueue.put('''INSERT INTO blacklist VALUES (?,?,?)''')
|
||||
else:
|
||||
sqlSubmitQueue.put('''INSERT INTO whitelist VALUES (?,?,?)''')
|
||||
sqlSubmitQueue.put(t)
|
||||
queryreturn = sqlReturnQueue.get()
|
||||
sqlLock.release()
|
||||
else:
|
||||
self.statusBar().showMessage('Error: You cannot add the same address to your list twice. Perhaps rename the existing one if you want.')
|
||||
else:
|
||||
self.statusBar().showMessage('The address you entered was invalid. Ignoring it.')
|
||||
|
||||
|
||||
def click_NewAddressDialog(self):
|
||||
print 'click_buttondialog'
|
||||
self.dialog = NewAddressDialog(self)
|
||||
|
||||
# For Modal dialogs
|
||||
if self.dialog.exec_():
|
||||
self.dialog.ui.buttonBox.enabled = False
|
||||
if self.dialog.ui.radioButtonMostAvailable.isChecked():
|
||||
#self.generateAndStoreAnAddress(1)
|
||||
streamNumberForAddress = 1
|
||||
|
||||
|
||||
else:
|
||||
#User selected 'Use the same stream as an existing address.'
|
||||
streamNumberForAddress = addressStream(self.dialog.ui.comboBoxExisting.currentText())
|
||||
|
||||
self.addressGenerator = addressGenerator()
|
||||
self.addressGenerator.setup(streamNumberForAddress,str(self.dialog.ui.newaddresslabel.text().toUtf8()))
|
||||
|
||||
QtCore.QObject.connect(self.addressGenerator, SIGNAL("writeNewAddressToTable(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"), self.writeNewAddressToTable)
|
||||
QtCore.QObject.connect(self.addressGenerator, QtCore.SIGNAL("updateStatusBar(PyQt_PyObject)"), self.updateStatusBar)
|
||||
|
||||
|
||||
self.addressGenerator.start()
|
||||
else:
|
||||
print 'rejected'
|
||||
|
||||
def closeEvent(self, event):
|
||||
broadcastToSendDataQueues((0, 'shutdown', 'all'))
|
||||
|
||||
print 'Closing. Flushing inventory in memory out to disk...'
|
||||
self.statusBar().showMessage('Flushing inventory in memory out to disk.')
|
||||
flushInventory()
|
||||
|
||||
'''quit_msg = "Are you sure you want to exit Bitmessage?"
|
||||
reply = QtGui.QMessageBox.question(self, 'Message',
|
||||
quit_msg, QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
|
||||
|
||||
if reply == QtGui.QMessageBox.Yes:
|
||||
event.accept()
|
||||
else:
|
||||
event.ignore()'''
|
||||
|
||||
#This one last useless query will guarantee that the previous query committed before we close the program.
|
||||
sqlLock.acquire()
|
||||
sqlSubmitQueue.put('SELECT address FROM subscriptions')
|
||||
sqlSubmitQueue.put('')
|
||||
sqlReturnQueue.get()
|
||||
sqlLock.release()
|
||||
|
||||
self.statusBar().showMessage('Saving the knownNodes list of peers to disk...')
|
||||
output = open(appdata + 'knownnodes.dat', 'wb')
|
||||
pickle.dump(knownNodes, output)
|
||||
output.close()
|
||||
|
||||
self.trayIcon.hide()
|
||||
print 'Done.'
|
||||
self.statusBar().showMessage('All done. Closing user interface...')
|
||||
event.accept()
|
||||
raise SystemExit
|
||||
|
||||
|
||||
def on_action_Reply(self):
|
||||
currentInboxRow = self.ui.tableWidgetInbox.currentRow()
|
||||
toAddressAtCurrentInboxRow = str(self.ui.tableWidgetInbox.item(currentInboxRow,0).data(Qt.UserRole).toPyObject())
|
||||
fromAddressAtCurrentInboxRow = str(self.ui.tableWidgetInbox.item(currentInboxRow,1).data(Qt.UserRole).toPyObject())
|
||||
if not config.get(toAddressAtCurrentInboxRow,'enabled'):
|
||||
self.statusBar().showMessage('Error: The address from which you are trying to send is disabled. Enable it from the \'Your Identities\' tab first.')
|
||||
return
|
||||
self.ui.lineEditTo.setText(str(fromAddressAtCurrentInboxRow))
|
||||
self.ui.labelFrom.setText(toAddressAtCurrentInboxRow)
|
||||
self.ui.comboBoxSendFrom.setEditText(str(self.ui.tableWidgetInbox.item(currentInboxRow,0).text))
|
||||
self.ui.tabWidget.setCurrentIndex(1)
|
||||
|
||||
def on_action_addSenderToAddressBook(self):
|
||||
currentInboxRow = self.ui.tableWidgetInbox.currentRow()
|
||||
#self.ui.tableWidgetInbox.item(currentRow,1).data(Qt.UserRole).toPyObject()
|
||||
addressAtCurrentInboxRow = str(self.ui.tableWidgetInbox.item(currentInboxRow,1).data(Qt.UserRole).toPyObject())
|
||||
#Let's make sure that it isn't already in the address book
|
||||
sqlLock.acquire()
|
||||
t = (addressAtCurrentInboxRow,)
|
||||
sqlSubmitQueue.put('''select * from addressbook where address=?''')
|
||||
sqlSubmitQueue.put(t)
|
||||
queryreturn = sqlReturnQueue.get()
|
||||
sqlLock.release()
|
||||
if queryreturn == []:
|
||||
self.ui.tableWidgetAddressBook.insertRow(0)
|
||||
newItem = QtGui.QTableWidgetItem('--New entry. Change label in Address Book.--')
|
||||
self.ui.tableWidgetAddressBook.setItem(0,0,newItem)
|
||||
newItem = QtGui.QTableWidgetItem(addressAtCurrentInboxRow)
|
||||
newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled )
|
||||
self.ui.tableWidgetAddressBook.setItem(0,1,newItem)
|
||||
t = ('--New entry. Change label in Address Book.--',addressAtCurrentInboxRow)
|
||||
sqlLock.acquire()
|
||||
sqlSubmitQueue.put('''INSERT INTO addressbook VALUES (?,?)''')
|
||||
sqlSubmitQueue.put(t)
|
||||
queryreturn = sqlReturnQueue.get()
|
||||
sqlLock.release()
|
||||
self.ui.tabWidget.setCurrentIndex(5)
|
||||
self.ui.tableWidgetAddressBook.setCurrentCell(0,0)
|
||||
self.statusBar().showMessage('Entry added to the Address Book. Edit the label to your liking.')
|
||||
else:
|
||||
self.statusBar().showMessage('Error: You cannot add the same address to your address book twice. Try renaming the existing one if you want.')
|
||||
|
||||
def on_action_InboxTrash(self):
|
||||
currentRow = self.ui.tableWidgetInbox.currentRow()
|
||||
inventoryHashToTrash = str(self.ui.tableWidgetInbox.item(currentRow,3).data(Qt.UserRole).toPyObject())
|
||||
t = (inventoryHashToTrash,)
|
||||
sqlLock.acquire()
|
||||
#sqlSubmitQueue.put('''delete from inbox where msgid=?''')
|
||||
sqlSubmitQueue.put('''UPDATE inbox SET folder='trash' WHERE msgid=?''')
|
||||
sqlSubmitQueue.put(t)
|
||||
sqlReturnQueue.get()
|
||||
sqlLock.release()
|
||||
self.ui.tableWidgetInbox.removeRow(currentRow)
|
||||
self.statusBar().showMessage('Moved item to trash. There is no user interface to view your trash, but it is still on disk if you are desperate to get it back.')
|
||||
|
||||
#Group of functions for the Address Book dialog box
|
||||
def on_action_AddressBookNew(self):
|
||||
self.click_pushButtonAddAddressBook()
|
||||
def on_action_AddressBookDelete(self):
|
||||
currentRow = self.ui.tableWidgetAddressBook.currentRow()
|
||||
labelAtCurrentRow = self.ui.tableWidgetAddressBook.item(currentRow,0).text().toUtf8()
|
||||
addressAtCurrentRow = self.ui.tableWidgetAddressBook.item(currentRow,1).text()
|
||||
t = (str(labelAtCurrentRow),str(addressAtCurrentRow))
|
||||
sqlLock.acquire()
|
||||
sqlSubmitQueue.put('''DELETE FROM addressbook WHERE label=? AND address=?''')
|
||||
sqlSubmitQueue.put(t)
|
||||
queryreturn = sqlReturnQueue.get()
|
||||
sqlLock.release()
|
||||
self.ui.tableWidgetAddressBook.removeRow(currentRow)
|
||||
self.rerenderInboxFromLabels()
|
||||
self.rerenderSentToLabels()
|
||||
self.reloadBroadcastSendersForWhichImWatching()
|
||||
def on_action_AddressBookClipboard(self):
|
||||
currentRow = self.ui.tableWidgetAddressBook.currentRow()
|
||||
addressAtCurrentRow = self.ui.tableWidgetAddressBook.item(currentRow,1).text()
|
||||
clipboard = QtGui.QApplication.clipboard()
|
||||
clipboard.setText(str(addressAtCurrentRow))
|
||||
def on_action_AddressBookSend(self):
|
||||
currentRow = self.ui.tableWidgetAddressBook.currentRow()
|
||||
addressAtCurrentRow = self.ui.tableWidgetAddressBook.item(currentRow,1).text()
|
||||
if self.ui.lineEditTo.text() == '':
|
||||
self.ui.lineEditTo.setText(str(addressAtCurrentRow))
|
||||
else:
|
||||
self.ui.lineEditTo.setText(str(self.ui.lineEditTo.text()) + '; '+ str(addressAtCurrentRow))
|
||||
self.statusBar().showMessage('You have added the address to the \'To\' field on the \'Send\' tab. You may add more recipients if you want. When you are done, go to the \'Send\' tab.')
|
||||
def on_context_menuAddressBook(self, point):
|
||||
self.popMenuAddressBook.exec_( self.ui.tableWidgetAddressBook.mapToGlobal(point) )
|
||||
|
||||
|
||||
#Group of functions for the Subscriptions dialog box
|
||||
def on_action_SubscriptionsNew(self):
|
||||
self.click_pushButtonAddSubscription()
|
||||
def on_action_SubscriptionsDelete(self):
|
||||
print 'clicked Delete'
|
||||
currentRow = self.ui.tableWidgetSubscriptions.currentRow()
|
||||
labelAtCurrentRow = self.ui.tableWidgetSubscriptions.item(currentRow,0).text().toUtf8()
|
||||
addressAtCurrentRow = self.ui.tableWidgetSubscriptions.item(currentRow,1).text()
|
||||
t = (str(labelAtCurrentRow),str(addressAtCurrentRow))
|
||||
sqlLock.acquire()
|
||||
sqlSubmitQueue.put('''DELETE FROM subscriptions WHERE label=? AND address=?''')
|
||||
sqlSubmitQueue.put(t)
|
||||
sqlReturnQueue.get()
|
||||
sqlLock.release()
|
||||
self.ui.tableWidgetSubscriptions.removeRow(currentRow)
|
||||
self.rerenderInboxFromLabels()
|
||||
def on_action_SubscriptionsClipboard(self):
|
||||
currentRow = self.ui.tableWidgetSubscriptions.currentRow()
|
||||
addressAtCurrentRow = self.ui.tableWidgetSubscriptions.item(currentRow,1).text()
|
||||
clipboard = QtGui.QApplication.clipboard()
|
||||
clipboard.setText(str(addressAtCurrentRow))
|
||||
def on_context_menuSubscriptions(self, point):
|
||||
self.popMenuSubscriptions.exec_( self.ui.tableWidgetSubscriptions.mapToGlobal(point) )
|
||||
|
||||
|
||||
#Group of functions for the Your Identities dialog box
|
||||
def on_action_new(self):
|
||||
self.click_NewAddressDialog()
|
||||
def on_action_enable(self):
|
||||
currentRow = self.ui.tableWidgetYourIdentities.currentRow()
|
||||
addressAtCurrentRow = self.ui.tableWidgetYourIdentities.item(currentRow,1).text()
|
||||
config.set(str(addressAtCurrentRow),'enabled','true')
|
||||
with open(appdata + 'keys.dat', 'wb') as configfile:
|
||||
config.write(configfile)
|
||||
self.ui.tableWidgetYourIdentities.item(currentRow,0).setTextColor(QtGui.QColor(0,0,0))
|
||||
self.ui.tableWidgetYourIdentities.item(currentRow,1).setTextColor(QtGui.QColor(0,0,0))
|
||||
self.ui.tableWidgetYourIdentities.item(currentRow,2).setTextColor(QtGui.QColor(0,0,0))
|
||||
self.reloadMyAddressHashes()
|
||||
def on_action_disable(self):
|
||||
currentRow = self.ui.tableWidgetYourIdentities.currentRow()
|
||||
addressAtCurrentRow = self.ui.tableWidgetYourIdentities.item(currentRow,1).text()
|
||||
config.set(str(addressAtCurrentRow),'enabled','false')
|
||||
self.ui.tableWidgetYourIdentities.item(currentRow,0).setTextColor(QtGui.QColor(128,128,128))
|
||||
self.ui.tableWidgetYourIdentities.item(currentRow,1).setTextColor(QtGui.QColor(128,128,128))
|
||||
self.ui.tableWidgetYourIdentities.item(currentRow,2).setTextColor(QtGui.QColor(128,128,128))
|
||||
with open(appdata + 'keys.dat', 'wb') as configfile:
|
||||
config.write(configfile)
|
||||
self.reloadMyAddressHashes()
|
||||
def on_action_clipboard(self):
|
||||
currentRow = self.ui.tableWidgetYourIdentities.currentRow()
|
||||
addressAtCurrentRow = self.ui.tableWidgetYourIdentities.item(currentRow,1).text()
|
||||
clipboard = QtGui.QApplication.clipboard()
|
||||
clipboard.setText(str(addressAtCurrentRow))
|
||||
def on_context_menuYourIdentities(self, point):
|
||||
self.popMenu.exec_( self.ui.tableWidgetYourIdentities.mapToGlobal(point) )
|
||||
def on_context_menuInbox(self, point):
|
||||
self.popMenuInbox.exec_( self.ui.tableWidgetInbox.mapToGlobal(point) )
|
||||
|
||||
def tableWidgetInboxItemClicked(self):
|
||||
currentRow = self.ui.tableWidgetInbox.currentRow()
|
||||
self.ui.textEditInboxMessage.setText(self.ui.tableWidgetInbox.item(currentRow,2).data(Qt.UserRole).toPyObject())
|
||||
|
||||
def tableWidgetSentItemClicked(self):
|
||||
currentRow = self.ui.tableWidgetSent.currentRow()
|
||||
self.ui.textEditSentMessage.setText(self.ui.tableWidgetSent.item(currentRow,2).data(Qt.UserRole).toPyObject())
|
||||
|
||||
def tableWidgetYourIdentitiesItemChanged(self):
|
||||
currentRow = self.ui.tableWidgetYourIdentities.currentRow()
|
||||
try:
|
||||
addressAtCurrentRow = self.ui.tableWidgetYourIdentities.item(currentRow,1).text()
|
||||
config.set(str(addressAtCurrentRow),'label',str(self.ui.tableWidgetYourIdentities.item(currentRow,0).text().toUtf8()))
|
||||
with open(appdata + 'keys.dat', 'wb') as configfile:
|
||||
config.write(configfile)
|
||||
except Exception, err:
|
||||
print 'Program Exception in tableWidgetYourIdentitiesItemChanged:', err
|
||||
self.rerenderComboBoxSendFrom()
|
||||
#self.rerenderInboxFromLabels()
|
||||
self.rerenderInboxToLabels()
|
||||
self.rerenderSentFromLabels()
|
||||
#self.rerenderSentToLabels()
|
||||
|
||||
def tableWidgetAddressBookItemChanged(self):
|
||||
currentRow = self.ui.tableWidgetAddressBook.currentRow()
|
||||
sqlLock.acquire()
|
||||
try:
|
||||
addressAtCurrentRow = self.ui.tableWidgetAddressBook.item(currentRow,1).text()
|
||||
t = (str(self.ui.tableWidgetAddressBook.item(currentRow,0).text().toUtf8()),str(addressAtCurrentRow))
|
||||
sqlSubmitQueue.put('''UPDATE addressbook set label=? WHERE address=?''')
|
||||
sqlSubmitQueue.put(t)
|
||||
sqlReturnQueue.get()
|
||||
except Exception, err:
|
||||
print 'Program Exception in tableWidgetAddressBookItemChanged:', err
|
||||
sqlLock.release()
|
||||
self.rerenderInboxFromLabels()
|
||||
self.rerenderSentToLabels()
|
||||
|
||||
def tableWidgetSubscriptionsItemChanged(self):
|
||||
currentRow = self.ui.tableWidgetSubscriptions.currentRow()
|
||||
sqlLock.acquire()
|
||||
try:
|
||||
addressAtCurrentRow = self.ui.tableWidgetSubscriptions.item(currentRow,1).text()
|
||||
t = (str(self.ui.tableWidgetSubscriptions.item(currentRow,0).text().toUtf8()),str(addressAtCurrentRow))
|
||||
sqlSubmitQueue.put('''UPDATE subscriptions set label=? WHERE address=?''')
|
||||
sqlSubmitQueue.put(t)
|
||||
sqlReturnQueue.get()
|
||||
except Exception, err:
|
||||
print 'Program Exception in tableWidgetSubscriptionsItemChanged:', err
|
||||
sqlLock.release()
|
||||
self.rerenderInboxFromLabels()
|
||||
self.rerenderSentToLabels()
|
||||
|
||||
|
||||
def writeNewAddressToTable(self,label,address,streamNumber):
|
||||
self.ui.tableWidgetYourIdentities.insertRow(0)
|
||||
self.ui.tableWidgetYourIdentities.setItem(0, 0, QtGui.QTableWidgetItem(unicode(label,'utf-8')))
|
||||
newItem = QtGui.QTableWidgetItem(address)
|
||||
newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled )
|
||||
self.ui.tableWidgetYourIdentities.setItem(0, 1, newItem)
|
||||
newItem = QtGui.QTableWidgetItem(streamNumber)
|
||||
newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled )
|
||||
self.ui.tableWidgetYourIdentities.setItem(0, 2, newItem)
|
||||
self.rerenderComboBoxSendFrom()
|
||||
self.reloadMyAddressHashes()
|
||||
|
||||
def updateStatusBar(self,data):
|
||||
print 'Status bar!', data
|
||||
self.statusBar().showMessage(data)
|
||||
|
||||
def reloadMyAddressHashes(self):
|
||||
print 'reloading my address hashes'
|
||||
myAddressHashes.clear()
|
||||
#myPrivateKeys.clear()
|
||||
configSections = config.sections()
|
||||
for addressInKeysFile in configSections:
|
||||
if addressInKeysFile <> 'bitmessagesettings':
|
||||
isEnabled = config.getboolean(addressInKeysFile, 'enabled')
|
||||
if isEnabled:
|
||||
status,addressVersionNumber,streamNumber,hash = decodeAddress(addressInKeysFile)
|
||||
n = config.getint(addressInKeysFile, 'n')
|
||||
e = config.getint(addressInKeysFile, 'e')
|
||||
d = config.getint(addressInKeysFile, 'd')
|
||||
p = config.getint(addressInKeysFile, 'p')
|
||||
q = config.getint(addressInKeysFile, 'q')
|
||||
myAddressHashes[hash] = rsa.PrivateKey(n,e,d,p,q)
|
||||
|
||||
def reloadBroadcastSendersForWhichImWatching(self):
|
||||
broadcastSendersForWhichImWatching.clear()
|
||||
sqlLock.acquire()
|
||||
sqlSubmitQueue.put('SELECT address FROM subscriptions')
|
||||
sqlSubmitQueue.put('')
|
||||
queryreturn = sqlReturnQueue.get()
|
||||
sqlLock.release()
|
||||
for row in queryreturn:
|
||||
address, = row
|
||||
status,addressVersionNumber,streamNumber,hash = decodeAddress(address)
|
||||
broadcastSendersForWhichImWatching[hash] = 0
|
||||
|
||||
|
||||
|
||||
sendDataQueues = [] #each sendData thread puts its queue in this list.
|
||||
myAddressHashes = {}
|
||||
#myPrivateKeys = {}
|
||||
inventory = {} #of objects (like msg payloads and pubkey payloads) Does not include protocol headers (the first 24 bytes of each packet).
|
||||
workerQueue = Queue.Queue()
|
||||
sqlSubmitQueue = Queue.Queue() #SQLITE3 is so thread-unsafe that they won't even let you call it from different threads using your own locks. SQL objects can only be called from one thread.
|
||||
sqlReturnQueue = Queue.Queue()
|
||||
sqlLock = threading.Lock()
|
||||
printLock = threading.Lock()
|
||||
ackdataForWhichImWatching = {}
|
||||
broadcastSendersForWhichImWatching = {}
|
||||
statusIconColor = 'red'
|
||||
connectionsCount = {} #Used for the 'network status' tab.
|
||||
connectionsCountLock = threading.Lock()
|
||||
eightBytesOfRandomDataUsedToDetectConnectionsToSelf = pack('>Q',random.randrange(1, 18446744073709551615))
|
||||
connectedHostsList = {} #List of hosts to which we are connected. Used to guarantee that the outgoingSynSender thread won't connect to the same remote node twice.
|
||||
neededPubkeys = {}
|
||||
|
||||
#These constants are not at the top because if changed they will cause particularly unexpected behavior
|
||||
averageProofOfWorkNonceTrialsPerByte = 2 #The amount of work that should be performed (and demanded) per byte of the payload. Double this number to double the work.
|
||||
payloadLengthExtraBytes = 1 #To make sending short messages a little more difficult, this value is added to the payload length for use in calculating the proof of work target.
|
||||
|
||||
if __name__ == "__main__":
|
||||
major, minor, revision = sqlite3.sqlite_version_info
|
||||
if major < 3:
|
||||
print 'This program requires sqlite version 3 or higher because 2 and lower cannot store NULL values. I see version:', sqlite3.sqlite_version_info
|
||||
sys.exit()
|
||||
|
||||
APPNAME = "PyBitmessage"
|
||||
from os import path, environ
|
||||
if sys.platform == 'darwin':
|
||||
from AppKit import NSSearchPathForDirectoriesInDomains
|
||||
# http://developer.apple.com/DOCUMENTATION/Cocoa/Reference/Foundation/Miscellaneous/Foundation_Functions/Reference/reference.html#//apple_ref/c/func/NSSearchPathForDirectoriesInDomains
|
||||
# NSApplicationSupportDirectory = 14
|
||||
# NSUserDomainMask = 1
|
||||
# True for expanding the tilde into a fully qualified path
|
||||
appdata = path.join(NSSearchPathForDirectoriesInDomains(14, 1, True)[0], APPNAME) + '/'
|
||||
elif 'win' in sys.platform:
|
||||
appdata = path.join(environ['APPDATA'], APPNAME) + '\\'
|
||||
else:
|
||||
appdata = path.expanduser(path.join("~", "." + APPNAME + "/"))
|
||||
|
||||
if not os.path.exists(appdata):
|
||||
os.makedirs(appdata)
|
||||
|
||||
config = ConfigParser.SafeConfigParser()
|
||||
config.read(appdata + 'keys.dat')
|
||||
try:
|
||||
config.get('bitmessagesettings', 'settingsversion')
|
||||
print 'Loading config files from', appdata
|
||||
except:
|
||||
#This appears to be the first time running the program; there is no config file (or it cannot be accessed). Create config and known-nodes file.
|
||||
config.add_section('bitmessagesettings')
|
||||
config.set('bitmessagesettings','settingsversion','1')
|
||||
config.set('bitmessagesettings','bitstrength','2048')
|
||||
config.set('bitmessagesettings','port','8444')
|
||||
config.set('bitmessagesettings','timeformat','%%a, %%d %%b %%Y %%I:%%M %%p')
|
||||
config.set('bitmessagesettings','blackwhitelist','black')
|
||||
config.set('bitmessagesettings','startonlogon','false')
|
||||
config.set('bitmessagesettings','minimizetotray','true')
|
||||
config.set('bitmessagesettings','showtraynotifications','true')
|
||||
config.set('bitmessagesettings','startintray','false')
|
||||
|
||||
|
||||
|
||||
with open(appdata + 'keys.dat', 'wb') as configfile:
|
||||
config.write(configfile)
|
||||
print 'Storing config files in', appdata
|
||||
|
||||
try:
|
||||
pickleFile = open(appdata + 'knownnodes.dat', 'rb')
|
||||
knownNodes = pickle.load(pickleFile)
|
||||
pickleFile.close()
|
||||
except:
|
||||
createDefaultKnownNodes(appdata)
|
||||
pickleFile = open(appdata + 'knownnodes.dat', 'rb')
|
||||
knownNodes = pickle.load(pickleFile)
|
||||
pickleFile.close()
|
||||
|
||||
if config.getint('bitmessagesettings', 'settingsversion') > 1:
|
||||
print 'Bitmessage cannot read future versions of the keys file (keys.dat). Run the newer version of Bitmessage.'
|
||||
raise SystemExit
|
||||
|
||||
|
||||
app = QtGui.QApplication(sys.argv)
|
||||
app.setStyleSheet("QStatusBar::item { border: 0px solid black }")
|
||||
myapp = MyForm()
|
||||
myapp.show()
|
||||
|
||||
if config.getboolean('bitmessagesettings', 'startintray'):
|
||||
myapp.hide()
|
||||
myapp.trayIcon.show()
|
||||
#self.hidden = True
|
||||
#self.setWindowState(self.windowState() & QtCore.Qt.WindowMinimized)
|
||||
#self.hide()
|
||||
if 'win' in sys.platform:
|
||||
myapp.setWindowFlags(Qt.ToolTip)
|
||||
|
||||
sys.exit(app.exec_())
|
507
bitmessageui.py
Normal file
507
bitmessageui.py
Normal file
|
@ -0,0 +1,507 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Form implementation generated from reading ui file 'bitmessageui.ui'
|
||||
#
|
||||
# Created: Thu Nov 15 14:12:54 2012
|
||||
# by: PyQt4 UI code generator 4.9.4
|
||||
#
|
||||
# WARNING! All changes made in this file will be lost!
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
try:
|
||||
_fromUtf8 = QtCore.QString.fromUtf8
|
||||
except AttributeError:
|
||||
_fromUtf8 = lambda s: s
|
||||
|
||||
class Ui_MainWindow(object):
|
||||
def setupUi(self, MainWindow):
|
||||
MainWindow.setObjectName(_fromUtf8("MainWindow"))
|
||||
MainWindow.resize(795, 561)
|
||||
MainWindow.setTabShape(QtGui.QTabWidget.Rounded)
|
||||
self.centralwidget = QtGui.QWidget(MainWindow)
|
||||
self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
|
||||
self.gridLayout = QtGui.QGridLayout(self.centralwidget)
|
||||
self.gridLayout.setMargin(0)
|
||||
self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
|
||||
self.tabWidget = QtGui.QTabWidget(self.centralwidget)
|
||||
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.tabWidget.sizePolicy().hasHeightForWidth())
|
||||
self.tabWidget.setSizePolicy(sizePolicy)
|
||||
self.tabWidget.setMinimumSize(QtCore.QSize(0, 0))
|
||||
self.tabWidget.setBaseSize(QtCore.QSize(0, 0))
|
||||
font = QtGui.QFont()
|
||||
font.setPointSize(9)
|
||||
self.tabWidget.setFont(font)
|
||||
self.tabWidget.setTabPosition(QtGui.QTabWidget.North)
|
||||
self.tabWidget.setTabShape(QtGui.QTabWidget.Rounded)
|
||||
self.tabWidget.setObjectName(_fromUtf8("tabWidget"))
|
||||
self.inbox = QtGui.QWidget()
|
||||
self.inbox.setObjectName(_fromUtf8("inbox"))
|
||||
self.verticalLayout_2 = QtGui.QVBoxLayout(self.inbox)
|
||||
self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2"))
|
||||
self.tableWidgetInbox = QtGui.QTableWidget(self.inbox)
|
||||
self.tableWidgetInbox.setAlternatingRowColors(True)
|
||||
self.tableWidgetInbox.setSelectionMode(QtGui.QAbstractItemView.SingleSelection)
|
||||
self.tableWidgetInbox.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows)
|
||||
self.tableWidgetInbox.setWordWrap(False)
|
||||
self.tableWidgetInbox.setObjectName(_fromUtf8("tableWidgetInbox"))
|
||||
self.tableWidgetInbox.setColumnCount(4)
|
||||
self.tableWidgetInbox.setRowCount(0)
|
||||
item = QtGui.QTableWidgetItem()
|
||||
self.tableWidgetInbox.setHorizontalHeaderItem(0, item)
|
||||
item = QtGui.QTableWidgetItem()
|
||||
self.tableWidgetInbox.setHorizontalHeaderItem(1, item)
|
||||
item = QtGui.QTableWidgetItem()
|
||||
self.tableWidgetInbox.setHorizontalHeaderItem(2, item)
|
||||
item = QtGui.QTableWidgetItem()
|
||||
self.tableWidgetInbox.setHorizontalHeaderItem(3, item)
|
||||
self.tableWidgetInbox.horizontalHeader().setCascadingSectionResizes(True)
|
||||
self.tableWidgetInbox.horizontalHeader().setDefaultSectionSize(200)
|
||||
self.tableWidgetInbox.horizontalHeader().setHighlightSections(False)
|
||||
self.tableWidgetInbox.horizontalHeader().setMinimumSectionSize(27)
|
||||
self.tableWidgetInbox.horizontalHeader().setSortIndicatorShown(False)
|
||||
self.tableWidgetInbox.horizontalHeader().setStretchLastSection(True)
|
||||
self.tableWidgetInbox.verticalHeader().setVisible(False)
|
||||
self.tableWidgetInbox.verticalHeader().setDefaultSectionSize(26)
|
||||
self.verticalLayout_2.addWidget(self.tableWidgetInbox)
|
||||
self.textEditInboxMessage = QtGui.QTextEdit(self.inbox)
|
||||
self.textEditInboxMessage.setBaseSize(QtCore.QSize(0, 500))
|
||||
self.textEditInboxMessage.setObjectName(_fromUtf8("textEditInboxMessage"))
|
||||
self.verticalLayout_2.addWidget(self.textEditInboxMessage)
|
||||
icon = QtGui.QIcon()
|
||||
icon.addPixmap(QtGui.QPixmap(_fromUtf8(":/newPrefix/images/inbox.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||
self.tabWidget.addTab(self.inbox, icon, _fromUtf8(""))
|
||||
self.send = QtGui.QWidget()
|
||||
self.send.setObjectName(_fromUtf8("send"))
|
||||
self.gridLayout_2 = QtGui.QGridLayout(self.send)
|
||||
self.gridLayout_2.setObjectName(_fromUtf8("gridLayout_2"))
|
||||
self.lineEditTo = QtGui.QLineEdit(self.send)
|
||||
self.lineEditTo.setObjectName(_fromUtf8("lineEditTo"))
|
||||
self.gridLayout_2.addWidget(self.lineEditTo, 3, 1, 1, 1)
|
||||
self.label_3 = QtGui.QLabel(self.send)
|
||||
self.label_3.setObjectName(_fromUtf8("label_3"))
|
||||
self.gridLayout_2.addWidget(self.label_3, 4, 0, 1, 1)
|
||||
spacerItem = QtGui.QSpacerItem(20, 297, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
|
||||
self.gridLayout_2.addItem(spacerItem, 6, 0, 1, 1)
|
||||
self.label_2 = QtGui.QLabel(self.send)
|
||||
self.label_2.setObjectName(_fromUtf8("label_2"))
|
||||
self.gridLayout_2.addWidget(self.label_2, 2, 0, 1, 1)
|
||||
self.comboBoxSendFrom = QtGui.QComboBox(self.send)
|
||||
self.comboBoxSendFrom.setObjectName(_fromUtf8("comboBoxSendFrom"))
|
||||
self.gridLayout_2.addWidget(self.comboBoxSendFrom, 2, 1, 1, 1)
|
||||
self.label_4 = QtGui.QLabel(self.send)
|
||||
self.label_4.setObjectName(_fromUtf8("label_4"))
|
||||
self.gridLayout_2.addWidget(self.label_4, 5, 0, 1, 1)
|
||||
self.label = QtGui.QLabel(self.send)
|
||||
self.label.setObjectName(_fromUtf8("label"))
|
||||
self.gridLayout_2.addWidget(self.label, 3, 0, 1, 1)
|
||||
self.radioButtonBroadcast = QtGui.QRadioButton(self.send)
|
||||
self.radioButtonBroadcast.setObjectName(_fromUtf8("radioButtonBroadcast"))
|
||||
self.gridLayout_2.addWidget(self.radioButtonBroadcast, 1, 1, 1, 3)
|
||||
self.pushButtonLoadFromAddressBook = QtGui.QPushButton(self.send)
|
||||
font = QtGui.QFont()
|
||||
font.setPointSize(7)
|
||||
self.pushButtonLoadFromAddressBook.setFont(font)
|
||||
self.pushButtonLoadFromAddressBook.setObjectName(_fromUtf8("pushButtonLoadFromAddressBook"))
|
||||
self.gridLayout_2.addWidget(self.pushButtonLoadFromAddressBook, 3, 2, 1, 2)
|
||||
spacerItem1 = QtGui.QSpacerItem(28, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
|
||||
self.gridLayout_2.addItem(spacerItem1, 6, 6, 1, 1)
|
||||
self.radioButtonSpecific = QtGui.QRadioButton(self.send)
|
||||
self.radioButtonSpecific.setChecked(True)
|
||||
self.radioButtonSpecific.setObjectName(_fromUtf8("radioButtonSpecific"))
|
||||
self.gridLayout_2.addWidget(self.radioButtonSpecific, 0, 1, 1, 1)
|
||||
spacerItem2 = QtGui.QSpacerItem(20, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
|
||||
self.gridLayout_2.addItem(spacerItem2, 3, 4, 1, 1)
|
||||
self.pushButtonSend = QtGui.QPushButton(self.send)
|
||||
self.pushButtonSend.setObjectName(_fromUtf8("pushButtonSend"))
|
||||
self.gridLayout_2.addWidget(self.pushButtonSend, 7, 5, 1, 1)
|
||||
spacerItem3 = QtGui.QSpacerItem(192, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
|
||||
self.gridLayout_2.addItem(spacerItem3, 7, 4, 1, 1)
|
||||
self.lineEditSubject = QtGui.QLineEdit(self.send)
|
||||
self.lineEditSubject.setText(_fromUtf8(""))
|
||||
self.lineEditSubject.setObjectName(_fromUtf8("lineEditSubject"))
|
||||
self.gridLayout_2.addWidget(self.lineEditSubject, 4, 1, 1, 5)
|
||||
self.textEditMessage = QtGui.QTextEdit(self.send)
|
||||
self.textEditMessage.setObjectName(_fromUtf8("textEditMessage"))
|
||||
self.gridLayout_2.addWidget(self.textEditMessage, 5, 1, 2, 5)
|
||||
self.labelFrom = QtGui.QLabel(self.send)
|
||||
self.labelFrom.setText(_fromUtf8(""))
|
||||
self.labelFrom.setObjectName(_fromUtf8("labelFrom"))
|
||||
self.gridLayout_2.addWidget(self.labelFrom, 2, 2, 1, 3)
|
||||
icon1 = QtGui.QIcon()
|
||||
icon1.addPixmap(QtGui.QPixmap(_fromUtf8(":/newPrefix/images/send.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||
self.tabWidget.addTab(self.send, icon1, _fromUtf8(""))
|
||||
self.sent = QtGui.QWidget()
|
||||
self.sent.setObjectName(_fromUtf8("sent"))
|
||||
self.verticalLayout = QtGui.QVBoxLayout(self.sent)
|
||||
self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
|
||||
self.tableWidgetSent = QtGui.QTableWidget(self.sent)
|
||||
self.tableWidgetSent.setDragDropMode(QtGui.QAbstractItemView.DragDrop)
|
||||
self.tableWidgetSent.setAlternatingRowColors(True)
|
||||
self.tableWidgetSent.setSelectionMode(QtGui.QAbstractItemView.SingleSelection)
|
||||
self.tableWidgetSent.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows)
|
||||
self.tableWidgetSent.setWordWrap(False)
|
||||
self.tableWidgetSent.setObjectName(_fromUtf8("tableWidgetSent"))
|
||||
self.tableWidgetSent.setColumnCount(4)
|
||||
self.tableWidgetSent.setRowCount(0)
|
||||
item = QtGui.QTableWidgetItem()
|
||||
self.tableWidgetSent.setHorizontalHeaderItem(0, item)
|
||||
item = QtGui.QTableWidgetItem()
|
||||
self.tableWidgetSent.setHorizontalHeaderItem(1, item)
|
||||
item = QtGui.QTableWidgetItem()
|
||||
self.tableWidgetSent.setHorizontalHeaderItem(2, item)
|
||||
item = QtGui.QTableWidgetItem()
|
||||
self.tableWidgetSent.setHorizontalHeaderItem(3, item)
|
||||
self.tableWidgetSent.horizontalHeader().setCascadingSectionResizes(True)
|
||||
self.tableWidgetSent.horizontalHeader().setDefaultSectionSize(130)
|
||||
self.tableWidgetSent.horizontalHeader().setHighlightSections(False)
|
||||
self.tableWidgetSent.horizontalHeader().setSortIndicatorShown(False)
|
||||
self.tableWidgetSent.horizontalHeader().setStretchLastSection(True)
|
||||
self.tableWidgetSent.verticalHeader().setVisible(False)
|
||||
self.tableWidgetSent.verticalHeader().setStretchLastSection(False)
|
||||
self.verticalLayout.addWidget(self.tableWidgetSent)
|
||||
self.textEditSentMessage = QtGui.QTextEdit(self.sent)
|
||||
self.textEditSentMessage.setObjectName(_fromUtf8("textEditSentMessage"))
|
||||
self.verticalLayout.addWidget(self.textEditSentMessage)
|
||||
icon2 = QtGui.QIcon()
|
||||
icon2.addPixmap(QtGui.QPixmap(_fromUtf8(":/newPrefix/images/sent.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||
self.tabWidget.addTab(self.sent, icon2, _fromUtf8(""))
|
||||
self.youridentities = QtGui.QWidget()
|
||||
self.youridentities.setObjectName(_fromUtf8("youridentities"))
|
||||
self.gridLayout_3 = QtGui.QGridLayout(self.youridentities)
|
||||
self.gridLayout_3.setObjectName(_fromUtf8("gridLayout_3"))
|
||||
self.pushButtonNewAddress = QtGui.QPushButton(self.youridentities)
|
||||
self.pushButtonNewAddress.setObjectName(_fromUtf8("pushButtonNewAddress"))
|
||||
self.gridLayout_3.addWidget(self.pushButtonNewAddress, 0, 0, 1, 1)
|
||||
spacerItem4 = QtGui.QSpacerItem(689, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
|
||||
self.gridLayout_3.addItem(spacerItem4, 0, 1, 1, 1)
|
||||
self.tableWidgetYourIdentities = QtGui.QTableWidget(self.youridentities)
|
||||
self.tableWidgetYourIdentities.setFrameShadow(QtGui.QFrame.Sunken)
|
||||
self.tableWidgetYourIdentities.setLineWidth(1)
|
||||
self.tableWidgetYourIdentities.setAlternatingRowColors(True)
|
||||
self.tableWidgetYourIdentities.setSelectionMode(QtGui.QAbstractItemView.SingleSelection)
|
||||
self.tableWidgetYourIdentities.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows)
|
||||
self.tableWidgetYourIdentities.setObjectName(_fromUtf8("tableWidgetYourIdentities"))
|
||||
self.tableWidgetYourIdentities.setColumnCount(3)
|
||||
self.tableWidgetYourIdentities.setRowCount(0)
|
||||
item = QtGui.QTableWidgetItem()
|
||||
font = QtGui.QFont()
|
||||
font.setKerning(True)
|
||||
item.setFont(font)
|
||||
self.tableWidgetYourIdentities.setHorizontalHeaderItem(0, item)
|
||||
item = QtGui.QTableWidgetItem()
|
||||
self.tableWidgetYourIdentities.setHorizontalHeaderItem(1, item)
|
||||
item = QtGui.QTableWidgetItem()
|
||||
self.tableWidgetYourIdentities.setHorizontalHeaderItem(2, item)
|
||||
self.tableWidgetYourIdentities.horizontalHeader().setCascadingSectionResizes(True)
|
||||
self.tableWidgetYourIdentities.horizontalHeader().setDefaultSectionSize(346)
|
||||
self.tableWidgetYourIdentities.horizontalHeader().setMinimumSectionSize(52)
|
||||
self.tableWidgetYourIdentities.horizontalHeader().setSortIndicatorShown(True)
|
||||
self.tableWidgetYourIdentities.horizontalHeader().setStretchLastSection(True)
|
||||
self.tableWidgetYourIdentities.verticalHeader().setVisible(False)
|
||||
self.tableWidgetYourIdentities.verticalHeader().setDefaultSectionSize(26)
|
||||
self.tableWidgetYourIdentities.verticalHeader().setSortIndicatorShown(False)
|
||||
self.tableWidgetYourIdentities.verticalHeader().setStretchLastSection(False)
|
||||
self.gridLayout_3.addWidget(self.tableWidgetYourIdentities, 1, 0, 1, 2)
|
||||
icon3 = QtGui.QIcon()
|
||||
icon3.addPixmap(QtGui.QPixmap(_fromUtf8(":/newPrefix/images/identities.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||
self.tabWidget.addTab(self.youridentities, icon3, _fromUtf8(""))
|
||||
self.subscriptions = QtGui.QWidget()
|
||||
self.subscriptions.setObjectName(_fromUtf8("subscriptions"))
|
||||
self.gridLayout_4 = QtGui.QGridLayout(self.subscriptions)
|
||||
self.gridLayout_4.setObjectName(_fromUtf8("gridLayout_4"))
|
||||
self.label_5 = QtGui.QLabel(self.subscriptions)
|
||||
self.label_5.setWordWrap(True)
|
||||
self.label_5.setObjectName(_fromUtf8("label_5"))
|
||||
self.gridLayout_4.addWidget(self.label_5, 0, 0, 1, 2)
|
||||
self.pushButtonAddSubscription = QtGui.QPushButton(self.subscriptions)
|
||||
self.pushButtonAddSubscription.setObjectName(_fromUtf8("pushButtonAddSubscription"))
|
||||
self.gridLayout_4.addWidget(self.pushButtonAddSubscription, 1, 0, 1, 1)
|
||||
spacerItem5 = QtGui.QSpacerItem(689, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
|
||||
self.gridLayout_4.addItem(spacerItem5, 1, 1, 1, 1)
|
||||
self.tableWidgetSubscriptions = QtGui.QTableWidget(self.subscriptions)
|
||||
self.tableWidgetSubscriptions.setAlternatingRowColors(True)
|
||||
self.tableWidgetSubscriptions.setSelectionMode(QtGui.QAbstractItemView.SingleSelection)
|
||||
self.tableWidgetSubscriptions.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows)
|
||||
self.tableWidgetSubscriptions.setObjectName(_fromUtf8("tableWidgetSubscriptions"))
|
||||
self.tableWidgetSubscriptions.setColumnCount(2)
|
||||
self.tableWidgetSubscriptions.setRowCount(0)
|
||||
item = QtGui.QTableWidgetItem()
|
||||
self.tableWidgetSubscriptions.setHorizontalHeaderItem(0, item)
|
||||
item = QtGui.QTableWidgetItem()
|
||||
self.tableWidgetSubscriptions.setHorizontalHeaderItem(1, item)
|
||||
self.tableWidgetSubscriptions.horizontalHeader().setCascadingSectionResizes(True)
|
||||
self.tableWidgetSubscriptions.horizontalHeader().setDefaultSectionSize(400)
|
||||
self.tableWidgetSubscriptions.horizontalHeader().setHighlightSections(False)
|
||||
self.tableWidgetSubscriptions.horizontalHeader().setSortIndicatorShown(False)
|
||||
self.tableWidgetSubscriptions.horizontalHeader().setStretchLastSection(True)
|
||||
self.tableWidgetSubscriptions.verticalHeader().setVisible(False)
|
||||
self.gridLayout_4.addWidget(self.tableWidgetSubscriptions, 2, 0, 1, 2)
|
||||
icon4 = QtGui.QIcon()
|
||||
icon4.addPixmap(QtGui.QPixmap(_fromUtf8(":/newPrefix/images/subscriptions.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||
self.tabWidget.addTab(self.subscriptions, icon4, _fromUtf8(""))
|
||||
self.addressbook = QtGui.QWidget()
|
||||
self.addressbook.setObjectName(_fromUtf8("addressbook"))
|
||||
self.gridLayout_5 = QtGui.QGridLayout(self.addressbook)
|
||||
self.gridLayout_5.setObjectName(_fromUtf8("gridLayout_5"))
|
||||
self.label_6 = QtGui.QLabel(self.addressbook)
|
||||
self.label_6.setWordWrap(True)
|
||||
self.label_6.setObjectName(_fromUtf8("label_6"))
|
||||
self.gridLayout_5.addWidget(self.label_6, 0, 0, 1, 2)
|
||||
self.pushButtonAddAddressBook = QtGui.QPushButton(self.addressbook)
|
||||
self.pushButtonAddAddressBook.setObjectName(_fromUtf8("pushButtonAddAddressBook"))
|
||||
self.gridLayout_5.addWidget(self.pushButtonAddAddressBook, 1, 0, 1, 1)
|
||||
spacerItem6 = QtGui.QSpacerItem(689, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
|
||||
self.gridLayout_5.addItem(spacerItem6, 1, 1, 1, 1)
|
||||
self.tableWidgetAddressBook = QtGui.QTableWidget(self.addressbook)
|
||||
self.tableWidgetAddressBook.setAlternatingRowColors(True)
|
||||
self.tableWidgetAddressBook.setSelectionMode(QtGui.QAbstractItemView.SingleSelection)
|
||||
self.tableWidgetAddressBook.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows)
|
||||
self.tableWidgetAddressBook.setObjectName(_fromUtf8("tableWidgetAddressBook"))
|
||||
self.tableWidgetAddressBook.setColumnCount(2)
|
||||
self.tableWidgetAddressBook.setRowCount(0)
|
||||
item = QtGui.QTableWidgetItem()
|
||||
self.tableWidgetAddressBook.setHorizontalHeaderItem(0, item)
|
||||
item = QtGui.QTableWidgetItem()
|
||||
self.tableWidgetAddressBook.setHorizontalHeaderItem(1, item)
|
||||
self.tableWidgetAddressBook.horizontalHeader().setCascadingSectionResizes(True)
|
||||
self.tableWidgetAddressBook.horizontalHeader().setDefaultSectionSize(400)
|
||||
self.tableWidgetAddressBook.horizontalHeader().setHighlightSections(False)
|
||||
self.tableWidgetAddressBook.horizontalHeader().setStretchLastSection(True)
|
||||
self.tableWidgetAddressBook.verticalHeader().setVisible(False)
|
||||
self.gridLayout_5.addWidget(self.tableWidgetAddressBook, 2, 0, 1, 2)
|
||||
icon5 = QtGui.QIcon()
|
||||
icon5.addPixmap(QtGui.QPixmap(_fromUtf8(":/newPrefix/images/addressbook.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||
self.tabWidget.addTab(self.addressbook, icon5, _fromUtf8(""))
|
||||
self.blackwhitelist = QtGui.QWidget()
|
||||
self.blackwhitelist.setObjectName(_fromUtf8("blackwhitelist"))
|
||||
self.gridLayout_6 = QtGui.QGridLayout(self.blackwhitelist)
|
||||
self.gridLayout_6.setObjectName(_fromUtf8("gridLayout_6"))
|
||||
self.radioButtonBlacklist = QtGui.QRadioButton(self.blackwhitelist)
|
||||
self.radioButtonBlacklist.setChecked(True)
|
||||
self.radioButtonBlacklist.setObjectName(_fromUtf8("radioButtonBlacklist"))
|
||||
self.gridLayout_6.addWidget(self.radioButtonBlacklist, 0, 0, 1, 2)
|
||||
self.radioButtonWhitelist = QtGui.QRadioButton(self.blackwhitelist)
|
||||
self.radioButtonWhitelist.setObjectName(_fromUtf8("radioButtonWhitelist"))
|
||||
self.gridLayout_6.addWidget(self.radioButtonWhitelist, 1, 0, 1, 2)
|
||||
self.pushButtonAddBlacklist = QtGui.QPushButton(self.blackwhitelist)
|
||||
self.pushButtonAddBlacklist.setObjectName(_fromUtf8("pushButtonAddBlacklist"))
|
||||
self.gridLayout_6.addWidget(self.pushButtonAddBlacklist, 2, 0, 1, 1)
|
||||
spacerItem7 = QtGui.QSpacerItem(689, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
|
||||
self.gridLayout_6.addItem(spacerItem7, 2, 1, 1, 1)
|
||||
self.tableWidgetBlacklist = QtGui.QTableWidget(self.blackwhitelist)
|
||||
self.tableWidgetBlacklist.setAlternatingRowColors(True)
|
||||
self.tableWidgetBlacklist.setSelectionMode(QtGui.QAbstractItemView.SingleSelection)
|
||||
self.tableWidgetBlacklist.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows)
|
||||
self.tableWidgetBlacklist.setObjectName(_fromUtf8("tableWidgetBlacklist"))
|
||||
self.tableWidgetBlacklist.setColumnCount(2)
|
||||
self.tableWidgetBlacklist.setRowCount(0)
|
||||
item = QtGui.QTableWidgetItem()
|
||||
self.tableWidgetBlacklist.setHorizontalHeaderItem(0, item)
|
||||
item = QtGui.QTableWidgetItem()
|
||||
self.tableWidgetBlacklist.setHorizontalHeaderItem(1, item)
|
||||
self.tableWidgetBlacklist.horizontalHeader().setCascadingSectionResizes(True)
|
||||
self.tableWidgetBlacklist.horizontalHeader().setDefaultSectionSize(400)
|
||||
self.tableWidgetBlacklist.horizontalHeader().setHighlightSections(False)
|
||||
self.tableWidgetBlacklist.horizontalHeader().setSortIndicatorShown(False)
|
||||
self.tableWidgetBlacklist.horizontalHeader().setStretchLastSection(True)
|
||||
self.tableWidgetBlacklist.verticalHeader().setVisible(False)
|
||||
self.gridLayout_6.addWidget(self.tableWidgetBlacklist, 3, 0, 1, 2)
|
||||
icon6 = QtGui.QIcon()
|
||||
icon6.addPixmap(QtGui.QPixmap(_fromUtf8(":/newPrefix/images/blacklist.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||
self.tabWidget.addTab(self.blackwhitelist, icon6, _fromUtf8(""))
|
||||
self.networkstatus = QtGui.QWidget()
|
||||
self.networkstatus.setObjectName(_fromUtf8("networkstatus"))
|
||||
self.pushButtonStatusIcon = QtGui.QPushButton(self.networkstatus)
|
||||
self.pushButtonStatusIcon.setGeometry(QtCore.QRect(680, 440, 21, 23))
|
||||
self.pushButtonStatusIcon.setText(_fromUtf8(""))
|
||||
icon7 = QtGui.QIcon()
|
||||
icon7.addPixmap(QtGui.QPixmap(_fromUtf8(":/newPrefix/images/redicon.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||
self.pushButtonStatusIcon.setIcon(icon7)
|
||||
self.pushButtonStatusIcon.setFlat(True)
|
||||
self.pushButtonStatusIcon.setObjectName(_fromUtf8("pushButtonStatusIcon"))
|
||||
self.tableWidgetConnectionCount = QtGui.QTableWidget(self.networkstatus)
|
||||
self.tableWidgetConnectionCount.setGeometry(QtCore.QRect(20, 70, 241, 241))
|
||||
palette = QtGui.QPalette()
|
||||
brush = QtGui.QBrush(QtGui.QColor(212, 208, 200))
|
||||
brush.setStyle(QtCore.Qt.SolidPattern)
|
||||
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Base, brush)
|
||||
brush = QtGui.QBrush(QtGui.QColor(212, 208, 200))
|
||||
brush.setStyle(QtCore.Qt.SolidPattern)
|
||||
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Base, brush)
|
||||
brush = QtGui.QBrush(QtGui.QColor(212, 208, 200))
|
||||
brush.setStyle(QtCore.Qt.SolidPattern)
|
||||
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Base, brush)
|
||||
self.tableWidgetConnectionCount.setPalette(palette)
|
||||
self.tableWidgetConnectionCount.setFrameShape(QtGui.QFrame.Box)
|
||||
self.tableWidgetConnectionCount.setFrameShadow(QtGui.QFrame.Plain)
|
||||
self.tableWidgetConnectionCount.setProperty("showDropIndicator", False)
|
||||
self.tableWidgetConnectionCount.setAlternatingRowColors(True)
|
||||
self.tableWidgetConnectionCount.setSelectionMode(QtGui.QAbstractItemView.NoSelection)
|
||||
self.tableWidgetConnectionCount.setObjectName(_fromUtf8("tableWidgetConnectionCount"))
|
||||
self.tableWidgetConnectionCount.setColumnCount(2)
|
||||
self.tableWidgetConnectionCount.setRowCount(0)
|
||||
item = QtGui.QTableWidgetItem()
|
||||
self.tableWidgetConnectionCount.setHorizontalHeaderItem(0, item)
|
||||
item = QtGui.QTableWidgetItem()
|
||||
self.tableWidgetConnectionCount.setHorizontalHeaderItem(1, item)
|
||||
self.tableWidgetConnectionCount.horizontalHeader().setCascadingSectionResizes(True)
|
||||
self.tableWidgetConnectionCount.horizontalHeader().setHighlightSections(False)
|
||||
self.tableWidgetConnectionCount.horizontalHeader().setStretchLastSection(True)
|
||||
self.tableWidgetConnectionCount.verticalHeader().setVisible(False)
|
||||
self.labelTotalConnections = QtGui.QLabel(self.networkstatus)
|
||||
self.labelTotalConnections.setGeometry(QtCore.QRect(20, 30, 401, 16))
|
||||
self.labelTotalConnections.setObjectName(_fromUtf8("labelTotalConnections"))
|
||||
self.labelStartupTime = QtGui.QLabel(self.networkstatus)
|
||||
self.labelStartupTime.setGeometry(QtCore.QRect(320, 110, 331, 20))
|
||||
self.labelStartupTime.setObjectName(_fromUtf8("labelStartupTime"))
|
||||
self.labelMessageCount = QtGui.QLabel(self.networkstatus)
|
||||
self.labelMessageCount.setGeometry(QtCore.QRect(350, 130, 281, 16))
|
||||
self.labelMessageCount.setObjectName(_fromUtf8("labelMessageCount"))
|
||||
self.labelPubkeyCount = QtGui.QLabel(self.networkstatus)
|
||||
self.labelPubkeyCount.setGeometry(QtCore.QRect(350, 170, 331, 16))
|
||||
self.labelPubkeyCount.setObjectName(_fromUtf8("labelPubkeyCount"))
|
||||
self.labelBroadcastCount = QtGui.QLabel(self.networkstatus)
|
||||
self.labelBroadcastCount.setGeometry(QtCore.QRect(350, 150, 171, 16))
|
||||
self.labelBroadcastCount.setObjectName(_fromUtf8("labelBroadcastCount"))
|
||||
icon8 = QtGui.QIcon()
|
||||
icon8.addPixmap(QtGui.QPixmap(_fromUtf8(":/newPrefix/images/networkstatus.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||
self.tabWidget.addTab(self.networkstatus, icon8, _fromUtf8(""))
|
||||
self.gridLayout.addWidget(self.tabWidget, 0, 0, 1, 1)
|
||||
MainWindow.setCentralWidget(self.centralwidget)
|
||||
self.menubar = QtGui.QMenuBar(MainWindow)
|
||||
self.menubar.setGeometry(QtCore.QRect(0, 0, 795, 18))
|
||||
self.menubar.setObjectName(_fromUtf8("menubar"))
|
||||
self.menuFile = QtGui.QMenu(self.menubar)
|
||||
self.menuFile.setObjectName(_fromUtf8("menuFile"))
|
||||
self.menuSettings = QtGui.QMenu(self.menubar)
|
||||
self.menuSettings.setObjectName(_fromUtf8("menuSettings"))
|
||||
self.menuHelp = QtGui.QMenu(self.menubar)
|
||||
self.menuHelp.setObjectName(_fromUtf8("menuHelp"))
|
||||
MainWindow.setMenuBar(self.menubar)
|
||||
self.statusbar = QtGui.QStatusBar(MainWindow)
|
||||
self.statusbar.setMaximumSize(QtCore.QSize(16777215, 22))
|
||||
self.statusbar.setObjectName(_fromUtf8("statusbar"))
|
||||
MainWindow.setStatusBar(self.statusbar)
|
||||
self.actionImport_keys = QtGui.QAction(MainWindow)
|
||||
self.actionImport_keys.setObjectName(_fromUtf8("actionImport_keys"))
|
||||
self.actionManageKeys = QtGui.QAction(MainWindow)
|
||||
self.actionManageKeys.setCheckable(False)
|
||||
self.actionManageKeys.setEnabled(True)
|
||||
self.actionManageKeys.setObjectName(_fromUtf8("actionManageKeys"))
|
||||
self.actionExit = QtGui.QAction(MainWindow)
|
||||
self.actionExit.setObjectName(_fromUtf8("actionExit"))
|
||||
self.actionHelp = QtGui.QAction(MainWindow)
|
||||
self.actionHelp.setObjectName(_fromUtf8("actionHelp"))
|
||||
self.actionAbout = QtGui.QAction(MainWindow)
|
||||
self.actionAbout.setObjectName(_fromUtf8("actionAbout"))
|
||||
self.actionSettings = QtGui.QAction(MainWindow)
|
||||
self.actionSettings.setObjectName(_fromUtf8("actionSettings"))
|
||||
self.menuFile.addAction(self.actionManageKeys)
|
||||
self.menuFile.addAction(self.actionExit)
|
||||
self.menuSettings.addAction(self.actionSettings)
|
||||
self.menuHelp.addAction(self.actionHelp)
|
||||
self.menuHelp.addAction(self.actionAbout)
|
||||
self.menubar.addAction(self.menuFile.menuAction())
|
||||
self.menubar.addAction(self.menuSettings.menuAction())
|
||||
self.menubar.addAction(self.menuHelp.menuAction())
|
||||
|
||||
self.retranslateUi(MainWindow)
|
||||
self.tabWidget.setCurrentIndex(0)
|
||||
QtCore.QObject.connect(self.radioButtonSpecific, QtCore.SIGNAL(_fromUtf8("toggled(bool)")), self.lineEditTo.setEnabled)
|
||||
QtCore.QMetaObject.connectSlotsByName(MainWindow)
|
||||
|
||||
def retranslateUi(self, MainWindow):
|
||||
MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "Bitmessage", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.tableWidgetInbox.setSortingEnabled(True)
|
||||
item = self.tableWidgetInbox.horizontalHeaderItem(0)
|
||||
item.setText(QtGui.QApplication.translate("MainWindow", "To", None, QtGui.QApplication.UnicodeUTF8))
|
||||
item = self.tableWidgetInbox.horizontalHeaderItem(1)
|
||||
item.setText(QtGui.QApplication.translate("MainWindow", "From", None, QtGui.QApplication.UnicodeUTF8))
|
||||
item = self.tableWidgetInbox.horizontalHeaderItem(2)
|
||||
item.setText(QtGui.QApplication.translate("MainWindow", "Subject", None, QtGui.QApplication.UnicodeUTF8))
|
||||
item = self.tableWidgetInbox.horizontalHeaderItem(3)
|
||||
item.setText(QtGui.QApplication.translate("MainWindow", "Received", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.tabWidget.setTabText(self.tabWidget.indexOf(self.inbox), QtGui.QApplication.translate("MainWindow", "Inbox", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.label_3.setText(QtGui.QApplication.translate("MainWindow", "Subject:", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.label_2.setText(QtGui.QApplication.translate("MainWindow", "From:", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.label_4.setText(QtGui.QApplication.translate("MainWindow", "Message:", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.label.setText(QtGui.QApplication.translate("MainWindow", "To:", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.radioButtonBroadcast.setText(QtGui.QApplication.translate("MainWindow", "Broadcast to everyone who is subscribed to your address", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.pushButtonLoadFromAddressBook.setText(QtGui.QApplication.translate("MainWindow", "Load from Address book", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.radioButtonSpecific.setText(QtGui.QApplication.translate("MainWindow", "Send to one or more specific people", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.pushButtonSend.setText(QtGui.QApplication.translate("MainWindow", "Send", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.textEditMessage.setHtml(QtGui.QApplication.translate("MainWindow", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
|
||||
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
|
||||
"p, li { white-space: pre-wrap; }\n"
|
||||
"</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:9pt; font-weight:400; font-style:normal;\">\n"
|
||||
"<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.tabWidget.setTabText(self.tabWidget.indexOf(self.send), QtGui.QApplication.translate("MainWindow", "Send", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.tableWidgetSent.setSortingEnabled(True)
|
||||
item = self.tableWidgetSent.horizontalHeaderItem(0)
|
||||
item.setText(QtGui.QApplication.translate("MainWindow", "To", None, QtGui.QApplication.UnicodeUTF8))
|
||||
item = self.tableWidgetSent.horizontalHeaderItem(1)
|
||||
item.setText(QtGui.QApplication.translate("MainWindow", "From", None, QtGui.QApplication.UnicodeUTF8))
|
||||
item = self.tableWidgetSent.horizontalHeaderItem(2)
|
||||
item.setText(QtGui.QApplication.translate("MainWindow", "Subject", None, QtGui.QApplication.UnicodeUTF8))
|
||||
item = self.tableWidgetSent.horizontalHeaderItem(3)
|
||||
item.setText(QtGui.QApplication.translate("MainWindow", "Status", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.tabWidget.setTabText(self.tabWidget.indexOf(self.sent), QtGui.QApplication.translate("MainWindow", "Sent", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.pushButtonNewAddress.setText(QtGui.QApplication.translate("MainWindow", "New", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.tableWidgetYourIdentities.setSortingEnabled(True)
|
||||
item = self.tableWidgetYourIdentities.horizontalHeaderItem(0)
|
||||
item.setText(QtGui.QApplication.translate("MainWindow", "Label (not shown to anyone)", None, QtGui.QApplication.UnicodeUTF8))
|
||||
item = self.tableWidgetYourIdentities.horizontalHeaderItem(1)
|
||||
item.setText(QtGui.QApplication.translate("MainWindow", "Address", None, QtGui.QApplication.UnicodeUTF8))
|
||||
item = self.tableWidgetYourIdentities.horizontalHeaderItem(2)
|
||||
item.setText(QtGui.QApplication.translate("MainWindow", "Stream", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.tabWidget.setTabText(self.tabWidget.indexOf(self.youridentities), QtGui.QApplication.translate("MainWindow", "Your Identities", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.label_5.setText(QtGui.QApplication.translate("MainWindow", "Here you can subscibe to \'broadcast messages\' that are sent by other users. Messages will appear in your Inbox. Addresses here override those on the Blacklist tab.", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.pushButtonAddSubscription.setText(QtGui.QApplication.translate("MainWindow", "Add", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.tableWidgetSubscriptions.setSortingEnabled(True)
|
||||
item = self.tableWidgetSubscriptions.horizontalHeaderItem(0)
|
||||
item.setText(QtGui.QApplication.translate("MainWindow", "Label", None, QtGui.QApplication.UnicodeUTF8))
|
||||
item = self.tableWidgetSubscriptions.horizontalHeaderItem(1)
|
||||
item.setText(QtGui.QApplication.translate("MainWindow", "Address", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.tabWidget.setTabText(self.tabWidget.indexOf(self.subscriptions), QtGui.QApplication.translate("MainWindow", "Subscriptions", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.label_6.setText(QtGui.QApplication.translate("MainWindow", "The Address book is useful for adding names or labels to other people\'s Bitmessage addresses so that you can recognize them more easily in your inbox. You can add entries here using the \'Add\' button, or from your inbox by right-clicking on a message.", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.pushButtonAddAddressBook.setText(QtGui.QApplication.translate("MainWindow", "Add", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.tableWidgetAddressBook.setSortingEnabled(True)
|
||||
item = self.tableWidgetAddressBook.horizontalHeaderItem(0)
|
||||
item.setText(QtGui.QApplication.translate("MainWindow", "Name or Label", None, QtGui.QApplication.UnicodeUTF8))
|
||||
item = self.tableWidgetAddressBook.horizontalHeaderItem(1)
|
||||
item.setText(QtGui.QApplication.translate("MainWindow", "Address", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.tabWidget.setTabText(self.tabWidget.indexOf(self.addressbook), QtGui.QApplication.translate("MainWindow", "Address book", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.radioButtonBlacklist.setText(QtGui.QApplication.translate("MainWindow", "Use a Blacklist (Allow all incoming messages except those on the Blacklist)", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.radioButtonWhitelist.setText(QtGui.QApplication.translate("MainWindow", "Use a Whitelist (Block all incoming messages except those on the Whitelist)", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.pushButtonAddBlacklist.setText(QtGui.QApplication.translate("MainWindow", "Add", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.tableWidgetBlacklist.setSortingEnabled(True)
|
||||
item = self.tableWidgetBlacklist.horizontalHeaderItem(0)
|
||||
item.setText(QtGui.QApplication.translate("MainWindow", "Name or Label", None, QtGui.QApplication.UnicodeUTF8))
|
||||
item = self.tableWidgetBlacklist.horizontalHeaderItem(1)
|
||||
item.setText(QtGui.QApplication.translate("MainWindow", "Address", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.tabWidget.setTabText(self.tabWidget.indexOf(self.blackwhitelist), QtGui.QApplication.translate("MainWindow", "Blacklist", None, QtGui.QApplication.UnicodeUTF8))
|
||||
item = self.tableWidgetConnectionCount.horizontalHeaderItem(0)
|
||||
item.setText(QtGui.QApplication.translate("MainWindow", "Stream Number", None, QtGui.QApplication.UnicodeUTF8))
|
||||
item = self.tableWidgetConnectionCount.horizontalHeaderItem(1)
|
||||
item.setText(QtGui.QApplication.translate("MainWindow", "Number of Connections", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.labelTotalConnections.setText(QtGui.QApplication.translate("MainWindow", "Total connections: 0", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.labelStartupTime.setText(QtGui.QApplication.translate("MainWindow", "Since startup at asdf:", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.labelMessageCount.setText(QtGui.QApplication.translate("MainWindow", "Processed 0 person-to-person messages.", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.labelPubkeyCount.setText(QtGui.QApplication.translate("MainWindow", "Processed 0 public keys.", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.labelBroadcastCount.setText(QtGui.QApplication.translate("MainWindow", "Processed 0 broadcasts.", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.tabWidget.setTabText(self.tabWidget.indexOf(self.networkstatus), QtGui.QApplication.translate("MainWindow", "Network Status", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.menuFile.setTitle(QtGui.QApplication.translate("MainWindow", "File", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.menuSettings.setTitle(QtGui.QApplication.translate("MainWindow", "Settings", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.menuHelp.setTitle(QtGui.QApplication.translate("MainWindow", "Help", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.actionImport_keys.setText(QtGui.QApplication.translate("MainWindow", "Import keys", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.actionManageKeys.setText(QtGui.QApplication.translate("MainWindow", "Manage keys", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.actionExit.setText(QtGui.QApplication.translate("MainWindow", "Exit", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.actionHelp.setText(QtGui.QApplication.translate("MainWindow", "Help", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.actionAbout.setText(QtGui.QApplication.translate("MainWindow", "About", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.actionSettings.setText(QtGui.QApplication.translate("MainWindow", "Settings", None, QtGui.QApplication.UnicodeUTF8))
|
||||
|
||||
import bitmessage_icons_rc
|
1017
bitmessageui.ui
Normal file
1017
bitmessageui.ui
Normal file
|
@ -0,0 +1,1017 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>795</width>
|
||||
<height>561</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Bitmessage</string>
|
||||
</property>
|
||||
<property name="tabShape">
|
||||
<enum>QTabWidget::Rounded</enum>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="baseSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>9</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="tabPosition">
|
||||
<enum>QTabWidget::North</enum>
|
||||
</property>
|
||||
<property name="tabShape">
|
||||
<enum>QTabWidget::Rounded</enum>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="inbox">
|
||||
<attribute name="icon">
|
||||
<iconset resource="bitmessage_icons.qrc">
|
||||
<normaloff>:/newPrefix/images/inbox.png</normaloff>:/newPrefix/images/inbox.png</iconset>
|
||||
</attribute>
|
||||
<attribute name="title">
|
||||
<string>Inbox</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QTableWidget" name="tableWidgetInbox">
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::SingleSelection</enum>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<attribute name="horizontalHeaderCascadingSectionResizes">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderDefaultSectionSize">
|
||||
<number>200</number>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderHighlightSections">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderMinimumSectionSize">
|
||||
<number>27</number>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderShowSortIndicator" stdset="0">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderStretchLastSection">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderDefaultSectionSize">
|
||||
<number>26</number>
|
||||
</attribute>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>To</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>From</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Subject</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Received</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTextEdit" name="textEditInboxMessage">
|
||||
<property name="baseSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>500</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="send">
|
||||
<attribute name="icon">
|
||||
<iconset resource="bitmessage_icons.qrc">
|
||||
<normaloff>:/newPrefix/images/send.png</normaloff>:/newPrefix/images/send.png</iconset>
|
||||
</attribute>
|
||||
<attribute name="title">
|
||||
<string>Send</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="lineEditTo"/>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Subject:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>297</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>From:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="comboBoxSendFrom"/>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Message:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>To:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="3">
|
||||
<widget class="QRadioButton" name="radioButtonBroadcast">
|
||||
<property name="text">
|
||||
<string>Broadcast to everyone who is subscribed to your address</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2" colspan="2">
|
||||
<widget class="QPushButton" name="pushButtonLoadFromAddressBook">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>7</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Load from Address book</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="6">
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>28</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QRadioButton" name="radioButtonSpecific">
|
||||
<property name="text">
|
||||
<string>Send to one or more specific people</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="4">
|
||||
<spacer name="horizontalSpacer_6">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="7" column="5">
|
||||
<widget class="QPushButton" name="pushButtonSend">
|
||||
<property name="text">
|
||||
<string>Send</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="4">
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>192</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="4" column="1" colspan="5">
|
||||
<widget class="QLineEdit" name="lineEditSubject">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1" rowspan="2" colspan="5">
|
||||
<widget class="QTextEdit" name="textEditMessage">
|
||||
<property name="html">
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:9pt; font-weight:400; font-style:normal;">
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2" colspan="3">
|
||||
<widget class="QLabel" name="labelFrom">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="sent">
|
||||
<attribute name="icon">
|
||||
<iconset resource="bitmessage_icons.qrc">
|
||||
<normaloff>:/newPrefix/images/sent.png</normaloff>:/newPrefix/images/sent.png</iconset>
|
||||
</attribute>
|
||||
<attribute name="title">
|
||||
<string>Sent</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTableWidget" name="tableWidgetSent">
|
||||
<property name="dragDropMode">
|
||||
<enum>QAbstractItemView::DragDrop</enum>
|
||||
</property>
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::SingleSelection</enum>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<attribute name="horizontalHeaderCascadingSectionResizes">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderDefaultSectionSize">
|
||||
<number>130</number>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderHighlightSections">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderShowSortIndicator" stdset="0">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderStretchLastSection">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderStretchLastSection">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>To</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>From</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Subject</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Status</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTextEdit" name="textEditSentMessage"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="youridentities">
|
||||
<attribute name="icon">
|
||||
<iconset resource="bitmessage_icons.qrc">
|
||||
<normaloff>:/newPrefix/images/identities.png</normaloff>:/newPrefix/images/identities.png</iconset>
|
||||
</attribute>
|
||||
<attribute name="title">
|
||||
<string>Your Identities</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="pushButtonNewAddress">
|
||||
<property name="text">
|
||||
<string>New</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>689</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QTableWidget" name="tableWidgetYourIdentities">
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::SingleSelection</enum>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<attribute name="horizontalHeaderCascadingSectionResizes">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderDefaultSectionSize">
|
||||
<number>346</number>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderMinimumSectionSize">
|
||||
<number>52</number>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderShowSortIndicator" stdset="0">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderStretchLastSection">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderDefaultSectionSize">
|
||||
<number>26</number>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderShowSortIndicator" stdset="0">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderStretchLastSection">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Label (not shown to anyone)</string>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<kerning>true</kerning>
|
||||
</font>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Address</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Stream</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="subscriptions">
|
||||
<attribute name="icon">
|
||||
<iconset resource="bitmessage_icons.qrc">
|
||||
<normaloff>:/newPrefix/images/subscriptions.png</normaloff>:/newPrefix/images/subscriptions.png</iconset>
|
||||
</attribute>
|
||||
<attribute name="title">
|
||||
<string>Subscriptions</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Here you can subscibe to 'broadcast messages' that are sent by other users. Messages will appear in your Inbox. Addresses here override those on the Blacklist tab.</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QPushButton" name="pushButtonAddSubscription">
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>689</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QTableWidget" name="tableWidgetSubscriptions">
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::SingleSelection</enum>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<attribute name="horizontalHeaderCascadingSectionResizes">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderDefaultSectionSize">
|
||||
<number>400</number>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderHighlightSections">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderShowSortIndicator" stdset="0">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderStretchLastSection">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Label</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Address</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="addressbook">
|
||||
<attribute name="icon">
|
||||
<iconset resource="bitmessage_icons.qrc">
|
||||
<normaloff>:/newPrefix/images/addressbook.png</normaloff>:/newPrefix/images/addressbook.png</iconset>
|
||||
</attribute>
|
||||
<attribute name="title">
|
||||
<string>Address book</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_5">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>The Address book is useful for adding names or labels to other people's Bitmessage addresses so that you can recognize them more easily in your inbox. You can add entries here using the 'Add' button, or from your inbox by right-clicking on a message.</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QPushButton" name="pushButtonAddAddressBook">
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<spacer name="horizontalSpacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>689</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QTableWidget" name="tableWidgetAddressBook">
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::SingleSelection</enum>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<attribute name="horizontalHeaderCascadingSectionResizes">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderDefaultSectionSize">
|
||||
<number>400</number>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderHighlightSections">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderStretchLastSection">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Name or Label</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Address</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="blackwhitelist">
|
||||
<attribute name="icon">
|
||||
<iconset resource="bitmessage_icons.qrc">
|
||||
<normaloff>:/newPrefix/images/blacklist.png</normaloff>:/newPrefix/images/blacklist.png</iconset>
|
||||
</attribute>
|
||||
<attribute name="title">
|
||||
<string>Blacklist</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_6">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QRadioButton" name="radioButtonBlacklist">
|
||||
<property name="text">
|
||||
<string>Use a Blacklist (Allow all incoming messages except those on the Blacklist)</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QRadioButton" name="radioButtonWhitelist">
|
||||
<property name="text">
|
||||
<string>Use a Whitelist (Block all incoming messages except those on the Whitelist)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QPushButton" name="pushButtonAddBlacklist">
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<spacer name="horizontalSpacer_8">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>689</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="QTableWidget" name="tableWidgetBlacklist">
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::SingleSelection</enum>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<attribute name="horizontalHeaderCascadingSectionResizes">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderDefaultSectionSize">
|
||||
<number>400</number>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderHighlightSections">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderShowSortIndicator" stdset="0">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderStretchLastSection">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Name or Label</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Address</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="networkstatus">
|
||||
<attribute name="icon">
|
||||
<iconset resource="bitmessage_icons.qrc">
|
||||
<normaloff>:/newPrefix/images/networkstatus.png</normaloff>:/newPrefix/images/networkstatus.png</iconset>
|
||||
</attribute>
|
||||
<attribute name="title">
|
||||
<string>Network Status</string>
|
||||
</attribute>
|
||||
<widget class="QPushButton" name="pushButtonStatusIcon">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>680</x>
|
||||
<y>440</y>
|
||||
<width>21</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="bitmessage_icons.qrc">
|
||||
<normaloff>:/newPrefix/images/redicon.png</normaloff>:/newPrefix/images/redicon.png</iconset>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QTableWidget" name="tableWidgetConnectionCount">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>70</y>
|
||||
<width>241</width>
|
||||
<height>241</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="palette">
|
||||
<palette>
|
||||
<active>
|
||||
<colorrole role="Base">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>212</red>
|
||||
<green>208</green>
|
||||
<blue>200</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</active>
|
||||
<inactive>
|
||||
<colorrole role="Base">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>212</red>
|
||||
<green>208</green>
|
||||
<blue>200</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</inactive>
|
||||
<disabled>
|
||||
<colorrole role="Base">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>212</red>
|
||||
<green>208</green>
|
||||
<blue>200</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</disabled>
|
||||
</palette>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Box</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<property name="showDropIndicator" stdset="0">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::NoSelection</enum>
|
||||
</property>
|
||||
<attribute name="horizontalHeaderCascadingSectionResizes">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderHighlightSections">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderStretchLastSection">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Stream Number</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Number of Connections</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
<widget class="QLabel" name="labelTotalConnections">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>30</y>
|
||||
<width>401</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Total connections: 0</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="labelStartupTime">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>320</x>
|
||||
<y>110</y>
|
||||
<width>331</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Since startup at asdf:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="labelMessageCount">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>350</x>
|
||||
<y>130</y>
|
||||
<width>281</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Processed 0 person-to-person messages.</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="labelPubkeyCount">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>350</x>
|
||||
<y>170</y>
|
||||
<width>331</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Processed 0 public keys.</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="labelBroadcastCount">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>350</x>
|
||||
<y>150</y>
|
||||
<width>171</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Processed 0 broadcasts.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>795</width>
|
||||
<height>18</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuFile">
|
||||
<property name="title">
|
||||
<string>File</string>
|
||||
</property>
|
||||
<addaction name="actionManageKeys"/>
|
||||
<addaction name="actionExit"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuSettings">
|
||||
<property name="title">
|
||||
<string>Settings</string>
|
||||
</property>
|
||||
<addaction name="actionSettings"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuHelp">
|
||||
<property name="title">
|
||||
<string>Help</string>
|
||||
</property>
|
||||
<addaction name="actionHelp"/>
|
||||
<addaction name="actionAbout"/>
|
||||
</widget>
|
||||
<addaction name="menuFile"/>
|
||||
<addaction name="menuSettings"/>
|
||||
<addaction name="menuHelp"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>22</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
<action name="actionImport_keys">
|
||||
<property name="text">
|
||||
<string>Import keys</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionManageKeys">
|
||||
<property name="checkable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Manage keys</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionExit">
|
||||
<property name="text">
|
||||
<string>Exit</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionHelp">
|
||||
<property name="text">
|
||||
<string>Help</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionAbout">
|
||||
<property name="text">
|
||||
<string>About</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSettings">
|
||||
<property name="text">
|
||||
<string>Settings</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="bitmessage_icons.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>radioButtonSpecific</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>lineEditTo</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>121</x>
|
||||
<y>60</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>133</x>
|
||||
<y>149</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
73
defaultKnownNodes.py
Normal file
73
defaultKnownNodes.py
Normal file
|
@ -0,0 +1,73 @@
|
|||
import pickle
|
||||
import socket
|
||||
from struct import *
|
||||
import time
|
||||
import random
|
||||
import sys
|
||||
from time import strftime, localtime
|
||||
|
||||
def createDefaultKnownNodes(appdata):
|
||||
############## Stream 1 ################
|
||||
stream1 = {}
|
||||
|
||||
#stream1['127.0.0.1'] = (5888,int(time.time()))
|
||||
#stream1['66.108.252.231'] = (8080,int(time.time()))
|
||||
stream1['75.186.58.44'] = (8080,int(time.time()))
|
||||
#stream1['0.0.0.20'] = (5777,int(time.time()))
|
||||
#stream1['0.0.0.30'] = (5777,int(time.time()))
|
||||
|
||||
############# Stream 2 #################
|
||||
stream2 = {}
|
||||
# None yet
|
||||
|
||||
############# Stream 3 #################
|
||||
stream3 = {}
|
||||
# None yet
|
||||
|
||||
allKnownNodes = {}
|
||||
allKnownNodes[1] = stream1
|
||||
allKnownNodes[2] = stream2
|
||||
allKnownNodes[3] = stream3
|
||||
|
||||
#print stream1
|
||||
#print allKnownNodes
|
||||
|
||||
output = open(appdata + 'knownnodes.dat', 'wb')
|
||||
|
||||
# Pickle dictionary using protocol 0.
|
||||
pickle.dump(allKnownNodes, output)
|
||||
|
||||
output.close()
|
||||
return allKnownNodes
|
||||
|
||||
def readDefaultKnownNodes(appdata):
|
||||
pickleFile = open(appdata + 'knownnodes.dat', 'rb')
|
||||
knownNodes = pickle.load(pickleFile)
|
||||
pickleFile.close()
|
||||
knownNodes
|
||||
for stream, storedValue in knownNodes.items():
|
||||
for host,value in storedValue.items():
|
||||
port, storedtime = storedValue[host]
|
||||
print host, '\t', port, '\t', strftime('%a, %d %b %Y %I:%M %p',localtime(storedtime))
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
APPNAME = "PyBitmessage"
|
||||
from os import path, environ
|
||||
if sys.platform == 'darwin':
|
||||
from AppKit import NSSearchPathForDirectoriesInDomains
|
||||
# http://developer.apple.com/DOCUMENTATION/Cocoa/Reference/Foundation/Miscellaneous/Foundation_Functions/Reference/reference.html#//apple_ref/c/func/NSSearchPathForDirectoriesInDomains
|
||||
# NSApplicationSupportDirectory = 14
|
||||
# NSUserDomainMask = 1
|
||||
# True for expanding the tilde into a fully qualified path
|
||||
appdata = path.join(NSSearchPathForDirectoriesInDomains(14, 1, True)[0], APPNAME) + '/'
|
||||
elif 'win' in sys.platform:
|
||||
appdata = path.join(environ['APPDATA'], APPNAME) + '\\'
|
||||
else:
|
||||
appdata = path.expanduser(path.join("~", "." + APPNAME + "/"))
|
||||
|
||||
|
||||
#print 'New list of all known nodes:', createDefaultKnownNodes(appdata)
|
||||
readDefaultKnownNodes(appdata)
|
||||
|
||||
|
43
help.py
Normal file
43
help.py
Normal file
|
@ -0,0 +1,43 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Form implementation generated from reading ui file 'help.ui'
|
||||
#
|
||||
# Created: Mon Nov 19 12:25:18 2012
|
||||
# by: PyQt4 UI code generator 4.9.4
|
||||
#
|
||||
# WARNING! All changes made in this file will be lost!
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
try:
|
||||
_fromUtf8 = QtCore.QString.fromUtf8
|
||||
except AttributeError:
|
||||
_fromUtf8 = lambda s: s
|
||||
|
||||
class Ui_helpDialog(object):
|
||||
def setupUi(self, helpDialog):
|
||||
helpDialog.setObjectName(_fromUtf8("helpDialog"))
|
||||
helpDialog.resize(335, 170)
|
||||
self.buttonBox = QtGui.QDialogButtonBox(helpDialog)
|
||||
self.buttonBox.setGeometry(QtCore.QRect(30, 120, 281, 32))
|
||||
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
|
||||
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok)
|
||||
self.buttonBox.setObjectName(_fromUtf8("buttonBox"))
|
||||
self.label = QtGui.QLabel(helpDialog)
|
||||
self.label.setGeometry(QtCore.QRect(30, 20, 291, 51))
|
||||
self.label.setWordWrap(True)
|
||||
self.label.setObjectName(_fromUtf8("label"))
|
||||
self.labelHelpURI = QtGui.QLabel(helpDialog)
|
||||
self.labelHelpURI.setGeometry(QtCore.QRect(30, 70, 301, 21))
|
||||
self.labelHelpURI.setObjectName(_fromUtf8("labelHelpURI"))
|
||||
|
||||
self.retranslateUi(helpDialog)
|
||||
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), helpDialog.accept)
|
||||
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), helpDialog.reject)
|
||||
QtCore.QMetaObject.connectSlotsByName(helpDialog)
|
||||
|
||||
def retranslateUi(self, helpDialog):
|
||||
helpDialog.setWindowTitle(QtGui.QApplication.translate("helpDialog", "Help", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.label.setText(QtGui.QApplication.translate("helpDialog", "As Bitmessage is a collaborative project, help can be found online in the Bitmessage Wiki:", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.labelHelpURI.setText(QtGui.QApplication.translate("helpDialog", "<a href=\"http://Bitmessage.org/wiki/PyBitmessage_Help\">http://Bitmessage.org/wiki/PyBitmessage_Help</a>", None, QtGui.QApplication.UnicodeUTF8))
|
||||
|
97
help.ui
Normal file
97
help.ui
Normal file
|
@ -0,0 +1,97 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>helpDialog</class>
|
||||
<widget class="QDialog" name="helpDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>335</width>
|
||||
<height>170</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Help</string>
|
||||
</property>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>120</y>
|
||||
<width>281</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>20</y>
|
||||
<width>291</width>
|
||||
<height>51</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>As Bitmessage is a collaborative project, help can be found online in the Bitmessage Wiki:</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="labelHelpURI">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>70</y>
|
||||
<width>301</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><a href="http://Bitmessage.org/wiki/PyBitmessage_Help">http://Bitmessage.org/wiki/PyBitmessage_Help</a></string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>helpDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>helpDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
72
iconglossary.py
Normal file
72
iconglossary.py
Normal file
|
@ -0,0 +1,72 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Form implementation generated from reading ui file 'iconglossary.ui'
|
||||
#
|
||||
# Created: Mon Nov 05 16:56:02 2012
|
||||
# by: PyQt4 UI code generator 4.9.4
|
||||
#
|
||||
# WARNING! All changes made in this file will be lost!
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
try:
|
||||
_fromUtf8 = QtCore.QString.fromUtf8
|
||||
except AttributeError:
|
||||
_fromUtf8 = lambda s: s
|
||||
|
||||
class Ui_iconGlossaryDialog(object):
|
||||
def setupUi(self, iconGlossaryDialog):
|
||||
iconGlossaryDialog.setObjectName(_fromUtf8("iconGlossaryDialog"))
|
||||
iconGlossaryDialog.resize(400, 300)
|
||||
self.buttonBox = QtGui.QDialogButtonBox(iconGlossaryDialog)
|
||||
self.buttonBox.setGeometry(QtCore.QRect(50, 260, 341, 32))
|
||||
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
|
||||
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
|
||||
self.buttonBox.setObjectName(_fromUtf8("buttonBox"))
|
||||
self.groupBox = QtGui.QGroupBox(iconGlossaryDialog)
|
||||
self.groupBox.setGeometry(QtCore.QRect(10, 10, 381, 241))
|
||||
self.groupBox.setObjectName(_fromUtf8("groupBox"))
|
||||
self.label = QtGui.QLabel(self.groupBox)
|
||||
self.label.setGeometry(QtCore.QRect(20, 30, 21, 21))
|
||||
self.label.setText(_fromUtf8(""))
|
||||
self.label.setPixmap(QtGui.QPixmap(_fromUtf8(":/newPrefix/images/redicon.png")))
|
||||
self.label.setObjectName(_fromUtf8("label"))
|
||||
self.label_2 = QtGui.QLabel(self.groupBox)
|
||||
self.label_2.setGeometry(QtCore.QRect(50, 30, 281, 20))
|
||||
self.label_2.setObjectName(_fromUtf8("label_2"))
|
||||
self.label_3 = QtGui.QLabel(self.groupBox)
|
||||
self.label_3.setGeometry(QtCore.QRect(20, 70, 16, 21))
|
||||
self.label_3.setText(_fromUtf8(""))
|
||||
self.label_3.setPixmap(QtGui.QPixmap(_fromUtf8(":/newPrefix/images/yellowicon.png")))
|
||||
self.label_3.setObjectName(_fromUtf8("label_3"))
|
||||
self.label_4 = QtGui.QLabel(self.groupBox)
|
||||
self.label_4.setGeometry(QtCore.QRect(50, 60, 321, 101))
|
||||
self.label_4.setWordWrap(True)
|
||||
self.label_4.setObjectName(_fromUtf8("label_4"))
|
||||
self.label_5 = QtGui.QLabel(self.groupBox)
|
||||
self.label_5.setGeometry(QtCore.QRect(20, 200, 21, 21))
|
||||
self.label_5.setText(_fromUtf8(""))
|
||||
self.label_5.setPixmap(QtGui.QPixmap(_fromUtf8(":/newPrefix/images/greenicon.png")))
|
||||
self.label_5.setObjectName(_fromUtf8("label_5"))
|
||||
self.label_6 = QtGui.QLabel(self.groupBox)
|
||||
self.label_6.setGeometry(QtCore.QRect(50, 200, 301, 31))
|
||||
self.label_6.setWordWrap(True)
|
||||
self.label_6.setObjectName(_fromUtf8("label_6"))
|
||||
self.labelPortNumber = QtGui.QLabel(self.groupBox)
|
||||
self.labelPortNumber.setGeometry(QtCore.QRect(50, 160, 321, 16))
|
||||
self.labelPortNumber.setObjectName(_fromUtf8("labelPortNumber"))
|
||||
|
||||
self.retranslateUi(iconGlossaryDialog)
|
||||
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), iconGlossaryDialog.accept)
|
||||
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), iconGlossaryDialog.reject)
|
||||
QtCore.QMetaObject.connectSlotsByName(iconGlossaryDialog)
|
||||
|
||||
def retranslateUi(self, iconGlossaryDialog):
|
||||
iconGlossaryDialog.setWindowTitle(QtGui.QApplication.translate("iconGlossaryDialog", "Icon Glossary", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.groupBox.setTitle(QtGui.QApplication.translate("iconGlossaryDialog", "Icon Glossary", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.label_2.setText(QtGui.QApplication.translate("iconGlossaryDialog", "You have no connections with other peers. ", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.label_4.setText(QtGui.QApplication.translate("iconGlossaryDialog", "You have made at least one connection to a peer using an outgoing connection but you have not yet received any incoming connections. Your firewall or home router probably isn\'t configured to foward incoming TCP connections to your computer. Bitmessage will work just fine but it would help the Bitmessage network if you allowed for incoming connections and will help you be a better-connected node.", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.label_6.setText(QtGui.QApplication.translate("iconGlossaryDialog", "You do have connections with other peers and your firewall is correctly configured.", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.labelPortNumber.setText(QtGui.QApplication.translate("iconGlossaryDialog", "You are using TCP port ?. (This can be changed in the settings).", None, QtGui.QApplication.UnicodeUTF8))
|
||||
|
||||
import bitmessage_icons_rc
|
189
iconglossary.ui
Normal file
189
iconglossary.ui
Normal file
|
@ -0,0 +1,189 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>iconGlossaryDialog</class>
|
||||
<widget class="QDialog" name="iconGlossaryDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Icon Glossary</string>
|
||||
</property>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>50</x>
|
||||
<y>260</y>
|
||||
<width>341</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>381</width>
|
||||
<height>241</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Icon Glossary</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>30</y>
|
||||
<width>21</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="bitmessage_icons.qrc">:/newPrefix/images/redicon.png</pixmap>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>50</x>
|
||||
<y>30</y>
|
||||
<width>281</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>You have no connections with other peers. </string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>70</y>
|
||||
<width>16</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="bitmessage_icons.qrc">:/newPrefix/images/yellowicon.png</pixmap>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>50</x>
|
||||
<y>60</y>
|
||||
<width>321</width>
|
||||
<height>101</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>You have made at least one connection to a peer using an outgoing connection but you have not yet received any incoming connections. Your firewall or home router probably isn't configured to foward incoming TCP connections to your computer. Bitmessage will work just fine but it would help the Bitmessage network if you allowed for incoming connections and will help you be a better-connected node.</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>200</y>
|
||||
<width>21</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="bitmessage_icons.qrc">:/newPrefix/images/greenicon.png</pixmap>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>50</x>
|
||||
<y>200</y>
|
||||
<width>301</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>You do have connections with other peers and your firewall is correctly configured.</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="labelPortNumber">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>50</x>
|
||||
<y>160</y>
|
||||
<width>321</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>You are using TCP port ?. (This can be changed in the settings).</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="bitmessage_icons.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>iconGlossaryDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>iconGlossaryDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
70
newaddressdialog.py
Normal file
70
newaddressdialog.py
Normal file
|
@ -0,0 +1,70 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Form implementation generated from reading ui file 'newaddressdialog.ui'
|
||||
#
|
||||
# Created: Tue Sep 25 16:40:04 2012
|
||||
# by: PyQt4 UI code generator 4.9.4
|
||||
#
|
||||
# WARNING! All changes made in this file will be lost!
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
try:
|
||||
_fromUtf8 = QtCore.QString.fromUtf8
|
||||
except AttributeError:
|
||||
_fromUtf8 = lambda s: s
|
||||
|
||||
class Ui_NewAddressDialog(object):
|
||||
def setupUi(self, NewAddressDialog):
|
||||
NewAddressDialog.setObjectName(_fromUtf8("NewAddressDialog"))
|
||||
NewAddressDialog.resize(368, 257)
|
||||
self.buttonBox = QtGui.QDialogButtonBox(NewAddressDialog)
|
||||
self.buttonBox.setGeometry(QtCore.QRect(160, 220, 201, 32))
|
||||
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
|
||||
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
|
||||
self.buttonBox.setObjectName(_fromUtf8("buttonBox"))
|
||||
self.label = QtGui.QLabel(NewAddressDialog)
|
||||
self.label.setGeometry(QtCore.QRect(10, 10, 351, 31))
|
||||
self.label.setWordWrap(True)
|
||||
self.label.setObjectName(_fromUtf8("label"))
|
||||
self.label_2 = QtGui.QLabel(NewAddressDialog)
|
||||
self.label_2.setGeometry(QtCore.QRect(20, 50, 301, 20))
|
||||
self.label_2.setObjectName(_fromUtf8("label_2"))
|
||||
self.newaddresslabel = QtGui.QLineEdit(NewAddressDialog)
|
||||
self.newaddresslabel.setGeometry(QtCore.QRect(20, 70, 341, 20))
|
||||
self.newaddresslabel.setObjectName(_fromUtf8("newaddresslabel"))
|
||||
self.radioButtonMostAvailable = QtGui.QRadioButton(NewAddressDialog)
|
||||
self.radioButtonMostAvailable.setGeometry(QtCore.QRect(20, 110, 401, 16))
|
||||
self.radioButtonMostAvailable.setChecked(True)
|
||||
self.radioButtonMostAvailable.setObjectName(_fromUtf8("radioButtonMostAvailable"))
|
||||
self.radioButtonExisting = QtGui.QRadioButton(NewAddressDialog)
|
||||
self.radioButtonExisting.setGeometry(QtCore.QRect(20, 150, 271, 18))
|
||||
self.radioButtonExisting.setChecked(False)
|
||||
self.radioButtonExisting.setObjectName(_fromUtf8("radioButtonExisting"))
|
||||
self.label_3 = QtGui.QLabel(NewAddressDialog)
|
||||
self.label_3.setGeometry(QtCore.QRect(33, 123, 331, 21))
|
||||
self.label_3.setObjectName(_fromUtf8("label_3"))
|
||||
self.label_4 = QtGui.QLabel(NewAddressDialog)
|
||||
self.label_4.setGeometry(QtCore.QRect(37, 167, 341, 16))
|
||||
self.label_4.setObjectName(_fromUtf8("label_4"))
|
||||
self.comboBoxExisting = QtGui.QComboBox(NewAddressDialog)
|
||||
self.comboBoxExisting.setEnabled(False)
|
||||
self.comboBoxExisting.setGeometry(QtCore.QRect(40, 190, 321, 22))
|
||||
self.comboBoxExisting.setEditable(True)
|
||||
self.comboBoxExisting.setObjectName(_fromUtf8("comboBoxExisting"))
|
||||
|
||||
self.retranslateUi(NewAddressDialog)
|
||||
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), NewAddressDialog.accept)
|
||||
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), NewAddressDialog.reject)
|
||||
QtCore.QObject.connect(self.radioButtonExisting, QtCore.SIGNAL(_fromUtf8("toggled(bool)")), self.comboBoxExisting.setEnabled)
|
||||
QtCore.QMetaObject.connectSlotsByName(NewAddressDialog)
|
||||
|
||||
def retranslateUi(self, NewAddressDialog):
|
||||
NewAddressDialog.setWindowTitle(QtGui.QApplication.translate("NewAddressDialog", "Create new Address", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.label.setText(QtGui.QApplication.translate("NewAddressDialog", "Here you may generate as many addresses as you like. Indeed, creating many addresses is encouraged.", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.label_2.setText(QtGui.QApplication.translate("NewAddressDialog", "Label (not shown to anyone except you)", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.radioButtonMostAvailable.setText(QtGui.QApplication.translate("NewAddressDialog", "Use the most available stream", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.radioButtonExisting.setText(QtGui.QApplication.translate("NewAddressDialog", "Use the same stream as an existing address", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.label_3.setText(QtGui.QApplication.translate("NewAddressDialog", " (best if this is the first of many addresses you will create)", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.label_4.setText(QtGui.QApplication.translate("NewAddressDialog", "(saves you some bandwidth and processing power)", None, QtGui.QApplication.UnicodeUTF8))
|
||||
|
206
newaddressdialog.ui
Normal file
206
newaddressdialog.ui
Normal file
|
@ -0,0 +1,206 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>NewAddressDialog</class>
|
||||
<widget class="QDialog" name="NewAddressDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>384</width>
|
||||
<height>257</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Create new Address</string>
|
||||
</property>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>160</x>
|
||||
<y>220</y>
|
||||
<width>201</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>0</y>
|
||||
<width>361</width>
|
||||
<height>41</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Here you may generate as many addresses as you like. Indeed, creating and abandoning addresses is encouraged.</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>50</y>
|
||||
<width>301</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Label (not shown to anyone except you)</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="newaddresslabel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>70</y>
|
||||
<width>351</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QRadioButton" name="radioButtonMostAvailable">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>110</y>
|
||||
<width>401</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Use the most available stream</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QRadioButton" name="radioButtonExisting">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>150</y>
|
||||
<width>351</width>
|
||||
<height>18</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Use the same stream as an existing address</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>35</x>
|
||||
<y>127</y>
|
||||
<width>351</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string> (best if this is the first of many addresses you will create)</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>37</x>
|
||||
<y>167</y>
|
||||
<width>351</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>(saves you some bandwidth and processing power)</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="comboBoxExisting">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>40</x>
|
||||
<y>190</y>
|
||||
<width>331</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>NewAddressDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>360</x>
|
||||
<y>234</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>256</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>NewAddressDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>360</x>
|
||||
<y>240</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>256</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>radioButtonExisting</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>comboBoxExisting</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>30</x>
|
||||
<y>158</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>99</x>
|
||||
<y>199</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
60
newsubscriptiondialog.py
Normal file
60
newsubscriptiondialog.py
Normal file
|
@ -0,0 +1,60 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Form implementation generated from reading ui file 'newsubscriptiondialog.ui'
|
||||
#
|
||||
# Created: Fri Oct 19 15:30:41 2012
|
||||
# by: PyQt4 UI code generator 4.9.4
|
||||
#
|
||||
# WARNING! All changes made in this file will be lost!
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
try:
|
||||
_fromUtf8 = QtCore.QString.fromUtf8
|
||||
except AttributeError:
|
||||
_fromUtf8 = lambda s: s
|
||||
|
||||
class Ui_NewSubscriptionDialog(object):
|
||||
def setupUi(self, NewSubscriptionDialog):
|
||||
NewSubscriptionDialog.setObjectName(_fromUtf8("NewSubscriptionDialog"))
|
||||
NewSubscriptionDialog.resize(368, 192)
|
||||
self.formLayout = QtGui.QFormLayout(NewSubscriptionDialog)
|
||||
self.formLayout.setFieldGrowthPolicy(QtGui.QFormLayout.AllNonFixedFieldsGrow)
|
||||
self.formLayout.setObjectName(_fromUtf8("formLayout"))
|
||||
self.label_2 = QtGui.QLabel(NewSubscriptionDialog)
|
||||
self.label_2.setObjectName(_fromUtf8("label_2"))
|
||||
self.formLayout.setWidget(0, QtGui.QFormLayout.SpanningRole, self.label_2)
|
||||
self.newsubscriptionlabel = QtGui.QLineEdit(NewSubscriptionDialog)
|
||||
self.newsubscriptionlabel.setObjectName(_fromUtf8("newsubscriptionlabel"))
|
||||
self.formLayout.setWidget(2, QtGui.QFormLayout.SpanningRole, self.newsubscriptionlabel)
|
||||
self.label = QtGui.QLabel(NewSubscriptionDialog)
|
||||
self.label.setObjectName(_fromUtf8("label"))
|
||||
self.formLayout.setWidget(4, QtGui.QFormLayout.LabelRole, self.label)
|
||||
spacerItem = QtGui.QSpacerItem(302, 10, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
|
||||
self.formLayout.setItem(4, QtGui.QFormLayout.FieldRole, spacerItem)
|
||||
self.lineEditSubscriptionAddress = QtGui.QLineEdit(NewSubscriptionDialog)
|
||||
self.lineEditSubscriptionAddress.setObjectName(_fromUtf8("lineEditSubscriptionAddress"))
|
||||
self.formLayout.setWidget(5, QtGui.QFormLayout.SpanningRole, self.lineEditSubscriptionAddress)
|
||||
self.buttonBox = QtGui.QDialogButtonBox(NewSubscriptionDialog)
|
||||
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
|
||||
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
|
||||
self.buttonBox.setObjectName(_fromUtf8("buttonBox"))
|
||||
self.formLayout.setWidget(8, QtGui.QFormLayout.FieldRole, self.buttonBox)
|
||||
spacerItem1 = QtGui.QSpacerItem(20, 10, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
|
||||
self.formLayout.setItem(7, QtGui.QFormLayout.FieldRole, spacerItem1)
|
||||
self.labelSubscriptionAddressCheck = QtGui.QLabel(NewSubscriptionDialog)
|
||||
self.labelSubscriptionAddressCheck.setText(_fromUtf8(""))
|
||||
self.labelSubscriptionAddressCheck.setWordWrap(True)
|
||||
self.labelSubscriptionAddressCheck.setObjectName(_fromUtf8("labelSubscriptionAddressCheck"))
|
||||
self.formLayout.setWidget(6, QtGui.QFormLayout.SpanningRole, self.labelSubscriptionAddressCheck)
|
||||
|
||||
self.retranslateUi(NewSubscriptionDialog)
|
||||
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), NewSubscriptionDialog.accept)
|
||||
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), NewSubscriptionDialog.reject)
|
||||
QtCore.QMetaObject.connectSlotsByName(NewSubscriptionDialog)
|
||||
|
||||
def retranslateUi(self, NewSubscriptionDialog):
|
||||
NewSubscriptionDialog.setWindowTitle(QtGui.QApplication.translate("NewSubscriptionDialog", "Add new entry", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.label_2.setText(QtGui.QApplication.translate("NewSubscriptionDialog", "Label", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.label.setText(QtGui.QApplication.translate("NewSubscriptionDialog", "Address", None, QtGui.QApplication.UnicodeUTF8))
|
||||
|
123
newsubscriptiondialog.ui
Normal file
123
newsubscriptiondialog.ui
Normal file
|
@ -0,0 +1,123 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>NewSubscriptionDialog</class>
|
||||
<widget class="QDialog" name="NewSubscriptionDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>368</width>
|
||||
<height>192</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Add new entry</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||
</property>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Label</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QLineEdit" name="newsubscriptionlabel"/>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Address</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>302</width>
|
||||
<height>10</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="2">
|
||||
<widget class="QLineEdit" name="lineEditSubscriptionAddress"/>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>10</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="6" column="0" colspan="2">
|
||||
<widget class="QLabel" name="labelSubscriptionAddressCheck">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>NewSubscriptionDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>360</x>
|
||||
<y>234</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>256</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>NewSubscriptionDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>360</x>
|
||||
<y>240</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>256</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
45
rsa/__init__.py
Normal file
45
rsa/__init__.py
Normal file
|
@ -0,0 +1,45 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright 2011 Sybren A. Stüvel <sybren@stuvel.eu>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
"""RSA module
|
||||
|
||||
Module for calculating large primes, and RSA encryption, decryption, signing
|
||||
and verification. Includes generating public and private keys.
|
||||
|
||||
WARNING: this implementation does not use random padding, compression of the
|
||||
cleartext input to prevent repetitions, or other common security improvements.
|
||||
Use with care.
|
||||
|
||||
If you want to have a more secure implementation, use the functions from the
|
||||
``rsa.pkcs1`` module.
|
||||
|
||||
"""
|
||||
|
||||
__author__ = "Sybren Stuvel, Barry Mead and Yesudeep Mangalapilly"
|
||||
__date__ = "2012-06-17"
|
||||
__version__ = '3.1.1'
|
||||
|
||||
from rsa.key import newkeys, PrivateKey, PublicKey
|
||||
from rsa.pkcs1 import encrypt, decrypt, sign, verify, DecryptionError, \
|
||||
VerificationError
|
||||
|
||||
# Do doctest if we're run directly
|
||||
if __name__ == "__main__":
|
||||
import doctest
|
||||
doctest.testmod()
|
||||
|
||||
__all__ = ["newkeys", "encrypt", "decrypt", "sign", "verify", 'PublicKey',
|
||||
'PrivateKey', 'DecryptionError', 'VerificationError']
|
||||
|
BIN
rsa/__init__.pyc
Normal file
BIN
rsa/__init__.pyc
Normal file
Binary file not shown.
160
rsa/_compat.py
Normal file
160
rsa/_compat.py
Normal file
|
@ -0,0 +1,160 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright 2011 Sybren A. Stüvel <sybren@stuvel.eu>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
"""Python compatibility wrappers."""
|
||||
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import sys
|
||||
from struct import pack
|
||||
|
||||
try:
|
||||
MAX_INT = sys.maxsize
|
||||
except AttributeError:
|
||||
MAX_INT = sys.maxint
|
||||
|
||||
MAX_INT64 = (1 << 63) - 1
|
||||
MAX_INT32 = (1 << 31) - 1
|
||||
MAX_INT16 = (1 << 15) - 1
|
||||
|
||||
# Determine the word size of the processor.
|
||||
if MAX_INT == MAX_INT64:
|
||||
# 64-bit processor.
|
||||
MACHINE_WORD_SIZE = 64
|
||||
elif MAX_INT == MAX_INT32:
|
||||
# 32-bit processor.
|
||||
MACHINE_WORD_SIZE = 32
|
||||
else:
|
||||
# Else we just assume 64-bit processor keeping up with modern times.
|
||||
MACHINE_WORD_SIZE = 64
|
||||
|
||||
|
||||
try:
|
||||
# < Python3
|
||||
unicode_type = unicode
|
||||
have_python3 = False
|
||||
except NameError:
|
||||
# Python3.
|
||||
unicode_type = str
|
||||
have_python3 = True
|
||||
|
||||
# Fake byte literals.
|
||||
if str is unicode_type:
|
||||
def byte_literal(s):
|
||||
return s.encode('latin1')
|
||||
else:
|
||||
def byte_literal(s):
|
||||
return s
|
||||
|
||||
# ``long`` is no more. Do type detection using this instead.
|
||||
try:
|
||||
integer_types = (int, long)
|
||||
except NameError:
|
||||
integer_types = (int,)
|
||||
|
||||
b = byte_literal
|
||||
|
||||
try:
|
||||
# Python 2.6 or higher.
|
||||
bytes_type = bytes
|
||||
except NameError:
|
||||
# Python 2.5
|
||||
bytes_type = str
|
||||
|
||||
|
||||
# To avoid calling b() multiple times in tight loops.
|
||||
ZERO_BYTE = b('\x00')
|
||||
EMPTY_BYTE = b('')
|
||||
|
||||
|
||||
def is_bytes(obj):
|
||||
"""
|
||||
Determines whether the given value is a byte string.
|
||||
|
||||
:param obj:
|
||||
The value to test.
|
||||
:returns:
|
||||
``True`` if ``value`` is a byte string; ``False`` otherwise.
|
||||
"""
|
||||
return isinstance(obj, bytes_type)
|
||||
|
||||
|
||||
def is_integer(obj):
|
||||
"""
|
||||
Determines whether the given value is an integer.
|
||||
|
||||
:param obj:
|
||||
The value to test.
|
||||
:returns:
|
||||
``True`` if ``value`` is an integer; ``False`` otherwise.
|
||||
"""
|
||||
return isinstance(obj, integer_types)
|
||||
|
||||
|
||||
def byte(num):
|
||||
"""
|
||||
Converts a number between 0 and 255 (both inclusive) to a base-256 (byte)
|
||||
representation.
|
||||
|
||||
Use it as a replacement for ``chr`` where you are expecting a byte
|
||||
because this will work on all current versions of Python::
|
||||
|
||||
:param num:
|
||||
An unsigned integer between 0 and 255 (both inclusive).
|
||||
:returns:
|
||||
A single byte.
|
||||
"""
|
||||
return pack("B", num)
|
||||
|
||||
|
||||
def get_word_alignment(num, force_arch=64,
|
||||
_machine_word_size=MACHINE_WORD_SIZE):
|
||||
"""
|
||||
Returns alignment details for the given number based on the platform
|
||||
Python is running on.
|
||||
|
||||
:param num:
|
||||
Unsigned integral number.
|
||||
:param force_arch:
|
||||
If you don't want to use 64-bit unsigned chunks, set this to
|
||||
anything other than 64. 32-bit chunks will be preferred then.
|
||||
Default 64 will be used when on a 64-bit machine.
|
||||
:param _machine_word_size:
|
||||
(Internal) The machine word size used for alignment.
|
||||
:returns:
|
||||
4-tuple::
|
||||
|
||||
(word_bits, word_bytes,
|
||||
max_uint, packing_format_type)
|
||||
"""
|
||||
max_uint64 = 0xffffffffffffffff
|
||||
max_uint32 = 0xffffffff
|
||||
max_uint16 = 0xffff
|
||||
max_uint8 = 0xff
|
||||
|
||||
if force_arch == 64 and _machine_word_size >= 64 and num > max_uint32:
|
||||
# 64-bit unsigned integer.
|
||||
return 64, 8, max_uint64, "Q"
|
||||
elif num > max_uint16:
|
||||
# 32-bit unsigned integer
|
||||
return 32, 4, max_uint32, "L"
|
||||
elif num > max_uint8:
|
||||
# 16-bit unsigned integer.
|
||||
return 16, 2, max_uint16, "H"
|
||||
else:
|
||||
# 8-bit unsigned integer.
|
||||
return 8, 1, max_uint8, "B"
|
BIN
rsa/_compat.pyc
Normal file
BIN
rsa/_compat.pyc
Normal file
Binary file not shown.
442
rsa/_version133.py
Normal file
442
rsa/_version133.py
Normal file
|
@ -0,0 +1,442 @@
|
|||
"""RSA module
|
||||
pri = k[1] //Private part of keys d,p,q
|
||||
|
||||
Module for calculating large primes, and RSA encryption, decryption,
|
||||
signing and verification. Includes generating public and private keys.
|
||||
|
||||
WARNING: this code implements the mathematics of RSA. It is not suitable for
|
||||
real-world secure cryptography purposes. It has not been reviewed by a security
|
||||
expert. It does not include padding of data. There are many ways in which the
|
||||
output of this module, when used without any modification, can be sucessfully
|
||||
attacked.
|
||||
"""
|
||||
|
||||
__author__ = "Sybren Stuvel, Marloes de Boer and Ivo Tamboer"
|
||||
__date__ = "2010-02-05"
|
||||
__version__ = '1.3.3'
|
||||
|
||||
# NOTE: Python's modulo can return negative numbers. We compensate for
|
||||
# this behaviour using the abs() function
|
||||
|
||||
from cPickle import dumps, loads
|
||||
import base64
|
||||
import math
|
||||
import os
|
||||
import random
|
||||
import sys
|
||||
import types
|
||||
import zlib
|
||||
|
||||
from rsa._compat import byte
|
||||
|
||||
# Display a warning that this insecure version is imported.
|
||||
import warnings
|
||||
warnings.warn('Insecure version of the RSA module is imported as %s, be careful'
|
||||
% __name__)
|
||||
|
||||
def gcd(p, q):
|
||||
"""Returns the greatest common divisor of p and q
|
||||
|
||||
|
||||
>>> gcd(42, 6)
|
||||
6
|
||||
"""
|
||||
if p<q: return gcd(q, p)
|
||||
if q == 0: return p
|
||||
return gcd(q, abs(p%q))
|
||||
|
||||
def bytes2int(bytes):
|
||||
"""Converts a list of bytes or a string to an integer
|
||||
|
||||
>>> (128*256 + 64)*256 + + 15
|
||||
8405007
|
||||
>>> l = [128, 64, 15]
|
||||
>>> bytes2int(l)
|
||||
8405007
|
||||
"""
|
||||
|
||||
if not (type(bytes) is types.ListType or type(bytes) is types.StringType):
|
||||
raise TypeError("You must pass a string or a list")
|
||||
|
||||
# Convert byte stream to integer
|
||||
integer = 0
|
||||
for byte in bytes:
|
||||
integer *= 256
|
||||
if type(byte) is types.StringType: byte = ord(byte)
|
||||
integer += byte
|
||||
|
||||
return integer
|
||||
|
||||
def int2bytes(number):
|
||||
"""Converts a number to a string of bytes
|
||||
|
||||
>>> bytes2int(int2bytes(123456789))
|
||||
123456789
|
||||
"""
|
||||
|
||||
if not (type(number) is types.LongType or type(number) is types.IntType):
|
||||
raise TypeError("You must pass a long or an int")
|
||||
|
||||
string = ""
|
||||
|
||||
while number > 0:
|
||||
string = "%s%s" % (byte(number & 0xFF), string)
|
||||
number /= 256
|
||||
|
||||
return string
|
||||
|
||||
def fast_exponentiation(a, p, n):
|
||||
"""Calculates r = a^p mod n
|
||||
"""
|
||||
result = a % n
|
||||
remainders = []
|
||||
while p != 1:
|
||||
remainders.append(p & 1)
|
||||
p = p >> 1
|
||||
while remainders:
|
||||
rem = remainders.pop()
|
||||
result = ((a ** rem) * result ** 2) % n
|
||||
return result
|
||||
|
||||
def read_random_int(nbits):
|
||||
"""Reads a random integer of approximately nbits bits rounded up
|
||||
to whole bytes"""
|
||||
|
||||
nbytes = ceil(nbits/8.)
|
||||
randomdata = os.urandom(nbytes)
|
||||
return bytes2int(randomdata)
|
||||
|
||||
def ceil(x):
|
||||
"""ceil(x) -> int(math.ceil(x))"""
|
||||
|
||||
return int(math.ceil(x))
|
||||
|
||||
def randint(minvalue, maxvalue):
|
||||
"""Returns a random integer x with minvalue <= x <= maxvalue"""
|
||||
|
||||
# Safety - get a lot of random data even if the range is fairly
|
||||
# small
|
||||
min_nbits = 32
|
||||
|
||||
# The range of the random numbers we need to generate
|
||||
range = maxvalue - minvalue
|
||||
|
||||
# Which is this number of bytes
|
||||
rangebytes = ceil(math.log(range, 2) / 8.)
|
||||
|
||||
# Convert to bits, but make sure it's always at least min_nbits*2
|
||||
rangebits = max(rangebytes * 8, min_nbits * 2)
|
||||
|
||||
# Take a random number of bits between min_nbits and rangebits
|
||||
nbits = random.randint(min_nbits, rangebits)
|
||||
|
||||
return (read_random_int(nbits) % range) + minvalue
|
||||
|
||||
def fermat_little_theorem(p):
|
||||
"""Returns 1 if p may be prime, and something else if p definitely
|
||||
is not prime"""
|
||||
|
||||
a = randint(1, p-1)
|
||||
return fast_exponentiation(a, p-1, p)
|
||||
|
||||
def jacobi(a, b):
|
||||
"""Calculates the value of the Jacobi symbol (a/b)
|
||||
"""
|
||||
|
||||
if a % b == 0:
|
||||
return 0
|
||||
result = 1
|
||||
while a > 1:
|
||||
if a & 1:
|
||||
if ((a-1)*(b-1) >> 2) & 1:
|
||||
result = -result
|
||||
b, a = a, b % a
|
||||
else:
|
||||
if ((b ** 2 - 1) >> 3) & 1:
|
||||
result = -result
|
||||
a = a >> 1
|
||||
return result
|
||||
|
||||
def jacobi_witness(x, n):
|
||||
"""Returns False if n is an Euler pseudo-prime with base x, and
|
||||
True otherwise.
|
||||
"""
|
||||
|
||||
j = jacobi(x, n) % n
|
||||
f = fast_exponentiation(x, (n-1)/2, n)
|
||||
|
||||
if j == f: return False
|
||||
return True
|
||||
|
||||
def randomized_primality_testing(n, k):
|
||||
"""Calculates whether n is composite (which is always correct) or
|
||||
prime (which is incorrect with error probability 2**-k)
|
||||
|
||||
Returns False if the number if composite, and True if it's
|
||||
probably prime.
|
||||
"""
|
||||
|
||||
q = 0.5 # Property of the jacobi_witness function
|
||||
|
||||
# t = int(math.ceil(k / math.log(1/q, 2)))
|
||||
t = ceil(k / math.log(1/q, 2))
|
||||
for i in range(t+1):
|
||||
x = randint(1, n-1)
|
||||
if jacobi_witness(x, n): return False
|
||||
|
||||
return True
|
||||
|
||||
def is_prime(number):
|
||||
"""Returns True if the number is prime, and False otherwise.
|
||||
|
||||
>>> is_prime(42)
|
||||
0
|
||||
>>> is_prime(41)
|
||||
1
|
||||
"""
|
||||
|
||||
"""
|
||||
if not fermat_little_theorem(number) == 1:
|
||||
# Not prime, according to Fermat's little theorem
|
||||
return False
|
||||
"""
|
||||
|
||||
if randomized_primality_testing(number, 5):
|
||||
# Prime, according to Jacobi
|
||||
return True
|
||||
|
||||
# Not prime
|
||||
return False
|
||||
|
||||
|
||||
def getprime(nbits):
|
||||
"""Returns a prime number of max. 'math.ceil(nbits/8)*8' bits. In
|
||||
other words: nbits is rounded up to whole bytes.
|
||||
|
||||
>>> p = getprime(8)
|
||||
>>> is_prime(p-1)
|
||||
0
|
||||
>>> is_prime(p)
|
||||
1
|
||||
>>> is_prime(p+1)
|
||||
0
|
||||
"""
|
||||
|
||||
nbytes = int(math.ceil(nbits/8.))
|
||||
|
||||
while True:
|
||||
integer = read_random_int(nbits)
|
||||
|
||||
# Make sure it's odd
|
||||
integer |= 1
|
||||
|
||||
# Test for primeness
|
||||
if is_prime(integer): break
|
||||
|
||||
# Retry if not prime
|
||||
|
||||
return integer
|
||||
|
||||
def are_relatively_prime(a, b):
|
||||
"""Returns True if a and b are relatively prime, and False if they
|
||||
are not.
|
||||
|
||||
>>> are_relatively_prime(2, 3)
|
||||
1
|
||||
>>> are_relatively_prime(2, 4)
|
||||
0
|
||||
"""
|
||||
|
||||
d = gcd(a, b)
|
||||
return (d == 1)
|
||||
|
||||
def find_p_q(nbits):
|
||||
"""Returns a tuple of two different primes of nbits bits"""
|
||||
|
||||
p = getprime(nbits)
|
||||
while True:
|
||||
q = getprime(nbits)
|
||||
if not q == p: break
|
||||
|
||||
return (p, q)
|
||||
|
||||
def extended_euclid_gcd(a, b):
|
||||
"""Returns a tuple (d, i, j) such that d = gcd(a, b) = ia + jb
|
||||
"""
|
||||
|
||||
if b == 0:
|
||||
return (a, 1, 0)
|
||||
|
||||
q = abs(a % b)
|
||||
r = long(a / b)
|
||||
(d, k, l) = extended_euclid_gcd(b, q)
|
||||
|
||||
return (d, l, k - l*r)
|
||||
|
||||
# Main function: calculate encryption and decryption keys
|
||||
def calculate_keys(p, q, nbits):
|
||||
"""Calculates an encryption and a decryption key for p and q, and
|
||||
returns them as a tuple (e, d)"""
|
||||
|
||||
n = p * q
|
||||
phi_n = (p-1) * (q-1)
|
||||
|
||||
while True:
|
||||
# Make sure e has enough bits so we ensure "wrapping" through
|
||||
# modulo n
|
||||
e = getprime(max(8, nbits/2))
|
||||
if are_relatively_prime(e, n) and are_relatively_prime(e, phi_n): break
|
||||
|
||||
(d, i, j) = extended_euclid_gcd(e, phi_n)
|
||||
|
||||
if not d == 1:
|
||||
raise Exception("e (%d) and phi_n (%d) are not relatively prime" % (e, phi_n))
|
||||
|
||||
if not (e * i) % phi_n == 1:
|
||||
raise Exception("e (%d) and i (%d) are not mult. inv. modulo phi_n (%d)" % (e, i, phi_n))
|
||||
|
||||
return (e, i)
|
||||
|
||||
|
||||
def gen_keys(nbits):
|
||||
"""Generate RSA keys of nbits bits. Returns (p, q, e, d).
|
||||
|
||||
Note: this can take a long time, depending on the key size.
|
||||
"""
|
||||
|
||||
while True:
|
||||
(p, q) = find_p_q(nbits)
|
||||
(e, d) = calculate_keys(p, q, nbits)
|
||||
|
||||
# For some reason, d is sometimes negative. We don't know how
|
||||
# to fix it (yet), so we keep trying until everything is shiny
|
||||
if d > 0: break
|
||||
|
||||
return (p, q, e, d)
|
||||
|
||||
def gen_pubpriv_keys(nbits):
|
||||
"""Generates public and private keys, and returns them as (pub,
|
||||
priv).
|
||||
|
||||
The public key consists of a dict {e: ..., , n: ....). The private
|
||||
key consists of a dict {d: ...., p: ...., q: ....).
|
||||
"""
|
||||
|
||||
(p, q, e, d) = gen_keys(nbits)
|
||||
|
||||
return ( {'e': e, 'n': p*q}, {'d': d, 'p': p, 'q': q} )
|
||||
|
||||
def encrypt_int(message, ekey, n):
|
||||
"""Encrypts a message using encryption key 'ekey', working modulo
|
||||
n"""
|
||||
|
||||
if type(message) is types.IntType:
|
||||
return encrypt_int(long(message), ekey, n)
|
||||
|
||||
if not type(message) is types.LongType:
|
||||
raise TypeError("You must pass a long or an int")
|
||||
|
||||
if message > 0 and \
|
||||
math.floor(math.log(message, 2)) > math.floor(math.log(n, 2)):
|
||||
raise OverflowError("The message is too long")
|
||||
|
||||
return fast_exponentiation(message, ekey, n)
|
||||
|
||||
def decrypt_int(cyphertext, dkey, n):
|
||||
"""Decrypts a cypher text using the decryption key 'dkey', working
|
||||
modulo n"""
|
||||
|
||||
return encrypt_int(cyphertext, dkey, n)
|
||||
|
||||
def sign_int(message, dkey, n):
|
||||
"""Signs 'message' using key 'dkey', working modulo n"""
|
||||
|
||||
return decrypt_int(message, dkey, n)
|
||||
|
||||
def verify_int(signed, ekey, n):
|
||||
"""verifies 'signed' using key 'ekey', working modulo n"""
|
||||
|
||||
return encrypt_int(signed, ekey, n)
|
||||
|
||||
def picklechops(chops):
|
||||
"""Pickles and base64encodes it's argument chops"""
|
||||
|
||||
value = zlib.compress(dumps(chops))
|
||||
encoded = base64.encodestring(value)
|
||||
return encoded.strip()
|
||||
|
||||
def unpicklechops(string):
|
||||
"""base64decodes and unpickes it's argument string into chops"""
|
||||
|
||||
return loads(zlib.decompress(base64.decodestring(string)))
|
||||
|
||||
def chopstring(message, key, n, funcref):
|
||||
"""Splits 'message' into chops that are at most as long as n,
|
||||
converts these into integers, and calls funcref(integer, key, n)
|
||||
for each chop.
|
||||
|
||||
Used by 'encrypt' and 'sign'.
|
||||
"""
|
||||
|
||||
msglen = len(message)
|
||||
mbits = msglen * 8
|
||||
nbits = int(math.floor(math.log(n, 2)))
|
||||
nbytes = nbits / 8
|
||||
blocks = msglen / nbytes
|
||||
|
||||
if msglen % nbytes > 0:
|
||||
blocks += 1
|
||||
|
||||
cypher = []
|
||||
|
||||
for bindex in range(blocks):
|
||||
offset = bindex * nbytes
|
||||
block = message[offset:offset+nbytes]
|
||||
value = bytes2int(block)
|
||||
cypher.append(funcref(value, key, n))
|
||||
|
||||
return picklechops(cypher)
|
||||
|
||||
def gluechops(chops, key, n, funcref):
|
||||
"""Glues chops back together into a string. calls
|
||||
funcref(integer, key, n) for each chop.
|
||||
|
||||
Used by 'decrypt' and 'verify'.
|
||||
"""
|
||||
message = ""
|
||||
|
||||
chops = unpicklechops(chops)
|
||||
|
||||
for cpart in chops:
|
||||
mpart = funcref(cpart, key, n)
|
||||
message += int2bytes(mpart)
|
||||
|
||||
return message
|
||||
|
||||
def encrypt(message, key):
|
||||
"""Encrypts a string 'message' with the public key 'key'"""
|
||||
|
||||
return chopstring(message, key['e'], key['n'], encrypt_int)
|
||||
|
||||
def sign(message, key):
|
||||
"""Signs a string 'message' with the private key 'key'"""
|
||||
|
||||
return chopstring(message, key['d'], key['p']*key['q'], decrypt_int)
|
||||
|
||||
def decrypt(cypher, key):
|
||||
"""Decrypts a cypher with the private key 'key'"""
|
||||
|
||||
return gluechops(cypher, key['d'], key['p']*key['q'], decrypt_int)
|
||||
|
||||
def verify(cypher, key):
|
||||
"""Verifies a cypher with the public key 'key'"""
|
||||
|
||||
return gluechops(cypher, key['e'], key['n'], encrypt_int)
|
||||
|
||||
# Do doctest if we're not imported
|
||||
if __name__ == "__main__":
|
||||
import doctest
|
||||
doctest.testmod()
|
||||
|
||||
__all__ = ["gen_pubpriv_keys", "encrypt", "decrypt", "sign", "verify"]
|
||||
|
529
rsa/_version200.py
Normal file
529
rsa/_version200.py
Normal file
|
@ -0,0 +1,529 @@
|
|||
"""RSA module
|
||||
|
||||
Module for calculating large primes, and RSA encryption, decryption,
|
||||
signing and verification. Includes generating public and private keys.
|
||||
|
||||
WARNING: this implementation does not use random padding, compression of the
|
||||
cleartext input to prevent repetitions, or other common security improvements.
|
||||
Use with care.
|
||||
|
||||
"""
|
||||
|
||||
__author__ = "Sybren Stuvel, Marloes de Boer, Ivo Tamboer, and Barry Mead"
|
||||
__date__ = "2010-02-08"
|
||||
__version__ = '2.0'
|
||||
|
||||
import math
|
||||
import os
|
||||
import random
|
||||
import sys
|
||||
import types
|
||||
from rsa._compat import byte
|
||||
|
||||
# Display a warning that this insecure version is imported.
|
||||
import warnings
|
||||
warnings.warn('Insecure version of the RSA module is imported as %s' % __name__)
|
||||
|
||||
|
||||
def bit_size(number):
|
||||
"""Returns the number of bits required to hold a specific long number"""
|
||||
|
||||
return int(math.ceil(math.log(number,2)))
|
||||
|
||||
def gcd(p, q):
|
||||
"""Returns the greatest common divisor of p and q
|
||||
>>> gcd(48, 180)
|
||||
12
|
||||
"""
|
||||
# Iterateive Version is faster and uses much less stack space
|
||||
while q != 0:
|
||||
if p < q: (p,q) = (q,p)
|
||||
(p,q) = (q, p % q)
|
||||
return p
|
||||
|
||||
|
||||
def bytes2int(bytes):
|
||||
"""Converts a list of bytes or a string to an integer
|
||||
|
||||
>>> (((128 * 256) + 64) * 256) + 15
|
||||
8405007
|
||||
>>> l = [128, 64, 15]
|
||||
>>> bytes2int(l) #same as bytes2int('\x80@\x0f')
|
||||
8405007
|
||||
"""
|
||||
|
||||
if not (type(bytes) is types.ListType or type(bytes) is types.StringType):
|
||||
raise TypeError("You must pass a string or a list")
|
||||
|
||||
# Convert byte stream to integer
|
||||
integer = 0
|
||||
for byte in bytes:
|
||||
integer *= 256
|
||||
if type(byte) is types.StringType: byte = ord(byte)
|
||||
integer += byte
|
||||
|
||||
return integer
|
||||
|
||||
def int2bytes(number):
|
||||
"""
|
||||
Converts a number to a string of bytes
|
||||
"""
|
||||
|
||||
if not (type(number) is types.LongType or type(number) is types.IntType):
|
||||
raise TypeError("You must pass a long or an int")
|
||||
|
||||
string = ""
|
||||
|
||||
while number > 0:
|
||||
string = "%s%s" % (byte(number & 0xFF), string)
|
||||
number /= 256
|
||||
|
||||
return string
|
||||
|
||||
def to64(number):
|
||||
"""Converts a number in the range of 0 to 63 into base 64 digit
|
||||
character in the range of '0'-'9', 'A'-'Z', 'a'-'z','-','_'.
|
||||
|
||||
>>> to64(10)
|
||||
'A'
|
||||
"""
|
||||
|
||||
if not (type(number) is types.LongType or type(number) is types.IntType):
|
||||
raise TypeError("You must pass a long or an int")
|
||||
|
||||
if 0 <= number <= 9: #00-09 translates to '0' - '9'
|
||||
return byte(number + 48)
|
||||
|
||||
if 10 <= number <= 35:
|
||||
return byte(number + 55) #10-35 translates to 'A' - 'Z'
|
||||
|
||||
if 36 <= number <= 61:
|
||||
return byte(number + 61) #36-61 translates to 'a' - 'z'
|
||||
|
||||
if number == 62: # 62 translates to '-' (minus)
|
||||
return byte(45)
|
||||
|
||||
if number == 63: # 63 translates to '_' (underscore)
|
||||
return byte(95)
|
||||
|
||||
raise ValueError('Invalid Base64 value: %i' % number)
|
||||
|
||||
|
||||
def from64(number):
|
||||
"""Converts an ordinal character value in the range of
|
||||
0-9,A-Z,a-z,-,_ to a number in the range of 0-63.
|
||||
|
||||
>>> from64(49)
|
||||
1
|
||||
"""
|
||||
|
||||
if not (type(number) is types.LongType or type(number) is types.IntType):
|
||||
raise TypeError("You must pass a long or an int")
|
||||
|
||||
if 48 <= number <= 57: #ord('0') - ord('9') translates to 0-9
|
||||
return(number - 48)
|
||||
|
||||
if 65 <= number <= 90: #ord('A') - ord('Z') translates to 10-35
|
||||
return(number - 55)
|
||||
|
||||
if 97 <= number <= 122: #ord('a') - ord('z') translates to 36-61
|
||||
return(number - 61)
|
||||
|
||||
if number == 45: #ord('-') translates to 62
|
||||
return(62)
|
||||
|
||||
if number == 95: #ord('_') translates to 63
|
||||
return(63)
|
||||
|
||||
raise ValueError('Invalid Base64 value: %i' % number)
|
||||
|
||||
|
||||
def int2str64(number):
|
||||
"""Converts a number to a string of base64 encoded characters in
|
||||
the range of '0'-'9','A'-'Z,'a'-'z','-','_'.
|
||||
|
||||
>>> int2str64(123456789)
|
||||
'7MyqL'
|
||||
"""
|
||||
|
||||
if not (type(number) is types.LongType or type(number) is types.IntType):
|
||||
raise TypeError("You must pass a long or an int")
|
||||
|
||||
string = ""
|
||||
|
||||
while number > 0:
|
||||
string = "%s%s" % (to64(number & 0x3F), string)
|
||||
number /= 64
|
||||
|
||||
return string
|
||||
|
||||
|
||||
def str642int(string):
|
||||
"""Converts a base64 encoded string into an integer.
|
||||
The chars of this string in in the range '0'-'9','A'-'Z','a'-'z','-','_'
|
||||
|
||||
>>> str642int('7MyqL')
|
||||
123456789
|
||||
"""
|
||||
|
||||
if not (type(string) is types.ListType or type(string) is types.StringType):
|
||||
raise TypeError("You must pass a string or a list")
|
||||
|
||||
integer = 0
|
||||
for byte in string:
|
||||
integer *= 64
|
||||
if type(byte) is types.StringType: byte = ord(byte)
|
||||
integer += from64(byte)
|
||||
|
||||
return integer
|
||||
|
||||
def read_random_int(nbits):
|
||||
"""Reads a random integer of approximately nbits bits rounded up
|
||||
to whole bytes"""
|
||||
|
||||
nbytes = int(math.ceil(nbits/8.))
|
||||
randomdata = os.urandom(nbytes)
|
||||
return bytes2int(randomdata)
|
||||
|
||||
def randint(minvalue, maxvalue):
|
||||
"""Returns a random integer x with minvalue <= x <= maxvalue"""
|
||||
|
||||
# Safety - get a lot of random data even if the range is fairly
|
||||
# small
|
||||
min_nbits = 32
|
||||
|
||||
# The range of the random numbers we need to generate
|
||||
range = (maxvalue - minvalue) + 1
|
||||
|
||||
# Which is this number of bytes
|
||||
rangebytes = ((bit_size(range) + 7) / 8)
|
||||
|
||||
# Convert to bits, but make sure it's always at least min_nbits*2
|
||||
rangebits = max(rangebytes * 8, min_nbits * 2)
|
||||
|
||||
# Take a random number of bits between min_nbits and rangebits
|
||||
nbits = random.randint(min_nbits, rangebits)
|
||||
|
||||
return (read_random_int(nbits) % range) + minvalue
|
||||
|
||||
def jacobi(a, b):
|
||||
"""Calculates the value of the Jacobi symbol (a/b)
|
||||
where both a and b are positive integers, and b is odd
|
||||
"""
|
||||
|
||||
if a == 0: return 0
|
||||
result = 1
|
||||
while a > 1:
|
||||
if a & 1:
|
||||
if ((a-1)*(b-1) >> 2) & 1:
|
||||
result = -result
|
||||
a, b = b % a, a
|
||||
else:
|
||||
if (((b * b) - 1) >> 3) & 1:
|
||||
result = -result
|
||||
a >>= 1
|
||||
if a == 0: return 0
|
||||
return result
|
||||
|
||||
def jacobi_witness(x, n):
|
||||
"""Returns False if n is an Euler pseudo-prime with base x, and
|
||||
True otherwise.
|
||||
"""
|
||||
|
||||
j = jacobi(x, n) % n
|
||||
f = pow(x, (n-1)/2, n)
|
||||
|
||||
if j == f: return False
|
||||
return True
|
||||
|
||||
def randomized_primality_testing(n, k):
|
||||
"""Calculates whether n is composite (which is always correct) or
|
||||
prime (which is incorrect with error probability 2**-k)
|
||||
|
||||
Returns False if the number is composite, and True if it's
|
||||
probably prime.
|
||||
"""
|
||||
|
||||
# 50% of Jacobi-witnesses can report compositness of non-prime numbers
|
||||
|
||||
for i in range(k):
|
||||
x = randint(1, n-1)
|
||||
if jacobi_witness(x, n): return False
|
||||
|
||||
return True
|
||||
|
||||
def is_prime(number):
|
||||
"""Returns True if the number is prime, and False otherwise.
|
||||
|
||||
>>> is_prime(42)
|
||||
0
|
||||
>>> is_prime(41)
|
||||
1
|
||||
"""
|
||||
|
||||
if randomized_primality_testing(number, 6):
|
||||
# Prime, according to Jacobi
|
||||
return True
|
||||
|
||||
# Not prime
|
||||
return False
|
||||
|
||||
|
||||
def getprime(nbits):
|
||||
"""Returns a prime number of max. 'math.ceil(nbits/8)*8' bits. In
|
||||
other words: nbits is rounded up to whole bytes.
|
||||
|
||||
>>> p = getprime(8)
|
||||
>>> is_prime(p-1)
|
||||
0
|
||||
>>> is_prime(p)
|
||||
1
|
||||
>>> is_prime(p+1)
|
||||
0
|
||||
"""
|
||||
|
||||
while True:
|
||||
integer = read_random_int(nbits)
|
||||
|
||||
# Make sure it's odd
|
||||
integer |= 1
|
||||
|
||||
# Test for primeness
|
||||
if is_prime(integer): break
|
||||
|
||||
# Retry if not prime
|
||||
|
||||
return integer
|
||||
|
||||
def are_relatively_prime(a, b):
|
||||
"""Returns True if a and b are relatively prime, and False if they
|
||||
are not.
|
||||
|
||||
>>> are_relatively_prime(2, 3)
|
||||
1
|
||||
>>> are_relatively_prime(2, 4)
|
||||
0
|
||||
"""
|
||||
|
||||
d = gcd(a, b)
|
||||
return (d == 1)
|
||||
|
||||
def find_p_q(nbits):
|
||||
"""Returns a tuple of two different primes of nbits bits"""
|
||||
pbits = nbits + (nbits/16) #Make sure that p and q aren't too close
|
||||
qbits = nbits - (nbits/16) #or the factoring programs can factor n
|
||||
p = getprime(pbits)
|
||||
while True:
|
||||
q = getprime(qbits)
|
||||
#Make sure p and q are different.
|
||||
if not q == p: break
|
||||
return (p, q)
|
||||
|
||||
def extended_gcd(a, b):
|
||||
"""Returns a tuple (r, i, j) such that r = gcd(a, b) = ia + jb
|
||||
"""
|
||||
# r = gcd(a,b) i = multiplicitive inverse of a mod b
|
||||
# or j = multiplicitive inverse of b mod a
|
||||
# Neg return values for i or j are made positive mod b or a respectively
|
||||
# Iterateive Version is faster and uses much less stack space
|
||||
x = 0
|
||||
y = 1
|
||||
lx = 1
|
||||
ly = 0
|
||||
oa = a #Remember original a/b to remove
|
||||
ob = b #negative values from return results
|
||||
while b != 0:
|
||||
q = long(a/b)
|
||||
(a, b) = (b, a % b)
|
||||
(x, lx) = ((lx - (q * x)),x)
|
||||
(y, ly) = ((ly - (q * y)),y)
|
||||
if (lx < 0): lx += ob #If neg wrap modulo orignal b
|
||||
if (ly < 0): ly += oa #If neg wrap modulo orignal a
|
||||
return (a, lx, ly) #Return only positive values
|
||||
|
||||
# Main function: calculate encryption and decryption keys
|
||||
def calculate_keys(p, q, nbits):
|
||||
"""Calculates an encryption and a decryption key for p and q, and
|
||||
returns them as a tuple (e, d)"""
|
||||
|
||||
n = p * q
|
||||
phi_n = (p-1) * (q-1)
|
||||
|
||||
while True:
|
||||
# Make sure e has enough bits so we ensure "wrapping" through
|
||||
# modulo n
|
||||
e = max(65537,getprime(nbits/4))
|
||||
if are_relatively_prime(e, n) and are_relatively_prime(e, phi_n): break
|
||||
|
||||
(d, i, j) = extended_gcd(e, phi_n)
|
||||
|
||||
if not d == 1:
|
||||
raise Exception("e (%d) and phi_n (%d) are not relatively prime" % (e, phi_n))
|
||||
if (i < 0):
|
||||
raise Exception("New extended_gcd shouldn't return negative values")
|
||||
if not (e * i) % phi_n == 1:
|
||||
raise Exception("e (%d) and i (%d) are not mult. inv. modulo phi_n (%d)" % (e, i, phi_n))
|
||||
|
||||
return (e, i)
|
||||
|
||||
|
||||
def gen_keys(nbits):
|
||||
"""Generate RSA keys of nbits bits. Returns (p, q, e, d).
|
||||
|
||||
Note: this can take a long time, depending on the key size.
|
||||
"""
|
||||
|
||||
(p, q) = find_p_q(nbits)
|
||||
(e, d) = calculate_keys(p, q, nbits)
|
||||
|
||||
return (p, q, e, d)
|
||||
|
||||
def newkeys(nbits):
|
||||
"""Generates public and private keys, and returns them as (pub,
|
||||
priv).
|
||||
|
||||
The public key consists of a dict {e: ..., , n: ....). The private
|
||||
key consists of a dict {d: ...., p: ...., q: ....).
|
||||
"""
|
||||
nbits = max(9,nbits) # Don't let nbits go below 9 bits
|
||||
(p, q, e, d) = gen_keys(nbits)
|
||||
|
||||
return ( {'e': e, 'n': p*q}, {'d': d, 'p': p, 'q': q} )
|
||||
|
||||
def encrypt_int(message, ekey, n):
|
||||
"""Encrypts a message using encryption key 'ekey', working modulo n"""
|
||||
|
||||
if type(message) is types.IntType:
|
||||
message = long(message)
|
||||
|
||||
if not type(message) is types.LongType:
|
||||
raise TypeError("You must pass a long or int")
|
||||
|
||||
if message < 0 or message > n:
|
||||
raise OverflowError("The message is too long")
|
||||
|
||||
#Note: Bit exponents start at zero (bit counts start at 1) this is correct
|
||||
safebit = bit_size(n) - 2 #compute safe bit (MSB - 1)
|
||||
message += (1 << safebit) #add safebit to ensure folding
|
||||
|
||||
return pow(message, ekey, n)
|
||||
|
||||
def decrypt_int(cyphertext, dkey, n):
|
||||
"""Decrypts a cypher text using the decryption key 'dkey', working
|
||||
modulo n"""
|
||||
|
||||
message = pow(cyphertext, dkey, n)
|
||||
|
||||
safebit = bit_size(n) - 2 #compute safe bit (MSB - 1)
|
||||
message -= (1 << safebit) #remove safebit before decode
|
||||
|
||||
return message
|
||||
|
||||
def encode64chops(chops):
|
||||
"""base64encodes chops and combines them into a ',' delimited string"""
|
||||
|
||||
chips = [] #chips are character chops
|
||||
|
||||
for value in chops:
|
||||
chips.append(int2str64(value))
|
||||
|
||||
#delimit chops with comma
|
||||
encoded = ','.join(chips)
|
||||
|
||||
return encoded
|
||||
|
||||
def decode64chops(string):
|
||||
"""base64decodes and makes a ',' delimited string into chops"""
|
||||
|
||||
chips = string.split(',') #split chops at commas
|
||||
|
||||
chops = []
|
||||
|
||||
for string in chips: #make char chops (chips) into chops
|
||||
chops.append(str642int(string))
|
||||
|
||||
return chops
|
||||
|
||||
def chopstring(message, key, n, funcref):
|
||||
"""Chops the 'message' into integers that fit into n,
|
||||
leaving room for a safebit to be added to ensure that all
|
||||
messages fold during exponentiation. The MSB of the number n
|
||||
is not independant modulo n (setting it could cause overflow), so
|
||||
use the next lower bit for the safebit. Therefore reserve 2-bits
|
||||
in the number n for non-data bits. Calls specified encryption
|
||||
function for each chop.
|
||||
|
||||
Used by 'encrypt' and 'sign'.
|
||||
"""
|
||||
|
||||
msglen = len(message)
|
||||
mbits = msglen * 8
|
||||
#Set aside 2-bits so setting of safebit won't overflow modulo n.
|
||||
nbits = bit_size(n) - 2 # leave room for safebit
|
||||
nbytes = nbits / 8
|
||||
blocks = msglen / nbytes
|
||||
|
||||
if msglen % nbytes > 0:
|
||||
blocks += 1
|
||||
|
||||
cypher = []
|
||||
|
||||
for bindex in range(blocks):
|
||||
offset = bindex * nbytes
|
||||
block = message[offset:offset+nbytes]
|
||||
value = bytes2int(block)
|
||||
cypher.append(funcref(value, key, n))
|
||||
|
||||
return encode64chops(cypher) #Encode encrypted ints to base64 strings
|
||||
|
||||
def gluechops(string, key, n, funcref):
|
||||
"""Glues chops back together into a string. calls
|
||||
funcref(integer, key, n) for each chop.
|
||||
|
||||
Used by 'decrypt' and 'verify'.
|
||||
"""
|
||||
message = ""
|
||||
|
||||
chops = decode64chops(string) #Decode base64 strings into integer chops
|
||||
|
||||
for cpart in chops:
|
||||
mpart = funcref(cpart, key, n) #Decrypt each chop
|
||||
message += int2bytes(mpart) #Combine decrypted strings into a msg
|
||||
|
||||
return message
|
||||
|
||||
def encrypt(message, key):
|
||||
"""Encrypts a string 'message' with the public key 'key'"""
|
||||
if 'n' not in key:
|
||||
raise Exception("You must use the public key with encrypt")
|
||||
|
||||
return chopstring(message, key['e'], key['n'], encrypt_int)
|
||||
|
||||
def sign(message, key):
|
||||
"""Signs a string 'message' with the private key 'key'"""
|
||||
if 'p' not in key:
|
||||
raise Exception("You must use the private key with sign")
|
||||
|
||||
return chopstring(message, key['d'], key['p']*key['q'], encrypt_int)
|
||||
|
||||
def decrypt(cypher, key):
|
||||
"""Decrypts a string 'cypher' with the private key 'key'"""
|
||||
if 'p' not in key:
|
||||
raise Exception("You must use the private key with decrypt")
|
||||
|
||||
return gluechops(cypher, key['d'], key['p']*key['q'], decrypt_int)
|
||||
|
||||
def verify(cypher, key):
|
||||
"""Verifies a string 'cypher' with the public key 'key'"""
|
||||
if 'n' not in key:
|
||||
raise Exception("You must use the public key with verify")
|
||||
|
||||
return gluechops(cypher, key['e'], key['n'], decrypt_int)
|
||||
|
||||
# Do doctest if we're not imported
|
||||
if __name__ == "__main__":
|
||||
import doctest
|
||||
doctest.testmod()
|
||||
|
||||
__all__ = ["newkeys", "encrypt", "decrypt", "sign", "verify"]
|
||||
|
87
rsa/bigfile.py
Normal file
87
rsa/bigfile.py
Normal file
|
@ -0,0 +1,87 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright 2011 Sybren A. Stüvel <sybren@stuvel.eu>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
'''Large file support
|
||||
|
||||
- break a file into smaller blocks, and encrypt them, and store the
|
||||
encrypted blocks in another file.
|
||||
|
||||
- take such an encrypted files, decrypt its blocks, and reconstruct the
|
||||
original file.
|
||||
|
||||
The encrypted file format is as follows, where || denotes byte concatenation:
|
||||
|
||||
FILE := VERSION || BLOCK || BLOCK ...
|
||||
|
||||
BLOCK := LENGTH || DATA
|
||||
|
||||
LENGTH := varint-encoded length of the subsequent data. Varint comes from
|
||||
Google Protobuf, and encodes an integer into a variable number of bytes.
|
||||
Each byte uses the 7 lowest bits to encode the value. The highest bit set
|
||||
to 1 indicates the next byte is also part of the varint. The last byte will
|
||||
have this bit set to 0.
|
||||
|
||||
This file format is called the VARBLOCK format, in line with the varint format
|
||||
used to denote the block sizes.
|
||||
|
||||
'''
|
||||
|
||||
from rsa import key, common, pkcs1, varblock
|
||||
from rsa._compat import byte
|
||||
|
||||
def encrypt_bigfile(infile, outfile, pub_key):
|
||||
'''Encrypts a file, writing it to 'outfile' in VARBLOCK format.
|
||||
|
||||
:param infile: file-like object to read the cleartext from
|
||||
:param outfile: file-like object to write the crypto in VARBLOCK format to
|
||||
:param pub_key: :py:class:`rsa.PublicKey` to encrypt with
|
||||
|
||||
'''
|
||||
|
||||
if not isinstance(pub_key, key.PublicKey):
|
||||
raise TypeError('Public key required, but got %r' % pub_key)
|
||||
|
||||
key_bytes = common.bit_size(pub_key.n) // 8
|
||||
blocksize = key_bytes - 11 # keep space for PKCS#1 padding
|
||||
|
||||
# Write the version number to the VARBLOCK file
|
||||
outfile.write(byte(varblock.VARBLOCK_VERSION))
|
||||
|
||||
# Encrypt and write each block
|
||||
for block in varblock.yield_fixedblocks(infile, blocksize):
|
||||
crypto = pkcs1.encrypt(block, pub_key)
|
||||
|
||||
varblock.write_varint(outfile, len(crypto))
|
||||
outfile.write(crypto)
|
||||
|
||||
def decrypt_bigfile(infile, outfile, priv_key):
|
||||
'''Decrypts an encrypted VARBLOCK file, writing it to 'outfile'
|
||||
|
||||
:param infile: file-like object to read the crypto in VARBLOCK format from
|
||||
:param outfile: file-like object to write the cleartext to
|
||||
:param priv_key: :py:class:`rsa.PrivateKey` to decrypt with
|
||||
|
||||
'''
|
||||
|
||||
if not isinstance(priv_key, key.PrivateKey):
|
||||
raise TypeError('Private key required, but got %r' % priv_key)
|
||||
|
||||
for block in varblock.yield_varblocks(infile):
|
||||
cleartext = pkcs1.decrypt(block, priv_key)
|
||||
outfile.write(cleartext)
|
||||
|
||||
__all__ = ['encrypt_bigfile', 'decrypt_bigfile']
|
||||
|
BIN
rsa/bigfile.pyc
Normal file
BIN
rsa/bigfile.pyc
Normal file
Binary file not shown.
379
rsa/cli.py
Normal file
379
rsa/cli.py
Normal file
|
@ -0,0 +1,379 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright 2011 Sybren A. Stüvel <sybren@stuvel.eu>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
'''Commandline scripts.
|
||||
|
||||
These scripts are called by the executables defined in setup.py.
|
||||
'''
|
||||
|
||||
from __future__ import with_statement, print_function
|
||||
|
||||
import abc
|
||||
import sys
|
||||
from optparse import OptionParser
|
||||
|
||||
import rsa
|
||||
import rsa.bigfile
|
||||
import rsa.pkcs1
|
||||
|
||||
HASH_METHODS = sorted(rsa.pkcs1.HASH_METHODS.keys())
|
||||
|
||||
def keygen():
|
||||
'''Key generator.'''
|
||||
|
||||
# Parse the CLI options
|
||||
parser = OptionParser(usage='usage: %prog [options] keysize',
|
||||
description='Generates a new RSA keypair of "keysize" bits.')
|
||||
|
||||
parser.add_option('--pubout', type='string',
|
||||
help='Output filename for the public key. The public key is '
|
||||
'not saved if this option is not present. You can use '
|
||||
'pyrsa-priv2pub to create the public key file later.')
|
||||
|
||||
parser.add_option('-o', '--out', type='string',
|
||||
help='Output filename for the private key. The key is '
|
||||
'written to stdout if this option is not present.')
|
||||
|
||||
parser.add_option('--form',
|
||||
help='key format of the private and public keys - default PEM',
|
||||
choices=('PEM', 'DER'), default='PEM')
|
||||
|
||||
(cli, cli_args) = parser.parse_args(sys.argv[1:])
|
||||
|
||||
if len(cli_args) != 1:
|
||||
parser.print_help()
|
||||
raise SystemExit(1)
|
||||
|
||||
try:
|
||||
keysize = int(cli_args[0])
|
||||
except ValueError:
|
||||
parser.print_help()
|
||||
print('Not a valid number: %s' % cli_args[0], file=sys.stderr)
|
||||
raise SystemExit(1)
|
||||
|
||||
print('Generating %i-bit key' % keysize, file=sys.stderr)
|
||||
(pub_key, priv_key) = rsa.newkeys(keysize)
|
||||
|
||||
|
||||
# Save public key
|
||||
if cli.pubout:
|
||||
print('Writing public key to %s' % cli.pubout, file=sys.stderr)
|
||||
data = pub_key.save_pkcs1(format=cli.form)
|
||||
with open(cli.pubout, 'wb') as outfile:
|
||||
outfile.write(data)
|
||||
|
||||
# Save private key
|
||||
data = priv_key.save_pkcs1(format=cli.form)
|
||||
|
||||
if cli.out:
|
||||
print('Writing private key to %s' % cli.out, file=sys.stderr)
|
||||
with open(cli.out, 'wb') as outfile:
|
||||
outfile.write(data)
|
||||
else:
|
||||
print('Writing private key to stdout', file=sys.stderr)
|
||||
sys.stdout.write(data)
|
||||
|
||||
|
||||
class CryptoOperation(object):
|
||||
'''CLI callable that operates with input, output, and a key.'''
|
||||
|
||||
__metaclass__ = abc.ABCMeta
|
||||
|
||||
keyname = 'public' # or 'private'
|
||||
usage = 'usage: %%prog [options] %(keyname)s_key'
|
||||
description = None
|
||||
operation = 'decrypt'
|
||||
operation_past = 'decrypted'
|
||||
operation_progressive = 'decrypting'
|
||||
input_help = 'Name of the file to %(operation)s. Reads from stdin if ' \
|
||||
'not specified.'
|
||||
output_help = 'Name of the file to write the %(operation_past)s file ' \
|
||||
'to. Written to stdout if this option is not present.'
|
||||
expected_cli_args = 1
|
||||
has_output = True
|
||||
|
||||
key_class = rsa.PublicKey
|
||||
|
||||
def __init__(self):
|
||||
self.usage = self.usage % self.__class__.__dict__
|
||||
self.input_help = self.input_help % self.__class__.__dict__
|
||||
self.output_help = self.output_help % self.__class__.__dict__
|
||||
|
||||
@abc.abstractmethod
|
||||
def perform_operation(self, indata, key, cli_args=None):
|
||||
'''Performs the program's operation.
|
||||
|
||||
Implement in a subclass.
|
||||
|
||||
:returns: the data to write to the output.
|
||||
'''
|
||||
|
||||
def __call__(self):
|
||||
'''Runs the program.'''
|
||||
|
||||
(cli, cli_args) = self.parse_cli()
|
||||
|
||||
key = self.read_key(cli_args[0], cli.keyform)
|
||||
|
||||
indata = self.read_infile(cli.input)
|
||||
|
||||
print(self.operation_progressive.title(), file=sys.stderr)
|
||||
outdata = self.perform_operation(indata, key, cli_args)
|
||||
|
||||
if self.has_output:
|
||||
self.write_outfile(outdata, cli.output)
|
||||
|
||||
def parse_cli(self):
|
||||
'''Parse the CLI options
|
||||
|
||||
:returns: (cli_opts, cli_args)
|
||||
'''
|
||||
|
||||
parser = OptionParser(usage=self.usage, description=self.description)
|
||||
|
||||
parser.add_option('-i', '--input', type='string', help=self.input_help)
|
||||
|
||||
if self.has_output:
|
||||
parser.add_option('-o', '--output', type='string', help=self.output_help)
|
||||
|
||||
parser.add_option('--keyform',
|
||||
help='Key format of the %s key - default PEM' % self.keyname,
|
||||
choices=('PEM', 'DER'), default='PEM')
|
||||
|
||||
(cli, cli_args) = parser.parse_args(sys.argv[1:])
|
||||
|
||||
if len(cli_args) != self.expected_cli_args:
|
||||
parser.print_help()
|
||||
raise SystemExit(1)
|
||||
|
||||
return (cli, cli_args)
|
||||
|
||||
def read_key(self, filename, keyform):
|
||||
'''Reads a public or private key.'''
|
||||
|
||||
print('Reading %s key from %s' % (self.keyname, filename), file=sys.stderr)
|
||||
with open(filename, 'rb') as keyfile:
|
||||
keydata = keyfile.read()
|
||||
|
||||
return self.key_class.load_pkcs1(keydata, keyform)
|
||||
|
||||
def read_infile(self, inname):
|
||||
'''Read the input file'''
|
||||
|
||||
if inname:
|
||||
print('Reading input from %s' % inname, file=sys.stderr)
|
||||
with open(inname, 'rb') as infile:
|
||||
return infile.read()
|
||||
|
||||
print('Reading input from stdin', file=sys.stderr)
|
||||
return sys.stdin.read()
|
||||
|
||||
def write_outfile(self, outdata, outname):
|
||||
'''Write the output file'''
|
||||
|
||||
if outname:
|
||||
print('Writing output to %s' % outname, file=sys.stderr)
|
||||
with open(outname, 'wb') as outfile:
|
||||
outfile.write(outdata)
|
||||
else:
|
||||
print('Writing output to stdout', file=sys.stderr)
|
||||
sys.stdout.write(outdata)
|
||||
|
||||
class EncryptOperation(CryptoOperation):
|
||||
'''Encrypts a file.'''
|
||||
|
||||
keyname = 'public'
|
||||
description = ('Encrypts a file. The file must be shorter than the key '
|
||||
'length in order to be encrypted. For larger files, use the '
|
||||
'pyrsa-encrypt-bigfile command.')
|
||||
operation = 'encrypt'
|
||||
operation_past = 'encrypted'
|
||||
operation_progressive = 'encrypting'
|
||||
|
||||
|
||||
def perform_operation(self, indata, pub_key, cli_args=None):
|
||||
'''Encrypts files.'''
|
||||
|
||||
return rsa.encrypt(indata, pub_key)
|
||||
|
||||
class DecryptOperation(CryptoOperation):
|
||||
'''Decrypts a file.'''
|
||||
|
||||
keyname = 'private'
|
||||
description = ('Decrypts a file. The original file must be shorter than '
|
||||
'the key length in order to have been encrypted. For larger '
|
||||
'files, use the pyrsa-decrypt-bigfile command.')
|
||||
operation = 'decrypt'
|
||||
operation_past = 'decrypted'
|
||||
operation_progressive = 'decrypting'
|
||||
key_class = rsa.PrivateKey
|
||||
|
||||
def perform_operation(self, indata, priv_key, cli_args=None):
|
||||
'''Decrypts files.'''
|
||||
|
||||
return rsa.decrypt(indata, priv_key)
|
||||
|
||||
class SignOperation(CryptoOperation):
|
||||
'''Signs a file.'''
|
||||
|
||||
keyname = 'private'
|
||||
usage = 'usage: %%prog [options] private_key hash_method'
|
||||
description = ('Signs a file, outputs the signature. Choose the hash '
|
||||
'method from %s' % ', '.join(HASH_METHODS))
|
||||
operation = 'sign'
|
||||
operation_past = 'signature'
|
||||
operation_progressive = 'Signing'
|
||||
key_class = rsa.PrivateKey
|
||||
expected_cli_args = 2
|
||||
|
||||
output_help = ('Name of the file to write the signature to. Written '
|
||||
'to stdout if this option is not present.')
|
||||
|
||||
def perform_operation(self, indata, priv_key, cli_args):
|
||||
'''Decrypts files.'''
|
||||
|
||||
hash_method = cli_args[1]
|
||||
if hash_method not in HASH_METHODS:
|
||||
raise SystemExit('Invalid hash method, choose one of %s' %
|
||||
', '.join(HASH_METHODS))
|
||||
|
||||
return rsa.sign(indata, priv_key, hash_method)
|
||||
|
||||
class VerifyOperation(CryptoOperation):
|
||||
'''Verify a signature.'''
|
||||
|
||||
keyname = 'public'
|
||||
usage = 'usage: %%prog [options] private_key signature_file'
|
||||
description = ('Verifies a signature, exits with status 0 upon success, '
|
||||
'prints an error message and exits with status 1 upon error.')
|
||||
operation = 'verify'
|
||||
operation_past = 'verified'
|
||||
operation_progressive = 'Verifying'
|
||||
key_class = rsa.PublicKey
|
||||
expected_cli_args = 2
|
||||
has_output = False
|
||||
|
||||
def perform_operation(self, indata, pub_key, cli_args):
|
||||
'''Decrypts files.'''
|
||||
|
||||
signature_file = cli_args[1]
|
||||
|
||||
with open(signature_file, 'rb') as sigfile:
|
||||
signature = sigfile.read()
|
||||
|
||||
try:
|
||||
rsa.verify(indata, signature, pub_key)
|
||||
except rsa.VerificationError:
|
||||
raise SystemExit('Verification failed.')
|
||||
|
||||
print('Verification OK', file=sys.stderr)
|
||||
|
||||
|
||||
class BigfileOperation(CryptoOperation):
|
||||
'''CryptoOperation that doesn't read the entire file into memory.'''
|
||||
|
||||
def __init__(self):
|
||||
CryptoOperation.__init__(self)
|
||||
|
||||
self.file_objects = []
|
||||
|
||||
def __del__(self):
|
||||
'''Closes any open file handles.'''
|
||||
|
||||
for fobj in self.file_objects:
|
||||
fobj.close()
|
||||
|
||||
def __call__(self):
|
||||
'''Runs the program.'''
|
||||
|
||||
(cli, cli_args) = self.parse_cli()
|
||||
|
||||
key = self.read_key(cli_args[0], cli.keyform)
|
||||
|
||||
# Get the file handles
|
||||
infile = self.get_infile(cli.input)
|
||||
outfile = self.get_outfile(cli.output)
|
||||
|
||||
# Call the operation
|
||||
print(self.operation_progressive.title(), file=sys.stderr)
|
||||
self.perform_operation(infile, outfile, key, cli_args)
|
||||
|
||||
def get_infile(self, inname):
|
||||
'''Returns the input file object'''
|
||||
|
||||
if inname:
|
||||
print('Reading input from %s' % inname, file=sys.stderr)
|
||||
fobj = open(inname, 'rb')
|
||||
self.file_objects.append(fobj)
|
||||
else:
|
||||
print('Reading input from stdin', file=sys.stderr)
|
||||
fobj = sys.stdin
|
||||
|
||||
return fobj
|
||||
|
||||
def get_outfile(self, outname):
|
||||
'''Returns the output file object'''
|
||||
|
||||
if outname:
|
||||
print('Will write output to %s' % outname, file=sys.stderr)
|
||||
fobj = open(outname, 'wb')
|
||||
self.file_objects.append(fobj)
|
||||
else:
|
||||
print('Will write output to stdout', file=sys.stderr)
|
||||
fobj = sys.stdout
|
||||
|
||||
return fobj
|
||||
|
||||
class EncryptBigfileOperation(BigfileOperation):
|
||||
'''Encrypts a file to VARBLOCK format.'''
|
||||
|
||||
keyname = 'public'
|
||||
description = ('Encrypts a file to an encrypted VARBLOCK file. The file '
|
||||
'can be larger than the key length, but the output file is only '
|
||||
'compatible with Python-RSA.')
|
||||
operation = 'encrypt'
|
||||
operation_past = 'encrypted'
|
||||
operation_progressive = 'encrypting'
|
||||
|
||||
def perform_operation(self, infile, outfile, pub_key, cli_args=None):
|
||||
'''Encrypts files to VARBLOCK.'''
|
||||
|
||||
return rsa.bigfile.encrypt_bigfile(infile, outfile, pub_key)
|
||||
|
||||
class DecryptBigfileOperation(BigfileOperation):
|
||||
'''Decrypts a file in VARBLOCK format.'''
|
||||
|
||||
keyname = 'private'
|
||||
description = ('Decrypts an encrypted VARBLOCK file that was encrypted '
|
||||
'with pyrsa-encrypt-bigfile')
|
||||
operation = 'decrypt'
|
||||
operation_past = 'decrypted'
|
||||
operation_progressive = 'decrypting'
|
||||
key_class = rsa.PrivateKey
|
||||
|
||||
def perform_operation(self, infile, outfile, priv_key, cli_args=None):
|
||||
'''Decrypts a VARBLOCK file.'''
|
||||
|
||||
return rsa.bigfile.decrypt_bigfile(infile, outfile, priv_key)
|
||||
|
||||
|
||||
encrypt = EncryptOperation()
|
||||
decrypt = DecryptOperation()
|
||||
sign = SignOperation()
|
||||
verify = VerifyOperation()
|
||||
encrypt_bigfile = EncryptBigfileOperation()
|
||||
decrypt_bigfile = DecryptBigfileOperation()
|
||||
|
185
rsa/common.py
Normal file
185
rsa/common.py
Normal file
|
@ -0,0 +1,185 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright 2011 Sybren A. Stüvel <sybren@stuvel.eu>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
'''Common functionality shared by several modules.'''
|
||||
|
||||
|
||||
def bit_size(num):
|
||||
'''
|
||||
Number of bits needed to represent a integer excluding any prefix
|
||||
0 bits.
|
||||
|
||||
As per definition from http://wiki.python.org/moin/BitManipulation and
|
||||
to match the behavior of the Python 3 API.
|
||||
|
||||
Usage::
|
||||
|
||||
>>> bit_size(1023)
|
||||
10
|
||||
>>> bit_size(1024)
|
||||
11
|
||||
>>> bit_size(1025)
|
||||
11
|
||||
|
||||
:param num:
|
||||
Integer value. If num is 0, returns 0. Only the absolute value of the
|
||||
number is considered. Therefore, signed integers will be abs(num)
|
||||
before the number's bit length is determined.
|
||||
:returns:
|
||||
Returns the number of bits in the integer.
|
||||
'''
|
||||
if num == 0:
|
||||
return 0
|
||||
if num < 0:
|
||||
num = -num
|
||||
|
||||
# Make sure this is an int and not a float.
|
||||
num & 1
|
||||
|
||||
hex_num = "%x" % num
|
||||
return ((len(hex_num) - 1) * 4) + {
|
||||
'0':0, '1':1, '2':2, '3':2,
|
||||
'4':3, '5':3, '6':3, '7':3,
|
||||
'8':4, '9':4, 'a':4, 'b':4,
|
||||
'c':4, 'd':4, 'e':4, 'f':4,
|
||||
}[hex_num[0]]
|
||||
|
||||
|
||||
def _bit_size(number):
|
||||
'''
|
||||
Returns the number of bits required to hold a specific long number.
|
||||
'''
|
||||
if number < 0:
|
||||
raise ValueError('Only nonnegative numbers possible: %s' % number)
|
||||
|
||||
if number == 0:
|
||||
return 0
|
||||
|
||||
# This works, even with very large numbers. When using math.log(number, 2),
|
||||
# you'll get rounding errors and it'll fail.
|
||||
bits = 0
|
||||
while number:
|
||||
bits += 1
|
||||
number >>= 1
|
||||
|
||||
return bits
|
||||
|
||||
|
||||
def byte_size(number):
|
||||
'''
|
||||
Returns the number of bytes required to hold a specific long number.
|
||||
|
||||
The number of bytes is rounded up.
|
||||
|
||||
Usage::
|
||||
|
||||
>>> byte_size(1 << 1023)
|
||||
128
|
||||
>>> byte_size((1 << 1024) - 1)
|
||||
128
|
||||
>>> byte_size(1 << 1024)
|
||||
129
|
||||
|
||||
:param number:
|
||||
An unsigned integer
|
||||
:returns:
|
||||
The number of bytes required to hold a specific long number.
|
||||
'''
|
||||
quanta, mod = divmod(bit_size(number), 8)
|
||||
if mod or number == 0:
|
||||
quanta += 1
|
||||
return quanta
|
||||
#return int(math.ceil(bit_size(number) / 8.0))
|
||||
|
||||
|
||||
def extended_gcd(a, b):
|
||||
'''Returns a tuple (r, i, j) such that r = gcd(a, b) = ia + jb
|
||||
'''
|
||||
# r = gcd(a,b) i = multiplicitive inverse of a mod b
|
||||
# or j = multiplicitive inverse of b mod a
|
||||
# Neg return values for i or j are made positive mod b or a respectively
|
||||
# Iterateive Version is faster and uses much less stack space
|
||||
x = 0
|
||||
y = 1
|
||||
lx = 1
|
||||
ly = 0
|
||||
oa = a #Remember original a/b to remove
|
||||
ob = b #negative values from return results
|
||||
while b != 0:
|
||||
q = a // b
|
||||
(a, b) = (b, a % b)
|
||||
(x, lx) = ((lx - (q * x)),x)
|
||||
(y, ly) = ((ly - (q * y)),y)
|
||||
if (lx < 0): lx += ob #If neg wrap modulo orignal b
|
||||
if (ly < 0): ly += oa #If neg wrap modulo orignal a
|
||||
return (a, lx, ly) #Return only positive values
|
||||
|
||||
|
||||
def inverse(x, n):
|
||||
'''Returns x^-1 (mod n)
|
||||
|
||||
>>> inverse(7, 4)
|
||||
3
|
||||
>>> (inverse(143, 4) * 143) % 4
|
||||
1
|
||||
'''
|
||||
|
||||
(divider, inv, _) = extended_gcd(x, n)
|
||||
|
||||
if divider != 1:
|
||||
raise ValueError("x (%d) and n (%d) are not relatively prime" % (x, n))
|
||||
|
||||
return inv
|
||||
|
||||
|
||||
def crt(a_values, modulo_values):
|
||||
'''Chinese Remainder Theorem.
|
||||
|
||||
Calculates x such that x = a[i] (mod m[i]) for each i.
|
||||
|
||||
:param a_values: the a-values of the above equation
|
||||
:param modulo_values: the m-values of the above equation
|
||||
:returns: x such that x = a[i] (mod m[i]) for each i
|
||||
|
||||
|
||||
>>> crt([2, 3], [3, 5])
|
||||
8
|
||||
|
||||
>>> crt([2, 3, 2], [3, 5, 7])
|
||||
23
|
||||
|
||||
>>> crt([2, 3, 0], [7, 11, 15])
|
||||
135
|
||||
'''
|
||||
|
||||
m = 1
|
||||
x = 0
|
||||
|
||||
for modulo in modulo_values:
|
||||
m *= modulo
|
||||
|
||||
for (m_i, a_i) in zip(modulo_values, a_values):
|
||||
M_i = m // m_i
|
||||
inv = inverse(M_i, m_i)
|
||||
|
||||
x = (x + a_i * M_i * inv) % m
|
||||
|
||||
return x
|
||||
|
||||
if __name__ == '__main__':
|
||||
import doctest
|
||||
doctest.testmod()
|
||||
|
BIN
rsa/common.pyc
Normal file
BIN
rsa/common.pyc
Normal file
Binary file not shown.
58
rsa/core.py
Normal file
58
rsa/core.py
Normal file
|
@ -0,0 +1,58 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright 2011 Sybren A. Stüvel <sybren@stuvel.eu>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
'''Core mathematical operations.
|
||||
|
||||
This is the actual core RSA implementation, which is only defined
|
||||
mathematically on integers.
|
||||
'''
|
||||
|
||||
|
||||
from rsa._compat import is_integer
|
||||
|
||||
def assert_int(var, name):
|
||||
|
||||
if is_integer(var):
|
||||
return
|
||||
|
||||
raise TypeError('%s should be an integer, not %s' % (name, var.__class__))
|
||||
|
||||
def encrypt_int(message, ekey, n):
|
||||
'''Encrypts a message using encryption key 'ekey', working modulo n'''
|
||||
|
||||
assert_int(message, 'message')
|
||||
assert_int(ekey, 'ekey')
|
||||
assert_int(n, 'n')
|
||||
|
||||
if message < 0:
|
||||
raise ValueError('Only non-negative numbers are supported')
|
||||
|
||||
if message > n:
|
||||
raise OverflowError("The message %i is too long for n=%i" % (message, n))
|
||||
|
||||
return pow(message, ekey, n)
|
||||
|
||||
def decrypt_int(cyphertext, dkey, n):
|
||||
'''Decrypts a cypher text using the decryption key 'dkey', working
|
||||
modulo n'''
|
||||
|
||||
assert_int(cyphertext, 'cyphertext')
|
||||
assert_int(dkey, 'dkey')
|
||||
assert_int(n, 'n')
|
||||
|
||||
message = pow(cyphertext, dkey, n)
|
||||
return message
|
||||
|
BIN
rsa/core.pyc
Normal file
BIN
rsa/core.pyc
Normal file
Binary file not shown.
581
rsa/key.py
Normal file
581
rsa/key.py
Normal file
|
@ -0,0 +1,581 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright 2011 Sybren A. Stüvel <sybren@stuvel.eu>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
'''RSA key generation code.
|
||||
|
||||
Create new keys with the newkeys() function. It will give you a PublicKey and a
|
||||
PrivateKey object.
|
||||
|
||||
Loading and saving keys requires the pyasn1 module. This module is imported as
|
||||
late as possible, such that other functionality will remain working in absence
|
||||
of pyasn1.
|
||||
|
||||
'''
|
||||
|
||||
import logging
|
||||
from rsa._compat import b
|
||||
|
||||
import rsa.prime
|
||||
import rsa.pem
|
||||
import rsa.common
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
class AbstractKey(object):
|
||||
'''Abstract superclass for private and public keys.'''
|
||||
|
||||
@classmethod
|
||||
def load_pkcs1(cls, keyfile, format='PEM'):
|
||||
r'''Loads a key in PKCS#1 DER or PEM format.
|
||||
|
||||
:param keyfile: contents of a DER- or PEM-encoded file that contains
|
||||
the public key.
|
||||
:param format: the format of the file to load; 'PEM' or 'DER'
|
||||
|
||||
:return: a PublicKey object
|
||||
|
||||
'''
|
||||
|
||||
methods = {
|
||||
'PEM': cls._load_pkcs1_pem,
|
||||
'DER': cls._load_pkcs1_der,
|
||||
}
|
||||
|
||||
if format not in methods:
|
||||
formats = ', '.join(sorted(methods.keys()))
|
||||
raise ValueError('Unsupported format: %r, try one of %s' % (format,
|
||||
formats))
|
||||
|
||||
method = methods[format]
|
||||
return method(keyfile)
|
||||
|
||||
def save_pkcs1(self, format='PEM'):
|
||||
'''Saves the public key in PKCS#1 DER or PEM format.
|
||||
|
||||
:param format: the format to save; 'PEM' or 'DER'
|
||||
:returns: the DER- or PEM-encoded public key.
|
||||
|
||||
'''
|
||||
|
||||
methods = {
|
||||
'PEM': self._save_pkcs1_pem,
|
||||
'DER': self._save_pkcs1_der,
|
||||
}
|
||||
|
||||
if format not in methods:
|
||||
formats = ', '.join(sorted(methods.keys()))
|
||||
raise ValueError('Unsupported format: %r, try one of %s' % (format,
|
||||
formats))
|
||||
|
||||
method = methods[format]
|
||||
return method()
|
||||
|
||||
class PublicKey(AbstractKey):
|
||||
'''Represents a public RSA key.
|
||||
|
||||
This key is also known as the 'encryption key'. It contains the 'n' and 'e'
|
||||
values.
|
||||
|
||||
Supports attributes as well as dictionary-like access. Attribute accesss is
|
||||
faster, though.
|
||||
|
||||
>>> PublicKey(5, 3)
|
||||
PublicKey(5, 3)
|
||||
|
||||
>>> key = PublicKey(5, 3)
|
||||
>>> key.n
|
||||
5
|
||||
>>> key['n']
|
||||
5
|
||||
>>> key.e
|
||||
3
|
||||
>>> key['e']
|
||||
3
|
||||
|
||||
'''
|
||||
|
||||
__slots__ = ('n', 'e')
|
||||
|
||||
def __init__(self, n, e):
|
||||
self.n = n
|
||||
self.e = e
|
||||
|
||||
def __getitem__(self, key):
|
||||
return getattr(self, key)
|
||||
|
||||
def __repr__(self):
|
||||
return 'PublicKey(%i, %i)' % (self.n, self.e)
|
||||
|
||||
def __eq__(self, other):
|
||||
if other is None:
|
||||
return False
|
||||
|
||||
if not isinstance(other, PublicKey):
|
||||
return False
|
||||
|
||||
return self.n == other.n and self.e == other.e
|
||||
|
||||
def __ne__(self, other):
|
||||
return not (self == other)
|
||||
|
||||
@classmethod
|
||||
def _load_pkcs1_der(cls, keyfile):
|
||||
r'''Loads a key in PKCS#1 DER format.
|
||||
|
||||
@param keyfile: contents of a DER-encoded file that contains the public
|
||||
key.
|
||||
@return: a PublicKey object
|
||||
|
||||
First let's construct a DER encoded key:
|
||||
|
||||
>>> import base64
|
||||
>>> b64der = 'MAwCBQCNGmYtAgMBAAE='
|
||||
>>> der = base64.decodestring(b64der)
|
||||
|
||||
This loads the file:
|
||||
|
||||
>>> PublicKey._load_pkcs1_der(der)
|
||||
PublicKey(2367317549, 65537)
|
||||
|
||||
'''
|
||||
|
||||
from pyasn1.codec.der import decoder
|
||||
(priv, _) = decoder.decode(keyfile)
|
||||
|
||||
# ASN.1 contents of DER encoded public key:
|
||||
#
|
||||
# RSAPublicKey ::= SEQUENCE {
|
||||
# modulus INTEGER, -- n
|
||||
# publicExponent INTEGER, -- e
|
||||
|
||||
as_ints = tuple(int(x) for x in priv)
|
||||
return cls(*as_ints)
|
||||
|
||||
def _save_pkcs1_der(self):
|
||||
'''Saves the public key in PKCS#1 DER format.
|
||||
|
||||
@returns: the DER-encoded public key.
|
||||
'''
|
||||
|
||||
from pyasn1.type import univ, namedtype
|
||||
from pyasn1.codec.der import encoder
|
||||
|
||||
class AsnPubKey(univ.Sequence):
|
||||
componentType = namedtype.NamedTypes(
|
||||
namedtype.NamedType('modulus', univ.Integer()),
|
||||
namedtype.NamedType('publicExponent', univ.Integer()),
|
||||
)
|
||||
|
||||
# Create the ASN object
|
||||
asn_key = AsnPubKey()
|
||||
asn_key.setComponentByName('modulus', self.n)
|
||||
asn_key.setComponentByName('publicExponent', self.e)
|
||||
|
||||
return encoder.encode(asn_key)
|
||||
|
||||
@classmethod
|
||||
def _load_pkcs1_pem(cls, keyfile):
|
||||
'''Loads a PKCS#1 PEM-encoded public key file.
|
||||
|
||||
The contents of the file before the "-----BEGIN RSA PUBLIC KEY-----" and
|
||||
after the "-----END RSA PUBLIC KEY-----" lines is ignored.
|
||||
|
||||
@param keyfile: contents of a PEM-encoded file that contains the public
|
||||
key.
|
||||
@return: a PublicKey object
|
||||
'''
|
||||
|
||||
der = rsa.pem.load_pem(keyfile, 'RSA PUBLIC KEY')
|
||||
return cls._load_pkcs1_der(der)
|
||||
|
||||
def _save_pkcs1_pem(self):
|
||||
'''Saves a PKCS#1 PEM-encoded public key file.
|
||||
|
||||
@return: contents of a PEM-encoded file that contains the public key.
|
||||
'''
|
||||
|
||||
der = self._save_pkcs1_der()
|
||||
return rsa.pem.save_pem(der, 'RSA PUBLIC KEY')
|
||||
|
||||
class PrivateKey(AbstractKey):
|
||||
'''Represents a private RSA key.
|
||||
|
||||
This key is also known as the 'decryption key'. It contains the 'n', 'e',
|
||||
'd', 'p', 'q' and other values.
|
||||
|
||||
Supports attributes as well as dictionary-like access. Attribute accesss is
|
||||
faster, though.
|
||||
|
||||
>>> PrivateKey(3247, 65537, 833, 191, 17)
|
||||
PrivateKey(3247, 65537, 833, 191, 17)
|
||||
|
||||
exp1, exp2 and coef don't have to be given, they will be calculated:
|
||||
|
||||
>>> pk = PrivateKey(3727264081, 65537, 3349121513, 65063, 57287)
|
||||
>>> pk.exp1
|
||||
55063
|
||||
>>> pk.exp2
|
||||
10095
|
||||
>>> pk.coef
|
||||
50797
|
||||
|
||||
If you give exp1, exp2 or coef, they will be used as-is:
|
||||
|
||||
>>> pk = PrivateKey(1, 2, 3, 4, 5, 6, 7, 8)
|
||||
>>> pk.exp1
|
||||
6
|
||||
>>> pk.exp2
|
||||
7
|
||||
>>> pk.coef
|
||||
8
|
||||
|
||||
'''
|
||||
|
||||
__slots__ = ('n', 'e', 'd', 'p', 'q', 'exp1', 'exp2', 'coef')
|
||||
|
||||
def __init__(self, n, e, d, p, q, exp1=None, exp2=None, coef=None):
|
||||
self.n = n
|
||||
self.e = e
|
||||
self.d = d
|
||||
self.p = p
|
||||
self.q = q
|
||||
|
||||
# Calculate the other values if they aren't supplied
|
||||
if exp1 is None:
|
||||
self.exp1 = int(d % (p - 1))
|
||||
else:
|
||||
self.exp1 = exp1
|
||||
|
||||
if exp1 is None:
|
||||
self.exp2 = int(d % (q - 1))
|
||||
else:
|
||||
self.exp2 = exp2
|
||||
|
||||
if coef is None:
|
||||
self.coef = rsa.common.inverse(q, p)
|
||||
else:
|
||||
self.coef = coef
|
||||
|
||||
def __getitem__(self, key):
|
||||
return getattr(self, key)
|
||||
|
||||
def __repr__(self):
|
||||
return 'PrivateKey(%(n)i, %(e)i, %(d)i, %(p)i, %(q)i)' % self
|
||||
|
||||
def __eq__(self, other):
|
||||
if other is None:
|
||||
return False
|
||||
|
||||
if not isinstance(other, PrivateKey):
|
||||
return False
|
||||
|
||||
return (self.n == other.n and
|
||||
self.e == other.e and
|
||||
self.d == other.d and
|
||||
self.p == other.p and
|
||||
self.q == other.q and
|
||||
self.exp1 == other.exp1 and
|
||||
self.exp2 == other.exp2 and
|
||||
self.coef == other.coef)
|
||||
|
||||
def __ne__(self, other):
|
||||
return not (self == other)
|
||||
|
||||
@classmethod
|
||||
def _load_pkcs1_der(cls, keyfile):
|
||||
r'''Loads a key in PKCS#1 DER format.
|
||||
|
||||
@param keyfile: contents of a DER-encoded file that contains the private
|
||||
key.
|
||||
@return: a PrivateKey object
|
||||
|
||||
First let's construct a DER encoded key:
|
||||
|
||||
>>> import base64
|
||||
>>> b64der = 'MC4CAQACBQDeKYlRAgMBAAECBQDHn4npAgMA/icCAwDfxwIDANcXAgInbwIDAMZt'
|
||||
>>> der = base64.decodestring(b64der)
|
||||
|
||||
This loads the file:
|
||||
|
||||
>>> PrivateKey._load_pkcs1_der(der)
|
||||
PrivateKey(3727264081, 65537, 3349121513, 65063, 57287)
|
||||
|
||||
'''
|
||||
|
||||
from pyasn1.codec.der import decoder
|
||||
(priv, _) = decoder.decode(keyfile)
|
||||
|
||||
# ASN.1 contents of DER encoded private key:
|
||||
#
|
||||
# RSAPrivateKey ::= SEQUENCE {
|
||||
# version Version,
|
||||
# modulus INTEGER, -- n
|
||||
# publicExponent INTEGER, -- e
|
||||
# privateExponent INTEGER, -- d
|
||||
# prime1 INTEGER, -- p
|
||||
# prime2 INTEGER, -- q
|
||||
# exponent1 INTEGER, -- d mod (p-1)
|
||||
# exponent2 INTEGER, -- d mod (q-1)
|
||||
# coefficient INTEGER, -- (inverse of q) mod p
|
||||
# otherPrimeInfos OtherPrimeInfos OPTIONAL
|
||||
# }
|
||||
|
||||
if priv[0] != 0:
|
||||
raise ValueError('Unable to read this file, version %s != 0' % priv[0])
|
||||
|
||||
as_ints = tuple(int(x) for x in priv[1:9])
|
||||
return cls(*as_ints)
|
||||
|
||||
def _save_pkcs1_der(self):
|
||||
'''Saves the private key in PKCS#1 DER format.
|
||||
|
||||
@returns: the DER-encoded private key.
|
||||
'''
|
||||
|
||||
from pyasn1.type import univ, namedtype
|
||||
from pyasn1.codec.der import encoder
|
||||
|
||||
class AsnPrivKey(univ.Sequence):
|
||||
componentType = namedtype.NamedTypes(
|
||||
namedtype.NamedType('version', univ.Integer()),
|
||||
namedtype.NamedType('modulus', univ.Integer()),
|
||||
namedtype.NamedType('publicExponent', univ.Integer()),
|
||||
namedtype.NamedType('privateExponent', univ.Integer()),
|
||||
namedtype.NamedType('prime1', univ.Integer()),
|
||||
namedtype.NamedType('prime2', univ.Integer()),
|
||||
namedtype.NamedType('exponent1', univ.Integer()),
|
||||
namedtype.NamedType('exponent2', univ.Integer()),
|
||||
namedtype.NamedType('coefficient', univ.Integer()),
|
||||
)
|
||||
|
||||
# Create the ASN object
|
||||
asn_key = AsnPrivKey()
|
||||
asn_key.setComponentByName('version', 0)
|
||||
asn_key.setComponentByName('modulus', self.n)
|
||||
asn_key.setComponentByName('publicExponent', self.e)
|
||||
asn_key.setComponentByName('privateExponent', self.d)
|
||||
asn_key.setComponentByName('prime1', self.p)
|
||||
asn_key.setComponentByName('prime2', self.q)
|
||||
asn_key.setComponentByName('exponent1', self.exp1)
|
||||
asn_key.setComponentByName('exponent2', self.exp2)
|
||||
asn_key.setComponentByName('coefficient', self.coef)
|
||||
|
||||
return encoder.encode(asn_key)
|
||||
|
||||
@classmethod
|
||||
def _load_pkcs1_pem(cls, keyfile):
|
||||
'''Loads a PKCS#1 PEM-encoded private key file.
|
||||
|
||||
The contents of the file before the "-----BEGIN RSA PRIVATE KEY-----" and
|
||||
after the "-----END RSA PRIVATE KEY-----" lines is ignored.
|
||||
|
||||
@param keyfile: contents of a PEM-encoded file that contains the private
|
||||
key.
|
||||
@return: a PrivateKey object
|
||||
'''
|
||||
|
||||
der = rsa.pem.load_pem(keyfile, b('RSA PRIVATE KEY'))
|
||||
return cls._load_pkcs1_der(der)
|
||||
|
||||
def _save_pkcs1_pem(self):
|
||||
'''Saves a PKCS#1 PEM-encoded private key file.
|
||||
|
||||
@return: contents of a PEM-encoded file that contains the private key.
|
||||
'''
|
||||
|
||||
der = self._save_pkcs1_der()
|
||||
return rsa.pem.save_pem(der, b('RSA PRIVATE KEY'))
|
||||
|
||||
def find_p_q(nbits, getprime_func=rsa.prime.getprime, accurate=True):
|
||||
''''Returns a tuple of two different primes of nbits bits each.
|
||||
|
||||
The resulting p * q has exacty 2 * nbits bits, and the returned p and q
|
||||
will not be equal.
|
||||
|
||||
:param nbits: the number of bits in each of p and q.
|
||||
:param getprime_func: the getprime function, defaults to
|
||||
:py:func:`rsa.prime.getprime`.
|
||||
|
||||
*Introduced in Python-RSA 3.1*
|
||||
|
||||
:param accurate: whether to enable accurate mode or not.
|
||||
:returns: (p, q), where p > q
|
||||
|
||||
>>> (p, q) = find_p_q(128)
|
||||
>>> from rsa import common
|
||||
>>> common.bit_size(p * q)
|
||||
256
|
||||
|
||||
When not in accurate mode, the number of bits can be slightly less
|
||||
|
||||
>>> (p, q) = find_p_q(128, accurate=False)
|
||||
>>> from rsa import common
|
||||
>>> common.bit_size(p * q) <= 256
|
||||
True
|
||||
>>> common.bit_size(p * q) > 240
|
||||
True
|
||||
|
||||
'''
|
||||
|
||||
total_bits = nbits * 2
|
||||
|
||||
# Make sure that p and q aren't too close or the factoring programs can
|
||||
# factor n.
|
||||
shift = nbits // 16
|
||||
pbits = nbits + shift
|
||||
qbits = nbits - shift
|
||||
|
||||
# Choose the two initial primes
|
||||
log.debug('find_p_q(%i): Finding p', nbits)
|
||||
p = getprime_func(pbits)
|
||||
log.debug('find_p_q(%i): Finding q', nbits)
|
||||
q = getprime_func(qbits)
|
||||
|
||||
def is_acceptable(p, q):
|
||||
'''Returns True iff p and q are acceptable:
|
||||
|
||||
- p and q differ
|
||||
- (p * q) has the right nr of bits (when accurate=True)
|
||||
'''
|
||||
|
||||
if p == q:
|
||||
return False
|
||||
|
||||
if not accurate:
|
||||
return True
|
||||
|
||||
# Make sure we have just the right amount of bits
|
||||
found_size = rsa.common.bit_size(p * q)
|
||||
return total_bits == found_size
|
||||
|
||||
# Keep choosing other primes until they match our requirements.
|
||||
change_p = False
|
||||
while not is_acceptable(p, q):
|
||||
# Change p on one iteration and q on the other
|
||||
if change_p:
|
||||
p = getprime_func(pbits)
|
||||
else:
|
||||
q = getprime_func(qbits)
|
||||
|
||||
change_p = not change_p
|
||||
|
||||
# We want p > q as described on
|
||||
# http://www.di-mgt.com.au/rsa_alg.html#crt
|
||||
return (max(p, q), min(p, q))
|
||||
|
||||
def calculate_keys(p, q, nbits):
|
||||
'''Calculates an encryption and a decryption key given p and q, and
|
||||
returns them as a tuple (e, d)
|
||||
|
||||
'''
|
||||
|
||||
phi_n = (p - 1) * (q - 1)
|
||||
|
||||
# A very common choice for e is 65537
|
||||
e = 65537
|
||||
|
||||
try:
|
||||
d = rsa.common.inverse(e, phi_n)
|
||||
except ValueError:
|
||||
raise ValueError("e (%d) and phi_n (%d) are not relatively prime" %
|
||||
(e, phi_n))
|
||||
|
||||
if (e * d) % phi_n != 1:
|
||||
raise ValueError("e (%d) and d (%d) are not mult. inv. modulo "
|
||||
"phi_n (%d)" % (e, d, phi_n))
|
||||
|
||||
return (e, d)
|
||||
|
||||
def gen_keys(nbits, getprime_func, accurate=True):
|
||||
'''Generate RSA keys of nbits bits. Returns (p, q, e, d).
|
||||
|
||||
Note: this can take a long time, depending on the key size.
|
||||
|
||||
:param nbits: the total number of bits in ``p`` and ``q``. Both ``p`` and
|
||||
``q`` will use ``nbits/2`` bits.
|
||||
:param getprime_func: either :py:func:`rsa.prime.getprime` or a function
|
||||
with similar signature.
|
||||
'''
|
||||
|
||||
(p, q) = find_p_q(nbits // 2, getprime_func, accurate)
|
||||
(e, d) = calculate_keys(p, q, nbits // 2)
|
||||
|
||||
return (p, q, e, d)
|
||||
|
||||
def newkeys(nbits, accurate=True, poolsize=1):
|
||||
'''Generates public and private keys, and returns them as (pub, priv).
|
||||
|
||||
The public key is also known as the 'encryption key', and is a
|
||||
:py:class:`rsa.PublicKey` object. The private key is also known as the
|
||||
'decryption key' and is a :py:class:`rsa.PrivateKey` object.
|
||||
|
||||
:param nbits: the number of bits required to store ``n = p*q``.
|
||||
:param accurate: when True, ``n`` will have exactly the number of bits you
|
||||
asked for. However, this makes key generation much slower. When False,
|
||||
`n`` may have slightly less bits.
|
||||
:param poolsize: the number of processes to use to generate the prime
|
||||
numbers. If set to a number > 1, a parallel algorithm will be used.
|
||||
This requires Python 2.6 or newer.
|
||||
|
||||
:returns: a tuple (:py:class:`rsa.PublicKey`, :py:class:`rsa.PrivateKey`)
|
||||
|
||||
The ``poolsize`` parameter was added in *Python-RSA 3.1* and requires
|
||||
Python 2.6 or newer.
|
||||
|
||||
'''
|
||||
|
||||
if nbits < 16:
|
||||
raise ValueError('Key too small')
|
||||
|
||||
if poolsize < 1:
|
||||
raise ValueError('Pool size (%i) should be >= 1' % poolsize)
|
||||
|
||||
# Determine which getprime function to use
|
||||
if poolsize > 1:
|
||||
from rsa import parallel
|
||||
import functools
|
||||
|
||||
getprime_func = functools.partial(parallel.getprime, poolsize=poolsize)
|
||||
else: getprime_func = rsa.prime.getprime
|
||||
|
||||
# Generate the key components
|
||||
(p, q, e, d) = gen_keys(nbits, getprime_func)
|
||||
|
||||
# Create the key objects
|
||||
n = p * q
|
||||
|
||||
return (
|
||||
PublicKey(n, e),
|
||||
PrivateKey(n, e, d, p, q)
|
||||
)
|
||||
|
||||
__all__ = ['PublicKey', 'PrivateKey', 'newkeys']
|
||||
|
||||
if __name__ == '__main__':
|
||||
import doctest
|
||||
|
||||
try:
|
||||
for count in range(100):
|
||||
(failures, tests) = doctest.testmod()
|
||||
if failures:
|
||||
break
|
||||
|
||||
if (count and count % 10 == 0) or count == 1:
|
||||
print('%i times' % count)
|
||||
except KeyboardInterrupt:
|
||||
print('Aborted')
|
||||
else:
|
||||
print('Doctests done')
|
BIN
rsa/key.pyc
Normal file
BIN
rsa/key.pyc
Normal file
Binary file not shown.
94
rsa/parallel.py
Normal file
94
rsa/parallel.py
Normal file
|
@ -0,0 +1,94 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright 2011 Sybren A. Stüvel <sybren@stuvel.eu>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
'''Functions for parallel computation on multiple cores.
|
||||
|
||||
Introduced in Python-RSA 3.1.
|
||||
|
||||
.. note::
|
||||
|
||||
Requires Python 2.6 or newer.
|
||||
|
||||
'''
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import multiprocessing as mp
|
||||
|
||||
import rsa.prime
|
||||
import rsa.randnum
|
||||
|
||||
def _find_prime(nbits, pipe):
|
||||
while True:
|
||||
integer = rsa.randnum.read_random_int(nbits)
|
||||
|
||||
# Make sure it's odd
|
||||
integer |= 1
|
||||
|
||||
# Test for primeness
|
||||
if rsa.prime.is_prime(integer):
|
||||
pipe.send(integer)
|
||||
return
|
||||
|
||||
def getprime(nbits, poolsize):
|
||||
'''Returns a prime number that can be stored in 'nbits' bits.
|
||||
|
||||
Works in multiple threads at the same time.
|
||||
|
||||
>>> p = getprime(128, 3)
|
||||
>>> rsa.prime.is_prime(p-1)
|
||||
False
|
||||
>>> rsa.prime.is_prime(p)
|
||||
True
|
||||
>>> rsa.prime.is_prime(p+1)
|
||||
False
|
||||
|
||||
>>> from rsa import common
|
||||
>>> common.bit_size(p) == 128
|
||||
True
|
||||
|
||||
'''
|
||||
|
||||
(pipe_recv, pipe_send) = mp.Pipe(duplex=False)
|
||||
|
||||
# Create processes
|
||||
procs = [mp.Process(target=_find_prime, args=(nbits, pipe_send))
|
||||
for _ in range(poolsize)]
|
||||
[p.start() for p in procs]
|
||||
|
||||
result = pipe_recv.recv()
|
||||
|
||||
[p.terminate() for p in procs]
|
||||
|
||||
return result
|
||||
|
||||
__all__ = ['getprime']
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print('Running doctests 1000x or until failure')
|
||||
import doctest
|
||||
|
||||
for count in range(100):
|
||||
(failures, tests) = doctest.testmod()
|
||||
if failures:
|
||||
break
|
||||
|
||||
if count and count % 10 == 0:
|
||||
print('%i times' % count)
|
||||
|
||||
print('Doctests done')
|
||||
|
BIN
rsa/parallel.pyc
Normal file
BIN
rsa/parallel.pyc
Normal file
Binary file not shown.
120
rsa/pem.py
Normal file
120
rsa/pem.py
Normal file
|
@ -0,0 +1,120 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright 2011 Sybren A. Stüvel <sybren@stuvel.eu>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
'''Functions that load and write PEM-encoded files.'''
|
||||
|
||||
import base64
|
||||
from rsa._compat import b, is_bytes
|
||||
|
||||
def _markers(pem_marker):
|
||||
'''
|
||||
Returns the start and end PEM markers
|
||||
'''
|
||||
|
||||
if is_bytes(pem_marker):
|
||||
pem_marker = pem_marker.decode('utf-8')
|
||||
|
||||
return (b('-----BEGIN %s-----' % pem_marker),
|
||||
b('-----END %s-----' % pem_marker))
|
||||
|
||||
def load_pem(contents, pem_marker):
|
||||
'''Loads a PEM file.
|
||||
|
||||
@param contents: the contents of the file to interpret
|
||||
@param pem_marker: the marker of the PEM content, such as 'RSA PRIVATE KEY'
|
||||
when your file has '-----BEGIN RSA PRIVATE KEY-----' and
|
||||
'-----END RSA PRIVATE KEY-----' markers.
|
||||
|
||||
@return the base64-decoded content between the start and end markers.
|
||||
|
||||
@raise ValueError: when the content is invalid, for example when the start
|
||||
marker cannot be found.
|
||||
|
||||
'''
|
||||
|
||||
(pem_start, pem_end) = _markers(pem_marker)
|
||||
|
||||
pem_lines = []
|
||||
in_pem_part = False
|
||||
|
||||
for line in contents.splitlines():
|
||||
line = line.strip()
|
||||
|
||||
# Skip empty lines
|
||||
if not line:
|
||||
continue
|
||||
|
||||
# Handle start marker
|
||||
if line == pem_start:
|
||||
if in_pem_part:
|
||||
raise ValueError('Seen start marker "%s" twice' % pem_start)
|
||||
|
||||
in_pem_part = True
|
||||
continue
|
||||
|
||||
# Skip stuff before first marker
|
||||
if not in_pem_part:
|
||||
continue
|
||||
|
||||
# Handle end marker
|
||||
if in_pem_part and line == pem_end:
|
||||
in_pem_part = False
|
||||
break
|
||||
|
||||
# Load fields
|
||||
if b(':') in line:
|
||||
continue
|
||||
|
||||
pem_lines.append(line)
|
||||
|
||||
# Do some sanity checks
|
||||
if not pem_lines:
|
||||
raise ValueError('No PEM start marker "%s" found' % pem_start)
|
||||
|
||||
if in_pem_part:
|
||||
raise ValueError('No PEM end marker "%s" found' % pem_end)
|
||||
|
||||
# Base64-decode the contents
|
||||
pem = b('').join(pem_lines)
|
||||
return base64.decodestring(pem)
|
||||
|
||||
|
||||
def save_pem(contents, pem_marker):
|
||||
'''Saves a PEM file.
|
||||
|
||||
@param contents: the contents to encode in PEM format
|
||||
@param pem_marker: the marker of the PEM content, such as 'RSA PRIVATE KEY'
|
||||
when your file has '-----BEGIN RSA PRIVATE KEY-----' and
|
||||
'-----END RSA PRIVATE KEY-----' markers.
|
||||
|
||||
@return the base64-encoded content between the start and end markers.
|
||||
|
||||
'''
|
||||
|
||||
(pem_start, pem_end) = _markers(pem_marker)
|
||||
|
||||
b64 = base64.encodestring(contents).replace(b('\n'), b(''))
|
||||
pem_lines = [pem_start]
|
||||
|
||||
for block_start in range(0, len(b64), 64):
|
||||
block = b64[block_start:block_start + 64]
|
||||
pem_lines.append(block)
|
||||
|
||||
pem_lines.append(pem_end)
|
||||
pem_lines.append(b(''))
|
||||
|
||||
return b('\n').join(pem_lines)
|
||||
|
BIN
rsa/pem.pyc
Normal file
BIN
rsa/pem.pyc
Normal file
Binary file not shown.
389
rsa/pkcs1.py
Normal file
389
rsa/pkcs1.py
Normal file
|
@ -0,0 +1,389 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright 2011 Sybren A. Stüvel <sybren@stuvel.eu>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
'''Functions for PKCS#1 version 1.5 encryption and signing
|
||||
|
||||
This module implements certain functionality from PKCS#1 version 1.5. For a
|
||||
very clear example, read http://www.di-mgt.com.au/rsa_alg.html#pkcs1schemes
|
||||
|
||||
At least 8 bytes of random padding is used when encrypting a message. This makes
|
||||
these methods much more secure than the ones in the ``rsa`` module.
|
||||
|
||||
WARNING: this module leaks information when decryption or verification fails.
|
||||
The exceptions that are raised contain the Python traceback information, which
|
||||
can be used to deduce where in the process the failure occurred. DO NOT PASS
|
||||
SUCH INFORMATION to your users.
|
||||
'''
|
||||
|
||||
import hashlib
|
||||
import os
|
||||
|
||||
from rsa._compat import b
|
||||
from rsa import common, transform, core, varblock
|
||||
|
||||
# ASN.1 codes that describe the hash algorithm used.
|
||||
HASH_ASN1 = {
|
||||
'MD5': b('\x30\x20\x30\x0c\x06\x08\x2a\x86\x48\x86\xf7\x0d\x02\x05\x05\x00\x04\x10'),
|
||||
'SHA-1': b('\x30\x21\x30\x09\x06\x05\x2b\x0e\x03\x02\x1a\x05\x00\x04\x14'),
|
||||
'SHA-256': b('\x30\x31\x30\x0d\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x01\x05\x00\x04\x20'),
|
||||
'SHA-384': b('\x30\x41\x30\x0d\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x02\x05\x00\x04\x30'),
|
||||
'SHA-512': b('\x30\x51\x30\x0d\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x03\x05\x00\x04\x40'),
|
||||
}
|
||||
|
||||
HASH_METHODS = {
|
||||
'MD5': hashlib.md5,
|
||||
'SHA-1': hashlib.sha1,
|
||||
'SHA-256': hashlib.sha256,
|
||||
'SHA-384': hashlib.sha384,
|
||||
'SHA-512': hashlib.sha512,
|
||||
}
|
||||
|
||||
class CryptoError(Exception):
|
||||
'''Base class for all exceptions in this module.'''
|
||||
|
||||
class DecryptionError(CryptoError):
|
||||
'''Raised when decryption fails.'''
|
||||
|
||||
class VerificationError(CryptoError):
|
||||
'''Raised when verification fails.'''
|
||||
|
||||
def _pad_for_encryption(message, target_length):
|
||||
r'''Pads the message for encryption, returning the padded message.
|
||||
|
||||
:return: 00 02 RANDOM_DATA 00 MESSAGE
|
||||
|
||||
>>> block = _pad_for_encryption('hello', 16)
|
||||
>>> len(block)
|
||||
16
|
||||
>>> block[0:2]
|
||||
'\x00\x02'
|
||||
>>> block[-6:]
|
||||
'\x00hello'
|
||||
|
||||
'''
|
||||
|
||||
max_msglength = target_length - 11
|
||||
msglength = len(message)
|
||||
|
||||
if msglength > max_msglength:
|
||||
raise OverflowError('%i bytes needed for message, but there is only'
|
||||
' space for %i' % (msglength, max_msglength))
|
||||
|
||||
# Get random padding
|
||||
padding = b('')
|
||||
padding_length = target_length - msglength - 3
|
||||
|
||||
# We remove 0-bytes, so we'll end up with less padding than we've asked for,
|
||||
# so keep adding data until we're at the correct length.
|
||||
while len(padding) < padding_length:
|
||||
needed_bytes = padding_length - len(padding)
|
||||
|
||||
# Always read at least 8 bytes more than we need, and trim off the rest
|
||||
# after removing the 0-bytes. This increases the chance of getting
|
||||
# enough bytes, especially when needed_bytes is small
|
||||
new_padding = os.urandom(needed_bytes + 5)
|
||||
new_padding = new_padding.replace(b('\x00'), b(''))
|
||||
padding = padding + new_padding[:needed_bytes]
|
||||
|
||||
assert len(padding) == padding_length
|
||||
|
||||
return b('').join([b('\x00\x02'),
|
||||
padding,
|
||||
b('\x00'),
|
||||
message])
|
||||
|
||||
|
||||
def _pad_for_signing(message, target_length):
|
||||
r'''Pads the message for signing, returning the padded message.
|
||||
|
||||
The padding is always a repetition of FF bytes.
|
||||
|
||||
:return: 00 01 PADDING 00 MESSAGE
|
||||
|
||||
>>> block = _pad_for_signing('hello', 16)
|
||||
>>> len(block)
|
||||
16
|
||||
>>> block[0:2]
|
||||
'\x00\x01'
|
||||
>>> block[-6:]
|
||||
'\x00hello'
|
||||
>>> block[2:-6]
|
||||
'\xff\xff\xff\xff\xff\xff\xff\xff'
|
||||
|
||||
'''
|
||||
|
||||
max_msglength = target_length - 11
|
||||
msglength = len(message)
|
||||
|
||||
if msglength > max_msglength:
|
||||
raise OverflowError('%i bytes needed for message, but there is only'
|
||||
' space for %i' % (msglength, max_msglength))
|
||||
|
||||
padding_length = target_length - msglength - 3
|
||||
|
||||
return b('').join([b('\x00\x01'),
|
||||
padding_length * b('\xff'),
|
||||
b('\x00'),
|
||||
message])
|
||||
|
||||
|
||||
def encrypt(message, pub_key):
|
||||
'''Encrypts the given message using PKCS#1 v1.5
|
||||
|
||||
:param message: the message to encrypt. Must be a byte string no longer than
|
||||
``k-11`` bytes, where ``k`` is the number of bytes needed to encode
|
||||
the ``n`` component of the public key.
|
||||
:param pub_key: the :py:class:`rsa.PublicKey` to encrypt with.
|
||||
:raise OverflowError: when the message is too large to fit in the padded
|
||||
block.
|
||||
|
||||
>>> from rsa import key, common
|
||||
>>> (pub_key, priv_key) = key.newkeys(256)
|
||||
>>> message = 'hello'
|
||||
>>> crypto = encrypt(message, pub_key)
|
||||
|
||||
The crypto text should be just as long as the public key 'n' component:
|
||||
|
||||
>>> len(crypto) == common.byte_size(pub_key.n)
|
||||
True
|
||||
|
||||
'''
|
||||
|
||||
keylength = common.byte_size(pub_key.n)
|
||||
padded = _pad_for_encryption(message, keylength)
|
||||
|
||||
payload = transform.bytes2int(padded)
|
||||
encrypted = core.encrypt_int(payload, pub_key.e, pub_key.n)
|
||||
block = transform.int2bytes(encrypted, keylength)
|
||||
|
||||
return block
|
||||
|
||||
def decrypt(crypto, priv_key):
|
||||
r'''Decrypts the given message using PKCS#1 v1.5
|
||||
|
||||
The decryption is considered 'failed' when the resulting cleartext doesn't
|
||||
start with the bytes 00 02, or when the 00 byte between the padding and
|
||||
the message cannot be found.
|
||||
|
||||
:param crypto: the crypto text as returned by :py:func:`rsa.encrypt`
|
||||
:param priv_key: the :py:class:`rsa.PrivateKey` to decrypt with.
|
||||
:raise DecryptionError: when the decryption fails. No details are given as
|
||||
to why the code thinks the decryption fails, as this would leak
|
||||
information about the private key.
|
||||
|
||||
|
||||
>>> import rsa
|
||||
>>> (pub_key, priv_key) = rsa.newkeys(256)
|
||||
|
||||
It works with strings:
|
||||
|
||||
>>> crypto = encrypt('hello', pub_key)
|
||||
>>> decrypt(crypto, priv_key)
|
||||
'hello'
|
||||
|
||||
And with binary data:
|
||||
|
||||
>>> crypto = encrypt('\x00\x00\x00\x00\x01', pub_key)
|
||||
>>> decrypt(crypto, priv_key)
|
||||
'\x00\x00\x00\x00\x01'
|
||||
|
||||
Altering the encrypted information will *likely* cause a
|
||||
:py:class:`rsa.pkcs1.DecryptionError`. If you want to be *sure*, use
|
||||
:py:func:`rsa.sign`.
|
||||
|
||||
|
||||
.. warning::
|
||||
|
||||
Never display the stack trace of a
|
||||
:py:class:`rsa.pkcs1.DecryptionError` exception. It shows where in the
|
||||
code the exception occurred, and thus leaks information about the key.
|
||||
It's only a tiny bit of information, but every bit makes cracking the
|
||||
keys easier.
|
||||
|
||||
>>> crypto = encrypt('hello', pub_key)
|
||||
>>> crypto = crypto[0:5] + 'X' + crypto[6:] # change a byte
|
||||
>>> decrypt(crypto, priv_key)
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
DecryptionError: Decryption failed
|
||||
|
||||
'''
|
||||
|
||||
blocksize = common.byte_size(priv_key.n)
|
||||
encrypted = transform.bytes2int(crypto)
|
||||
decrypted = core.decrypt_int(encrypted, priv_key.d, priv_key.n)
|
||||
cleartext = transform.int2bytes(decrypted, blocksize)
|
||||
|
||||
# If we can't find the cleartext marker, decryption failed.
|
||||
if cleartext[0:2] != b('\x00\x02'):
|
||||
raise DecryptionError('Decryption failed')
|
||||
|
||||
# Find the 00 separator between the padding and the message
|
||||
try:
|
||||
sep_idx = cleartext.index(b('\x00'), 2)
|
||||
except ValueError:
|
||||
raise DecryptionError('Decryption failed')
|
||||
|
||||
return cleartext[sep_idx+1:]
|
||||
|
||||
def sign(message, priv_key, hash):
|
||||
'''Signs the message with the private key.
|
||||
|
||||
Hashes the message, then signs the hash with the given key. This is known
|
||||
as a "detached signature", because the message itself isn't altered.
|
||||
|
||||
:param message: the message to sign. Can be an 8-bit string or a file-like
|
||||
object. If ``message`` has a ``read()`` method, it is assumed to be a
|
||||
file-like object.
|
||||
:param priv_key: the :py:class:`rsa.PrivateKey` to sign with
|
||||
:param hash: the hash method used on the message. Use 'MD5', 'SHA-1',
|
||||
'SHA-256', 'SHA-384' or 'SHA-512'.
|
||||
:return: a message signature block.
|
||||
:raise OverflowError: if the private key is too small to contain the
|
||||
requested hash.
|
||||
|
||||
'''
|
||||
|
||||
# Get the ASN1 code for this hash method
|
||||
if hash not in HASH_ASN1:
|
||||
raise ValueError('Invalid hash method: %s' % hash)
|
||||
asn1code = HASH_ASN1[hash]
|
||||
|
||||
# Calculate the hash
|
||||
hash = _hash(message, hash)
|
||||
|
||||
# Encrypt the hash with the private key
|
||||
cleartext = asn1code + hash
|
||||
keylength = common.byte_size(priv_key.n)
|
||||
padded = _pad_for_signing(cleartext, keylength)
|
||||
|
||||
payload = transform.bytes2int(padded)
|
||||
encrypted = core.encrypt_int(payload, priv_key.d, priv_key.n)
|
||||
block = transform.int2bytes(encrypted, keylength)
|
||||
|
||||
return block
|
||||
|
||||
def verify(message, signature, pub_key):
|
||||
'''Verifies that the signature matches the message.
|
||||
|
||||
The hash method is detected automatically from the signature.
|
||||
|
||||
:param message: the signed message. Can be an 8-bit string or a file-like
|
||||
object. If ``message`` has a ``read()`` method, it is assumed to be a
|
||||
file-like object.
|
||||
:param signature: the signature block, as created with :py:func:`rsa.sign`.
|
||||
:param pub_key: the :py:class:`rsa.PublicKey` of the person signing the message.
|
||||
:raise VerificationError: when the signature doesn't match the message.
|
||||
|
||||
.. warning::
|
||||
|
||||
Never display the stack trace of a
|
||||
:py:class:`rsa.pkcs1.VerificationError` exception. It shows where in
|
||||
the code the exception occurred, and thus leaks information about the
|
||||
key. It's only a tiny bit of information, but every bit makes cracking
|
||||
the keys easier.
|
||||
|
||||
'''
|
||||
|
||||
blocksize = common.byte_size(pub_key.n)
|
||||
encrypted = transform.bytes2int(signature)
|
||||
decrypted = core.decrypt_int(encrypted, pub_key.e, pub_key.n)
|
||||
clearsig = transform.int2bytes(decrypted, blocksize)
|
||||
|
||||
# If we can't find the signature marker, verification failed.
|
||||
if clearsig[0:2] != b('\x00\x01'):
|
||||
raise VerificationError('Verification failed')
|
||||
|
||||
# Find the 00 separator between the padding and the payload
|
||||
try:
|
||||
sep_idx = clearsig.index(b('\x00'), 2)
|
||||
except ValueError:
|
||||
raise VerificationError('Verification failed')
|
||||
|
||||
# Get the hash and the hash method
|
||||
(method_name, signature_hash) = _find_method_hash(clearsig[sep_idx+1:])
|
||||
message_hash = _hash(message, method_name)
|
||||
|
||||
# Compare the real hash to the hash in the signature
|
||||
if message_hash != signature_hash:
|
||||
raise VerificationError('Verification failed')
|
||||
|
||||
def _hash(message, method_name):
|
||||
'''Returns the message digest.
|
||||
|
||||
:param message: the signed message. Can be an 8-bit string or a file-like
|
||||
object. If ``message`` has a ``read()`` method, it is assumed to be a
|
||||
file-like object.
|
||||
:param method_name: the hash method, must be a key of
|
||||
:py:const:`HASH_METHODS`.
|
||||
|
||||
'''
|
||||
|
||||
if method_name not in HASH_METHODS:
|
||||
raise ValueError('Invalid hash method: %s' % method_name)
|
||||
|
||||
method = HASH_METHODS[method_name]
|
||||
hasher = method()
|
||||
|
||||
if hasattr(message, 'read') and hasattr(message.read, '__call__'):
|
||||
# read as 1K blocks
|
||||
for block in varblock.yield_fixedblocks(message, 1024):
|
||||
hasher.update(block)
|
||||
else:
|
||||
# hash the message object itself.
|
||||
hasher.update(message)
|
||||
|
||||
return hasher.digest()
|
||||
|
||||
|
||||
def _find_method_hash(method_hash):
|
||||
'''Finds the hash method and the hash itself.
|
||||
|
||||
:param method_hash: ASN1 code for the hash method concatenated with the
|
||||
hash itself.
|
||||
|
||||
:return: tuple (method, hash) where ``method`` is the used hash method, and
|
||||
``hash`` is the hash itself.
|
||||
|
||||
:raise VerificationFailed: when the hash method cannot be found
|
||||
|
||||
'''
|
||||
|
||||
for (hashname, asn1code) in HASH_ASN1.items():
|
||||
if not method_hash.startswith(asn1code):
|
||||
continue
|
||||
|
||||
return (hashname, method_hash[len(asn1code):])
|
||||
|
||||
raise VerificationError('Verification failed')
|
||||
|
||||
|
||||
__all__ = ['encrypt', 'decrypt', 'sign', 'verify',
|
||||
'DecryptionError', 'VerificationError', 'CryptoError']
|
||||
|
||||
if __name__ == '__main__':
|
||||
print('Running doctests 1000x or until failure')
|
||||
import doctest
|
||||
|
||||
for count in range(1000):
|
||||
(failures, tests) = doctest.testmod()
|
||||
if failures:
|
||||
break
|
||||
|
||||
if count and count % 100 == 0:
|
||||
print('%i times' % count)
|
||||
|
||||
print('Doctests done')
|
BIN
rsa/pkcs1.pyc
Normal file
BIN
rsa/pkcs1.pyc
Normal file
Binary file not shown.
166
rsa/prime.py
Normal file
166
rsa/prime.py
Normal file
|
@ -0,0 +1,166 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright 2011 Sybren A. Stüvel <sybren@stuvel.eu>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
'''Numerical functions related to primes.
|
||||
|
||||
Implementation based on the book Algorithm Design by Michael T. Goodrich and
|
||||
Roberto Tamassia, 2002.
|
||||
'''
|
||||
|
||||
__all__ = [ 'getprime', 'are_relatively_prime']
|
||||
|
||||
import rsa.randnum
|
||||
|
||||
def gcd(p, q):
|
||||
'''Returns the greatest common divisor of p and q
|
||||
|
||||
>>> gcd(48, 180)
|
||||
12
|
||||
'''
|
||||
|
||||
while q != 0:
|
||||
if p < q: (p,q) = (q,p)
|
||||
(p,q) = (q, p % q)
|
||||
return p
|
||||
|
||||
|
||||
def jacobi(a, b):
|
||||
'''Calculates the value of the Jacobi symbol (a/b) where both a and b are
|
||||
positive integers, and b is odd
|
||||
|
||||
:returns: -1, 0 or 1
|
||||
'''
|
||||
|
||||
assert a > 0
|
||||
assert b > 0
|
||||
|
||||
if a == 0: return 0
|
||||
result = 1
|
||||
while a > 1:
|
||||
if a & 1:
|
||||
if ((a-1)*(b-1) >> 2) & 1:
|
||||
result = -result
|
||||
a, b = b % a, a
|
||||
else:
|
||||
if (((b * b) - 1) >> 3) & 1:
|
||||
result = -result
|
||||
a >>= 1
|
||||
if a == 0: return 0
|
||||
return result
|
||||
|
||||
def jacobi_witness(x, n):
|
||||
'''Returns False if n is an Euler pseudo-prime with base x, and
|
||||
True otherwise.
|
||||
'''
|
||||
|
||||
j = jacobi(x, n) % n
|
||||
|
||||
f = pow(x, n >> 1, n)
|
||||
|
||||
if j == f: return False
|
||||
return True
|
||||
|
||||
def randomized_primality_testing(n, k):
|
||||
'''Calculates whether n is composite (which is always correct) or
|
||||
prime (which is incorrect with error probability 2**-k)
|
||||
|
||||
Returns False if the number is composite, and True if it's
|
||||
probably prime.
|
||||
'''
|
||||
|
||||
# 50% of Jacobi-witnesses can report compositness of non-prime numbers
|
||||
|
||||
# The implemented algorithm using the Jacobi witness function has error
|
||||
# probability q <= 0.5, according to Goodrich et. al
|
||||
#
|
||||
# q = 0.5
|
||||
# t = int(math.ceil(k / log(1 / q, 2)))
|
||||
# So t = k / log(2, 2) = k / 1 = k
|
||||
# this means we can use range(k) rather than range(t)
|
||||
|
||||
for _ in range(k):
|
||||
x = rsa.randnum.randint(n-1)
|
||||
if jacobi_witness(x, n): return False
|
||||
|
||||
return True
|
||||
|
||||
def is_prime(number):
|
||||
'''Returns True if the number is prime, and False otherwise.
|
||||
|
||||
>>> is_prime(42)
|
||||
False
|
||||
>>> is_prime(41)
|
||||
True
|
||||
'''
|
||||
|
||||
return randomized_primality_testing(number, 6)
|
||||
|
||||
def getprime(nbits):
|
||||
'''Returns a prime number that can be stored in 'nbits' bits.
|
||||
|
||||
>>> p = getprime(128)
|
||||
>>> is_prime(p-1)
|
||||
False
|
||||
>>> is_prime(p)
|
||||
True
|
||||
>>> is_prime(p+1)
|
||||
False
|
||||
|
||||
>>> from rsa import common
|
||||
>>> common.bit_size(p) == 128
|
||||
True
|
||||
|
||||
'''
|
||||
|
||||
while True:
|
||||
integer = rsa.randnum.read_random_int(nbits)
|
||||
|
||||
# Make sure it's odd
|
||||
integer |= 1
|
||||
|
||||
# Test for primeness
|
||||
if is_prime(integer):
|
||||
return integer
|
||||
|
||||
# Retry if not prime
|
||||
|
||||
|
||||
def are_relatively_prime(a, b):
|
||||
'''Returns True if a and b are relatively prime, and False if they
|
||||
are not.
|
||||
|
||||
>>> are_relatively_prime(2, 3)
|
||||
1
|
||||
>>> are_relatively_prime(2, 4)
|
||||
0
|
||||
'''
|
||||
|
||||
d = gcd(a, b)
|
||||
return (d == 1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
print('Running doctests 1000x or until failure')
|
||||
import doctest
|
||||
|
||||
for count in range(1000):
|
||||
(failures, tests) = doctest.testmod()
|
||||
if failures:
|
||||
break
|
||||
|
||||
if count and count % 100 == 0:
|
||||
print('%i times' % count)
|
||||
|
||||
print('Doctests done')
|
BIN
rsa/prime.pyc
Normal file
BIN
rsa/prime.pyc
Normal file
Binary file not shown.
85
rsa/randnum.py
Normal file
85
rsa/randnum.py
Normal file
|
@ -0,0 +1,85 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright 2011 Sybren A. Stüvel <sybren@stuvel.eu>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
'''Functions for generating random numbers.'''
|
||||
|
||||
# Source inspired by code by Yesudeep Mangalapilly <yesudeep@gmail.com>
|
||||
|
||||
import os
|
||||
|
||||
from rsa import common, transform
|
||||
from rsa._compat import byte
|
||||
|
||||
def read_random_bits(nbits):
|
||||
'''Reads 'nbits' random bits.
|
||||
|
||||
If nbits isn't a whole number of bytes, an extra byte will be appended with
|
||||
only the lower bits set.
|
||||
'''
|
||||
|
||||
nbytes, rbits = divmod(nbits, 8)
|
||||
|
||||
# Get the random bytes
|
||||
randomdata = os.urandom(nbytes)
|
||||
|
||||
# Add the remaining random bits
|
||||
if rbits > 0:
|
||||
randomvalue = ord(os.urandom(1))
|
||||
randomvalue >>= (8 - rbits)
|
||||
randomdata = byte(randomvalue) + randomdata
|
||||
|
||||
return randomdata
|
||||
|
||||
|
||||
def read_random_int(nbits):
|
||||
'''Reads a random integer of approximately nbits bits.
|
||||
'''
|
||||
|
||||
randomdata = read_random_bits(nbits)
|
||||
value = transform.bytes2int(randomdata)
|
||||
|
||||
# Ensure that the number is large enough to just fill out the required
|
||||
# number of bits.
|
||||
value |= 1 << (nbits - 1)
|
||||
|
||||
return value
|
||||
|
||||
def randint(maxvalue):
|
||||
'''Returns a random integer x with 1 <= x <= maxvalue
|
||||
|
||||
May take a very long time in specific situations. If maxvalue needs N bits
|
||||
to store, the closer maxvalue is to (2 ** N) - 1, the faster this function
|
||||
is.
|
||||
'''
|
||||
|
||||
bit_size = common.bit_size(maxvalue)
|
||||
|
||||
tries = 0
|
||||
while True:
|
||||
value = read_random_int(bit_size)
|
||||
if value <= maxvalue:
|
||||
break
|
||||
|
||||
if tries and tries % 10 == 0:
|
||||
# After a lot of tries to get the right number of bits but still
|
||||
# smaller than maxvalue, decrease the number of bits by 1. That'll
|
||||
# dramatically increase the chances to get a large enough number.
|
||||
bit_size -= 1
|
||||
tries += 1
|
||||
|
||||
return value
|
||||
|
||||
|
BIN
rsa/randnum.pyc
Normal file
BIN
rsa/randnum.pyc
Normal file
Binary file not shown.
220
rsa/transform.py
Normal file
220
rsa/transform.py
Normal file
|
@ -0,0 +1,220 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright 2011 Sybren A. Stüvel <sybren@stuvel.eu>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
'''Data transformation functions.
|
||||
|
||||
From bytes to a number, number to bytes, etc.
|
||||
'''
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
try:
|
||||
# We'll use psyco if available on 32-bit architectures to speed up code.
|
||||
# Using psyco (if available) cuts down the execution time on Python 2.5
|
||||
# at least by half.
|
||||
import psyco
|
||||
psyco.full()
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
import binascii
|
||||
from struct import pack
|
||||
from rsa import common
|
||||
from rsa._compat import is_integer, b, byte, get_word_alignment, ZERO_BYTE, EMPTY_BYTE
|
||||
|
||||
|
||||
def bytes2int(raw_bytes):
|
||||
r'''Converts a list of bytes or an 8-bit string to an integer.
|
||||
|
||||
When using unicode strings, encode it to some encoding like UTF8 first.
|
||||
|
||||
>>> (((128 * 256) + 64) * 256) + 15
|
||||
8405007
|
||||
>>> bytes2int('\x80@\x0f')
|
||||
8405007
|
||||
|
||||
'''
|
||||
|
||||
return int(binascii.hexlify(raw_bytes), 16)
|
||||
|
||||
|
||||
def _int2bytes(number, block_size=None):
|
||||
r'''Converts a number to a string of bytes.
|
||||
|
||||
Usage::
|
||||
|
||||
>>> _int2bytes(123456789)
|
||||
'\x07[\xcd\x15'
|
||||
>>> bytes2int(_int2bytes(123456789))
|
||||
123456789
|
||||
|
||||
>>> _int2bytes(123456789, 6)
|
||||
'\x00\x00\x07[\xcd\x15'
|
||||
>>> bytes2int(_int2bytes(123456789, 128))
|
||||
123456789
|
||||
|
||||
>>> _int2bytes(123456789, 3)
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
OverflowError: Needed 4 bytes for number, but block size is 3
|
||||
|
||||
@param number: the number to convert
|
||||
@param block_size: the number of bytes to output. If the number encoded to
|
||||
bytes is less than this, the block will be zero-padded. When not given,
|
||||
the returned block is not padded.
|
||||
|
||||
@throws OverflowError when block_size is given and the number takes up more
|
||||
bytes than fit into the block.
|
||||
'''
|
||||
# Type checking
|
||||
if not is_integer(number):
|
||||
raise TypeError("You must pass an integer for 'number', not %s" %
|
||||
number.__class__)
|
||||
|
||||
if number < 0:
|
||||
raise ValueError('Negative numbers cannot be used: %i' % number)
|
||||
|
||||
# Do some bounds checking
|
||||
if number == 0:
|
||||
needed_bytes = 1
|
||||
raw_bytes = [ZERO_BYTE]
|
||||
else:
|
||||
needed_bytes = common.byte_size(number)
|
||||
raw_bytes = []
|
||||
|
||||
# You cannot compare None > 0 in Python 3x. It will fail with a TypeError.
|
||||
if block_size and block_size > 0:
|
||||
if needed_bytes > block_size:
|
||||
raise OverflowError('Needed %i bytes for number, but block size '
|
||||
'is %i' % (needed_bytes, block_size))
|
||||
|
||||
# Convert the number to bytes.
|
||||
while number > 0:
|
||||
raw_bytes.insert(0, byte(number & 0xFF))
|
||||
number >>= 8
|
||||
|
||||
# Pad with zeroes to fill the block
|
||||
if block_size and block_size > 0:
|
||||
padding = (block_size - needed_bytes) * ZERO_BYTE
|
||||
else:
|
||||
padding = EMPTY_BYTE
|
||||
|
||||
return padding + EMPTY_BYTE.join(raw_bytes)
|
||||
|
||||
|
||||
def bytes_leading(raw_bytes, needle=ZERO_BYTE):
|
||||
'''
|
||||
Finds the number of prefixed byte occurrences in the haystack.
|
||||
|
||||
Useful when you want to deal with padding.
|
||||
|
||||
:param raw_bytes:
|
||||
Raw bytes.
|
||||
:param needle:
|
||||
The byte to count. Default \000.
|
||||
:returns:
|
||||
The number of leading needle bytes.
|
||||
'''
|
||||
leading = 0
|
||||
# Indexing keeps compatibility between Python 2.x and Python 3.x
|
||||
_byte = needle[0]
|
||||
for x in raw_bytes:
|
||||
if x == _byte:
|
||||
leading += 1
|
||||
else:
|
||||
break
|
||||
return leading
|
||||
|
||||
|
||||
def int2bytes(number, fill_size=None, chunk_size=None, overflow=False):
|
||||
'''
|
||||
Convert an unsigned integer to bytes (base-256 representation)::
|
||||
|
||||
Does not preserve leading zeros if you don't specify a chunk size or
|
||||
fill size.
|
||||
|
||||
.. NOTE:
|
||||
You must not specify both fill_size and chunk_size. Only one
|
||||
of them is allowed.
|
||||
|
||||
:param number:
|
||||
Integer value
|
||||
:param fill_size:
|
||||
If the optional fill size is given the length of the resulting
|
||||
byte string is expected to be the fill size and will be padded
|
||||
with prefix zero bytes to satisfy that length.
|
||||
:param chunk_size:
|
||||
If optional chunk size is given and greater than zero, pad the front of
|
||||
the byte string with binary zeros so that the length is a multiple of
|
||||
``chunk_size``.
|
||||
:param overflow:
|
||||
``False`` (default). If this is ``True``, no ``OverflowError``
|
||||
will be raised when the fill_size is shorter than the length
|
||||
of the generated byte sequence. Instead the byte sequence will
|
||||
be returned as is.
|
||||
:returns:
|
||||
Raw bytes (base-256 representation).
|
||||
:raises:
|
||||
``OverflowError`` when fill_size is given and the number takes up more
|
||||
bytes than fit into the block. This requires the ``overflow``
|
||||
argument to this function to be set to ``False`` otherwise, no
|
||||
error will be raised.
|
||||
'''
|
||||
if number < 0:
|
||||
raise ValueError("Number must be an unsigned integer: %d" % number)
|
||||
|
||||
if fill_size and chunk_size:
|
||||
raise ValueError("You can either fill or pad chunks, but not both")
|
||||
|
||||
# Ensure these are integers.
|
||||
number & 1
|
||||
|
||||
raw_bytes = b('')
|
||||
|
||||
# Pack the integer one machine word at a time into bytes.
|
||||
num = number
|
||||
word_bits, _, max_uint, pack_type = get_word_alignment(num)
|
||||
pack_format = ">%s" % pack_type
|
||||
while num > 0:
|
||||
raw_bytes = pack(pack_format, num & max_uint) + raw_bytes
|
||||
num >>= word_bits
|
||||
# Obtain the index of the first non-zero byte.
|
||||
zero_leading = bytes_leading(raw_bytes)
|
||||
if number == 0:
|
||||
raw_bytes = ZERO_BYTE
|
||||
# De-padding.
|
||||
raw_bytes = raw_bytes[zero_leading:]
|
||||
|
||||
length = len(raw_bytes)
|
||||
if fill_size and fill_size > 0:
|
||||
if not overflow and length > fill_size:
|
||||
raise OverflowError(
|
||||
"Need %d bytes for number, but fill size is %d" %
|
||||
(length, fill_size)
|
||||
)
|
||||
raw_bytes = raw_bytes.rjust(fill_size, ZERO_BYTE)
|
||||
elif chunk_size and chunk_size > 0:
|
||||
remainder = length % chunk_size
|
||||
if remainder:
|
||||
padding_size = chunk_size - remainder
|
||||
raw_bytes = raw_bytes.rjust(length + padding_size, ZERO_BYTE)
|
||||
return raw_bytes
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import doctest
|
||||
doctest.testmod()
|
||||
|
BIN
rsa/transform.pyc
Normal file
BIN
rsa/transform.pyc
Normal file
Binary file not shown.
79
rsa/util.py
Normal file
79
rsa/util.py
Normal file
|
@ -0,0 +1,79 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright 2011 Sybren A. Stüvel <sybren@stuvel.eu>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
'''Utility functions.'''
|
||||
|
||||
from __future__ import with_statement
|
||||
|
||||
import sys
|
||||
from optparse import OptionParser
|
||||
|
||||
import rsa.key
|
||||
|
||||
def private_to_public():
|
||||
'''Reads a private key and outputs the corresponding public key.'''
|
||||
|
||||
# Parse the CLI options
|
||||
parser = OptionParser(usage='usage: %prog [options]',
|
||||
description='Reads a private key and outputs the '
|
||||
'corresponding public key. Both private and public keys use '
|
||||
'the format described in PKCS#1 v1.5')
|
||||
|
||||
parser.add_option('-i', '--input', dest='infilename', type='string',
|
||||
help='Input filename. Reads from stdin if not specified')
|
||||
parser.add_option('-o', '--output', dest='outfilename', type='string',
|
||||
help='Output filename. Writes to stdout of not specified')
|
||||
|
||||
parser.add_option('--inform', dest='inform',
|
||||
help='key format of input - default PEM',
|
||||
choices=('PEM', 'DER'), default='PEM')
|
||||
|
||||
parser.add_option('--outform', dest='outform',
|
||||
help='key format of output - default PEM',
|
||||
choices=('PEM', 'DER'), default='PEM')
|
||||
|
||||
(cli, cli_args) = parser.parse_args(sys.argv)
|
||||
|
||||
# Read the input data
|
||||
if cli.infilename:
|
||||
print >>sys.stderr, 'Reading private key from %s in %s format' % \
|
||||
(cli.infilename, cli.inform)
|
||||
with open(cli.infilename) as infile:
|
||||
in_data = infile.read()
|
||||
else:
|
||||
print >>sys.stderr, 'Reading private key from stdin in %s format' % \
|
||||
cli.inform
|
||||
in_data = sys.stdin.read()
|
||||
|
||||
|
||||
# Take the public fields and create a public key
|
||||
priv_key = rsa.key.PrivateKey.load_pkcs1(in_data, cli.inform)
|
||||
pub_key = rsa.key.PublicKey(priv_key.n, priv_key.e)
|
||||
|
||||
# Save to the output file
|
||||
out_data = pub_key.save_pkcs1(cli.outform)
|
||||
|
||||
if cli.outfilename:
|
||||
print >>sys.stderr, 'Writing public key to %s in %s format' % \
|
||||
(cli.outfilename, cli.outform)
|
||||
with open(cli.outfilename, 'w') as outfile:
|
||||
outfile.write(out_data)
|
||||
else:
|
||||
print >>sys.stderr, 'Writing public key to stdout in %s format' % \
|
||||
cli.outform
|
||||
sys.stdout.write(out_data)
|
||||
|
||||
|
155
rsa/varblock.py
Normal file
155
rsa/varblock.py
Normal file
|
@ -0,0 +1,155 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright 2011 Sybren A. Stüvel <sybren@stuvel.eu>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
'''VARBLOCK file support
|
||||
|
||||
The VARBLOCK file format is as follows, where || denotes byte concatenation:
|
||||
|
||||
FILE := VERSION || BLOCK || BLOCK ...
|
||||
|
||||
BLOCK := LENGTH || DATA
|
||||
|
||||
LENGTH := varint-encoded length of the subsequent data. Varint comes from
|
||||
Google Protobuf, and encodes an integer into a variable number of bytes.
|
||||
Each byte uses the 7 lowest bits to encode the value. The highest bit set
|
||||
to 1 indicates the next byte is also part of the varint. The last byte will
|
||||
have this bit set to 0.
|
||||
|
||||
This file format is called the VARBLOCK format, in line with the varint format
|
||||
used to denote the block sizes.
|
||||
|
||||
'''
|
||||
|
||||
from rsa._compat import byte, b
|
||||
|
||||
|
||||
ZERO_BYTE = b('\x00')
|
||||
VARBLOCK_VERSION = 1
|
||||
|
||||
def read_varint(infile):
|
||||
'''Reads a varint from the file.
|
||||
|
||||
When the first byte to be read indicates EOF, (0, 0) is returned. When an
|
||||
EOF occurs when at least one byte has been read, an EOFError exception is
|
||||
raised.
|
||||
|
||||
@param infile: the file-like object to read from. It should have a read()
|
||||
method.
|
||||
@returns (varint, length), the read varint and the number of read bytes.
|
||||
'''
|
||||
|
||||
varint = 0
|
||||
read_bytes = 0
|
||||
|
||||
while True:
|
||||
char = infile.read(1)
|
||||
if len(char) == 0:
|
||||
if read_bytes == 0:
|
||||
return (0, 0)
|
||||
raise EOFError('EOF while reading varint, value is %i so far' %
|
||||
varint)
|
||||
|
||||
byte = ord(char)
|
||||
varint += (byte & 0x7F) << (7 * read_bytes)
|
||||
|
||||
read_bytes += 1
|
||||
|
||||
if not byte & 0x80:
|
||||
return (varint, read_bytes)
|
||||
|
||||
|
||||
def write_varint(outfile, value):
|
||||
'''Writes a varint to a file.
|
||||
|
||||
@param outfile: the file-like object to write to. It should have a write()
|
||||
method.
|
||||
@returns the number of written bytes.
|
||||
'''
|
||||
|
||||
# there is a big difference between 'write the value 0' (this case) and
|
||||
# 'there is nothing left to write' (the false-case of the while loop)
|
||||
|
||||
if value == 0:
|
||||
outfile.write(ZERO_BYTE)
|
||||
return 1
|
||||
|
||||
written_bytes = 0
|
||||
while value > 0:
|
||||
to_write = value & 0x7f
|
||||
value = value >> 7
|
||||
|
||||
if value > 0:
|
||||
to_write |= 0x80
|
||||
|
||||
outfile.write(byte(to_write))
|
||||
written_bytes += 1
|
||||
|
||||
return written_bytes
|
||||
|
||||
|
||||
def yield_varblocks(infile):
|
||||
'''Generator, yields each block in the input file.
|
||||
|
||||
@param infile: file to read, is expected to have the VARBLOCK format as
|
||||
described in the module's docstring.
|
||||
@yields the contents of each block.
|
||||
'''
|
||||
|
||||
# Check the version number
|
||||
first_char = infile.read(1)
|
||||
if len(first_char) == 0:
|
||||
raise EOFError('Unable to read VARBLOCK version number')
|
||||
|
||||
version = ord(first_char)
|
||||
if version != VARBLOCK_VERSION:
|
||||
raise ValueError('VARBLOCK version %i not supported' % version)
|
||||
|
||||
while True:
|
||||
(block_size, read_bytes) = read_varint(infile)
|
||||
|
||||
# EOF at block boundary, that's fine.
|
||||
if read_bytes == 0 and block_size == 0:
|
||||
break
|
||||
|
||||
block = infile.read(block_size)
|
||||
|
||||
read_size = len(block)
|
||||
if read_size != block_size:
|
||||
raise EOFError('Block size is %i, but could read only %i bytes' %
|
||||
(block_size, read_size))
|
||||
|
||||
yield block
|
||||
|
||||
|
||||
def yield_fixedblocks(infile, blocksize):
|
||||
'''Generator, yields each block of ``blocksize`` bytes in the input file.
|
||||
|
||||
:param infile: file to read and separate in blocks.
|
||||
:returns: a generator that yields the contents of each block
|
||||
'''
|
||||
|
||||
while True:
|
||||
block = infile.read(blocksize)
|
||||
|
||||
read_bytes = len(block)
|
||||
if read_bytes == 0:
|
||||
break
|
||||
|
||||
yield block
|
||||
|
||||
if read_bytes < blocksize:
|
||||
break
|
||||
|
BIN
rsa/varblock.pyc
Normal file
BIN
rsa/varblock.pyc
Normal file
Binary file not shown.
89
settings.py
Normal file
89
settings.py
Normal file
|
@ -0,0 +1,89 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Form implementation generated from reading ui file 'settings.ui'
|
||||
#
|
||||
# Created: Mon Nov 19 13:33:39 2012
|
||||
# by: PyQt4 UI code generator 4.9.4
|
||||
#
|
||||
# WARNING! All changes made in this file will be lost!
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
try:
|
||||
_fromUtf8 = QtCore.QString.fromUtf8
|
||||
except AttributeError:
|
||||
_fromUtf8 = lambda s: s
|
||||
|
||||
class Ui_settingsDialog(object):
|
||||
def setupUi(self, settingsDialog):
|
||||
settingsDialog.setObjectName(_fromUtf8("settingsDialog"))
|
||||
settingsDialog.resize(417, 297)
|
||||
self.gridLayout = QtGui.QGridLayout(settingsDialog)
|
||||
self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
|
||||
self.tabWidgetSettings = QtGui.QTabWidget(settingsDialog)
|
||||
self.tabWidgetSettings.setObjectName(_fromUtf8("tabWidgetSettings"))
|
||||
self.tabUserInterface = QtGui.QWidget()
|
||||
self.tabUserInterface.setEnabled(True)
|
||||
self.tabUserInterface.setObjectName(_fromUtf8("tabUserInterface"))
|
||||
self.formLayout = QtGui.QFormLayout(self.tabUserInterface)
|
||||
self.formLayout.setFieldGrowthPolicy(QtGui.QFormLayout.AllNonFixedFieldsGrow)
|
||||
self.formLayout.setObjectName(_fromUtf8("formLayout"))
|
||||
self.checkBoxStartOnLogon = QtGui.QCheckBox(self.tabUserInterface)
|
||||
self.checkBoxStartOnLogon.setObjectName(_fromUtf8("checkBoxStartOnLogon"))
|
||||
self.formLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.checkBoxStartOnLogon)
|
||||
self.checkBoxStartInTray = QtGui.QCheckBox(self.tabUserInterface)
|
||||
self.checkBoxStartInTray.setObjectName(_fromUtf8("checkBoxStartInTray"))
|
||||
self.formLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.checkBoxStartInTray)
|
||||
self.checkBoxMinimizeToTray = QtGui.QCheckBox(self.tabUserInterface)
|
||||
self.checkBoxMinimizeToTray.setChecked(True)
|
||||
self.checkBoxMinimizeToTray.setObjectName(_fromUtf8("checkBoxMinimizeToTray"))
|
||||
self.formLayout.setWidget(2, QtGui.QFormLayout.LabelRole, self.checkBoxMinimizeToTray)
|
||||
self.checkBoxShowTrayNotifications = QtGui.QCheckBox(self.tabUserInterface)
|
||||
self.checkBoxShowTrayNotifications.setObjectName(_fromUtf8("checkBoxShowTrayNotifications"))
|
||||
self.formLayout.setWidget(3, QtGui.QFormLayout.SpanningRole, self.checkBoxShowTrayNotifications)
|
||||
spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
|
||||
self.formLayout.setItem(4, QtGui.QFormLayout.LabelRole, spacerItem)
|
||||
self.labelSettingsNote = QtGui.QLabel(self.tabUserInterface)
|
||||
self.labelSettingsNote.setText(_fromUtf8(""))
|
||||
self.labelSettingsNote.setWordWrap(True)
|
||||
self.labelSettingsNote.setObjectName(_fromUtf8("labelSettingsNote"))
|
||||
self.formLayout.setWidget(5, QtGui.QFormLayout.SpanningRole, self.labelSettingsNote)
|
||||
self.tabWidgetSettings.addTab(self.tabUserInterface, _fromUtf8(""))
|
||||
self.tabNetworkSettings = QtGui.QWidget()
|
||||
self.tabNetworkSettings.setObjectName(_fromUtf8("tabNetworkSettings"))
|
||||
self.gridLayout_2 = QtGui.QGridLayout(self.tabNetworkSettings)
|
||||
self.gridLayout_2.setObjectName(_fromUtf8("gridLayout_2"))
|
||||
spacerItem1 = QtGui.QSpacerItem(56, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
|
||||
self.gridLayout_2.addItem(spacerItem1, 0, 0, 1, 1)
|
||||
self.label = QtGui.QLabel(self.tabNetworkSettings)
|
||||
self.label.setObjectName(_fromUtf8("label"))
|
||||
self.gridLayout_2.addWidget(self.label, 0, 1, 1, 1)
|
||||
self.lineEditTCPPort = QtGui.QLineEdit(self.tabNetworkSettings)
|
||||
self.lineEditTCPPort.setObjectName(_fromUtf8("lineEditTCPPort"))
|
||||
self.gridLayout_2.addWidget(self.lineEditTCPPort, 0, 2, 1, 1)
|
||||
spacerItem2 = QtGui.QSpacerItem(20, 169, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
|
||||
self.gridLayout_2.addItem(spacerItem2, 1, 2, 1, 1)
|
||||
self.tabWidgetSettings.addTab(self.tabNetworkSettings, _fromUtf8(""))
|
||||
self.gridLayout.addWidget(self.tabWidgetSettings, 0, 0, 1, 1)
|
||||
self.buttonBox = QtGui.QDialogButtonBox(settingsDialog)
|
||||
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
|
||||
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
|
||||
self.buttonBox.setObjectName(_fromUtf8("buttonBox"))
|
||||
self.gridLayout.addWidget(self.buttonBox, 1, 0, 1, 1)
|
||||
|
||||
self.retranslateUi(settingsDialog)
|
||||
self.tabWidgetSettings.setCurrentIndex(0)
|
||||
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), settingsDialog.accept)
|
||||
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), settingsDialog.reject)
|
||||
QtCore.QMetaObject.connectSlotsByName(settingsDialog)
|
||||
|
||||
def retranslateUi(self, settingsDialog):
|
||||
settingsDialog.setWindowTitle(QtGui.QApplication.translate("settingsDialog", "Settings", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.checkBoxStartOnLogon.setText(QtGui.QApplication.translate("settingsDialog", "Start Bitmessage on user login", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.checkBoxStartInTray.setText(QtGui.QApplication.translate("settingsDialog", "Start Bitmessage in the tray (don\'t show main window)", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.checkBoxMinimizeToTray.setText(QtGui.QApplication.translate("settingsDialog", "Minimize to tray", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.checkBoxShowTrayNotifications.setText(QtGui.QApplication.translate("settingsDialog", "Show notification when message received and minimzed to tray", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.tabWidgetSettings.setTabText(self.tabWidgetSettings.indexOf(self.tabUserInterface), QtGui.QApplication.translate("settingsDialog", "User Interface", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.label.setText(QtGui.QApplication.translate("settingsDialog", "Listen for connections on port:", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.tabWidgetSettings.setTabText(self.tabWidgetSettings.indexOf(self.tabNetworkSettings), QtGui.QApplication.translate("settingsDialog", "Network Settings", None, QtGui.QApplication.UnicodeUTF8))
|
||||
|
181
settings.ui
Normal file
181
settings.ui
Normal file
|
@ -0,0 +1,181 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>settingsDialog</class>
|
||||
<widget class="QDialog" name="settingsDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>417</width>
|
||||
<height>297</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Settings</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QTabWidget" name="tabWidgetSettings">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tabUserInterface">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<attribute name="title">
|
||||
<string>User Interface</string>
|
||||
</attribute>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="checkBoxStartOnLogon">
|
||||
<property name="text">
|
||||
<string>Start Bitmessage on user login</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="checkBoxStartInTray">
|
||||
<property name="text">
|
||||
<string>Start Bitmessage in the tray (don't show main window)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QCheckBox" name="checkBoxMinimizeToTray">
|
||||
<property name="text">
|
||||
<string>Minimize to tray</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="checkBoxShowTrayNotifications">
|
||||
<property name="text">
|
||||
<string>Show notification when message received and minimzed to tray</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="2">
|
||||
<widget class="QLabel" name="labelSettingsNote">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tabNetworkSettings">
|
||||
<attribute name="title">
|
||||
<string>Network Settings</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>56</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Listen for connections on port:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLineEdit" name="lineEditTCPPort"/>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>169</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>settingsDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>settingsDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
Reference in New Issue
Block a user