Commit Graph

260 Commits

Author SHA1 Message Date
ThomasV
5c73bc5bc7 interface: init ping_time with 0 so that the client sends version message 2015-05-19 11:28:30 +02:00
ThomasV
2a92a310ba typo 2015-05-08 17:47:04 +02:00
ThomasV
8c07bdc3bc do not timeout if interface is receiving data 2015-05-08 17:45:59 +02:00
Neil Booth
97b5f6d6a3 Fix two races in interface.py.
First, close the socket from the thread itself rather than from
the stop() function.  This prevents another thread closing the
socket that the interface thread is simultaneously using.

Second, it occasionally would happen that the parent thread such as
network.py start() an interface, do a send_request() and timeout
waiting for a response (timeouts are 0.1s).  It would check
is_connected(), get False, and assume the connection has failed.
In fact the thread hadn't even been scheduled or gotten around to
completing the socket connection.  Fix by having self.connected
start out True.  If the connection fails or times out, we set
connected to False soon enough.

Finally for correctness we need to deepcopy a send_request() rather
than take a reference to it.
2015-05-08 07:32:31 +09:00
ThomasV
8656785aa7 fix: use request_time for interface timeout 2015-05-06 17:25:29 +02:00
ThomasV
45fd3ef343 interface: send from same thread and simplify timeouts 2015-05-06 16:42:18 +02:00
ThomasV
78f5dbb72e revert c64e0c0e64 2015-05-06 12:13:21 +02:00
Neil Booth
6171779442 Move response getting to its own function.
This makes the operation of run() more clear.
No essential change in functionality.
2015-05-06 14:35:55 +09:00
Neil Booth
0cfcd2c7b2 Remove self.lock
It is now unused; all necesary locking is done by the Queue objects.
2015-05-05 21:57:07 +09:00
Neil Booth
c64e0c0e64 Send requests only from the interface thread.
Currently requests are sent from the requestor's thread.  The lock is
not properly held where necessary so this is not thread-safe.  For example
it can race with the thread stopping and closing the socket the
requestor is trying to use to send with.

Resolve such races by having send_request() simply queue the requests,
which are asynchronously sent from the interface thread itself.
2015-05-05 21:36:34 +09:00
Neil Booth
6920747a5d Move ping functionality into its own function.
First step in cleaning up the run() function.
Calls stop() rather than setting is_connected to False on
case of timeout, which cleanly closes the socket.
2015-05-05 20:46:34 +09:00
Neil Booth
c07e956127 Pass the response_queue to the constructor, not start().
Removes an unnecessary Thread base-class override.  The python
documentation also strongly discourages overriding anything other
than run().
2015-05-05 20:37:25 +09:00
Neil Booth
9cf2eff16b Make is_connected into a member function. No change in logic. 2015-05-05 20:00:10 +09:00
Neil Booth
4d55cb9528 First of several incremental patches tightening up interface.py.
Remove some unneeded imports, a constant and a line of dead code.
Document the current external API interface.py provides.
2015-05-05 14:02:51 +09:00
ThomasV
f32f1183fc print_error methods. request timeout for interface 2015-03-12 21:39:05 +01:00
ThomasV
799a08514b move proxy logic to network.py. reload socket module if proxy is disabled 2015-03-12 12:56:06 +01:00
ThomasV
ae7405a10f remove old http interface code, not used 2015-03-12 11:55:10 +01:00
ThomasV
92987d9019 add comment about proxy side effect 2015-03-10 09:43:22 +01:00
ThomasV
73d8ba24d9 fix network connection issues 2015-03-07 22:47:25 +01:00
ThomasV
fdaf4e42a9 print reason if connection fails 2015-02-28 19:45:10 +01:00
ThomasV
b3364b87d1 interface: don't show traceback on error 104 2015-02-21 14:45:09 +01:00
ThomasV
992a634a77 serialize: handle case where proxy is None 2015-01-29 11:30:42 +01:00
ThomasV
30763a6555 fix config: serialize/deserialize proxy 2015-01-29 11:21:17 +01:00
ThomasV
c225795793 use ssl.PROTOCOL_SSLv23 2014-10-31 14:59:59 +01:00
Tafelpoot
d9c5250a6f removed trailing whitespace and fixed indentation in history widget 2014-10-21 19:05:51 +02:00
ThomasV
60e5450a0e rm print statement 2014-09-28 23:20:52 +02:00
ThomasV
0c0da6a36d use certs from request module in interface.py 2014-09-28 23:19:52 +02:00
ThomasV
52450289ff we must check host name if cert is signed by CA 2014-09-19 10:18:33 +02:00
ThomasV
889ac782c1 simplify interface.get_socket, and fix a bug with new certificates 2014-09-19 09:25:44 +02:00
ThomasV
dd849964d1 interface: forward errors 2014-09-05 14:51:37 +02:00
ThomasV
8ca42bbf43 accept ssl certs signed by CA 2014-08-22 10:33:13 +02:00
ThomasV
ae56de3160 rm dead code 2014-08-18 18:23:45 +02:00
ThomasV
3a9bb3cd43 interface: print debug message with the correct id 2014-08-13 21:58:01 +02:00
ThomasV
efa0972971 use ping time to determine if we are disconnected 2014-07-29 17:57:03 +02:00
ThomasV
411a87e0a3 fix disconnection error 2014-07-29 14:19:23 +02:00
ThomasV
58c817f81a close interfaces on shutdown 2014-07-29 12:13:21 +02:00
ThomasV
44072a4f48 separate interface classes 2014-07-29 09:28:27 +02:00
ThomasV
ed8f9666df remove interface.synchronous_get 2014-07-29 00:15:21 +02:00
ThomasV
fb878e1045 fix: catch server.version 2014-07-28 08:23:28 +02:00
ThomasV
28df27fba2 update interface.py 2014-07-28 00:13:40 +02:00
ThomasV
9efc25bdba interface: use parse_json 2014-07-26 16:24:22 +02:00
ThomasV
9a07c1cb44 rename process_response 2014-07-26 15:47:30 +02:00
ThomasV
191520f064 interface.py: print -> print_error 2014-07-25 17:21:17 +02:00
ThomasV
f9985ae233 use x509 to check if server certificate has expired 2014-06-27 11:36:51 +02:00
ThomasV
80a988e337 slightly better notifications. at least, it fixes #652 2014-04-17 17:38:21 +02:00
ThomasV
696766c370 json-friendly debug messages. fix #659 2014-04-17 17:20:07 +02:00
ThomasV
268a099f87 sync_get 2014-01-29 16:48:00 +01:00
dmcdad
292ab39553 Update interface.py
Fix timeout problem under Python 2.7.1 where a socket.error 60 is thrown instead of socket.timeout exception.
2014-01-15 08:49:26 -06:00
ThomasV
f4f418e9ec return message ids with send_http too 2013-12-21 19:27:49 +01:00
ThomasV
de94eaadeb fix issue occuring with set_server 2013-12-17 18:20:54 +01:00
ThomasV
60b6fd399d exit gracefully if host cannot be resolved. Fixes #488 2013-12-13 09:22:39 +01:00
ThomasV
cff8515e3c on sl error: print exception inside for loop, and do not continue the loop 2013-11-14 09:23:38 +01:00
Emery Hemingway
8f87f7e954 IPv6 support 2013-11-13 14:46:36 -05:00
ThomasV
ee141f6d37 fix connect on windows 2013-11-11 16:59:36 +01:00
Bryan Stitt
225d8b83a3 don't use bare except 2013-11-09 21:23:57 -08:00
Bryan Stitt
f0eb0eccde replace BaseException with Exception 2013-11-09 20:21:02 -08:00
ThomasV
83e699c314 sanitize server in interface.py (fix bug #309) 2013-10-08 19:52:17 +02:00
ThomasV
d2af935fc7 use a regexp for the ssl bug workaround 2013-10-08 13:24:54 +02:00
ThomasV
f858f69c56 workaround android bug with ssl certificates 2013-10-08 13:08:13 +02:00
ThomasV
66f224eab4 update a few scripts 2013-10-06 12:28:45 +02:00
ThomasV
a6934f6796 support for all protocols 2013-10-05 11:16:09 +02:00
ThomasV
0b2c09d20b interface.debug flag 2013-10-04 16:00:20 +02:00
ThomasV
c18a49b8fe auto-cycle: switch to the longest chain 2013-10-03 14:56:48 +02:00
ThomasV
77dd1ae1b1 handle handshake failures in SSL 2013-10-03 10:27:39 +02:00
ThomasV
7a5016ec42 move synchronous_get to network.py, fix get_balance script 2013-10-03 10:05:01 +02:00
ThomasV
5086fd6b27 do not check certificate expiration if OpenSSL cannot be imported 2013-10-03 07:44:04 +02:00
ThomasV
40e393187a manage subscriptions in network.py 2013-10-02 13:00:02 +02:00
ThomasV
7a5b8a6202 fix 2013-10-02 10:43:02 +02:00
ThomasV
676350ba8a delete expired certificates 2013-10-02 10:36:29 +02:00
ThomasV
614254d037 scripts to check certificates 2013-10-02 10:21:25 +02:00
ThomasV
36b61fccfd temporary_path for unverified certificates 2013-10-02 09:22:13 +02:00
ThomasV
1bcb361fca fixes 2013-10-02 04:01:24 +02:00
ThomasV
f3763b45af fix 2013-10-02 03:33:45 +02:00
ThomasV
c097b9a530 delete only if cert is new 2013-10-02 03:24:14 +02:00
ThomasV
06cc898652 delete certificates that fail 2013-10-02 03:20:15 +02:00
ThomasV
27cc09e8e2 prevent dns leaks when using proxy. fixes issue #147 2013-10-01 11:24:55 +02:00
ThomasV
7658b2ade1 interface: call socket.connect before sll.wrap_socket, for proxy. (fixes bug #207) 2013-10-01 09:01:46 +02:00
thomasv
a6002cf71c SSL certificate validation 2013-09-30 14:01:49 +02:00
rofl0r
854802122c fix error to create a wallet due to missing pick_random_server decl 2013-09-18 16:55:19 +00:00
ThomasV
d51a8d0f25 create a class for transaction dialog 2013-09-14 21:07:54 +02:00
thomasv
6b6c508976 replace wallet.interface everywhere 2013-09-12 14:58:42 +02:00
ThomasV
907dca6eb9 simplify interface: use callbacks 2013-09-12 08:41:27 +02:00
thomasv
77871b97af fixes, resend_subscriptions 2013-09-10 19:59:58 +02:00
thomasv
2df129cfbf connect to random servers, reconnect if connection is lost 2013-09-10 17:52:43 +02:00
thomasv
0ec436c02c fix: network start was calling __init__ 2013-09-10 16:42:11 +02:00
thomasv
047e4b3478 move callbacks to the network class 2013-09-09 13:33:25 +02:00
ThomasV
328315f94b separate blockchain and network 2013-09-08 17:23:01 +02:00
ThomasV
803b292d9d socket: retry on EAGAIN 2013-09-02 21:16:57 +02:00
thomasv
2a6e8927dd select the longest blockchain from several servers 2013-09-02 17:49:12 +02:00
thomasv
9d1c31255c Merge branch '1.9' of git://github.com/spesmilo/electrum into 1.9 2013-09-02 11:16:35 +02:00
ThomasV
d99a381d83 separation between wallet storage and config 2013-09-01 15:26:52 +02:00
thomasv
1d26676ee9 parse_servers method 2013-08-14 16:16:03 +02:00
thomasv
a0b86f405d offline interface: fix init 2013-08-01 11:31:33 +02:00
Maran
06bfb60308 Reworked notification flow and combined multiple transactions into one notification 2013-07-16 12:15:23 +02:00
Maran
468c76b66e Added notifications when receiving a new transaction 2013-07-16 12:15:23 +02:00
Eagle[TM]
d24fefd459 update default server list, remove offline and pre v0.8 servers 2013-05-06 01:23:18 +02:00
ecdsa
86fd728a47 move network dialog in a new class; simplify interface.get_servers 2013-04-28 13:47:19 +02:00
ecdsa
827e29c1dc fix: print_log -> print_error 2013-04-27 10:57:15 +02:00
ecdsa
6069939003 handle errno 10035 2013-04-27 10:22:01 +02:00
ecdsa
7653408ff4 fix: socket error 2013-04-27 07:30:18 +02:00