Commit Graph

51 Commits

Author SHA1 Message Date
Colin Kuebler
ce709f56ba Fix encoding issues 2020-01-24 18:44:16 -05:00
Colin Kuebler
769acc617f Replaced pycrypto with pycryptodomex 2019-12-31 18:55:10 -05:00
Colin Kuebler
70448fec6c Fix accidental file mode change 2019-11-24 15:34:32 -05:00
Colin Kuebler
46cb505bfc Change spaces used for indentation into tabs 2019-11-23 17:45:50 -05:00
Colin Kuebler
3cef06065f Merge remote-tracking branch 'upstream/master' into development 2019-11-18 21:57:18 -05:00
Christian Clauss
8d679574b3 Use ==/!= to compare str, bytes, and int literals
Identity is not the same thing as equality in Python so use ==/!= to compare str, bytes, and int literals. In Python >= 3.8, these instances will raise SyntaxWarnings so it is best to fix them now.  https://docs.python.org/3.8/whatsnew/3.8.html#porting-to-python-3-8
2019-11-18 14:41:07 +01:00
Colin Kuebler
f2499d24f4 Encode all str keys passed to Crypto #332 2019-11-15 10:13:13 -05:00
Colin Kuebler
4aa350c149 Modify extended schema to cover more cases, fix #354 #363 #369 #372 2019-11-07 10:37:51 -05:00
Colin Kuebler
c3952af957 Encode AES key
Closes #332
2019-10-23 23:31:58 -04:00
Colin Kuebler
ec43e49d16 Replace hardcoded gateway with supplied argument 2019-10-09 23:09:47 -04:00
Colin Kuebler
da75a2f6b0 Merge branch 'simple-dict' into development 2019-10-05 18:47:13 -04:00
Colin Kuebler
8b799fe05f Merge branch 'fix-net-inf' into development 2019-10-05 18:46:12 -04:00
Colin Kuebler
d9a29ca421 Merge branch 'improve-flow' into development 2019-10-05 18:44:04 -04:00
Colin Kuebler
2fe5cd4fcd A simple dictionary to track activated ids, instead of a boilerplate class 2019-10-05 17:47:51 -04:00
Colin Kuebler
38d1981a9e Let the user know when they are connected, rather than hello world 2019-10-04 14:33:11 -04:00
Colin Kuebler
0578b32ab5 Enable captive portal detection by responding to unknown requests with 302 (temporary redirect)
This should fix mobile devices that disconnect when there is no internet access
2019-10-04 14:29:17 -04:00
Colin Kuebler
155dfdaceb Merge branch 'master' into fix-net-inf 2019-10-03 22:10:30 -04:00
Colin Kuebler
1762c6a66e Fix schema generation using a global object as an in memory db 2019-10-03 21:16:20 -04:00
Colin Kuebler
8d3de795e5 Merge branch 'master' into fix-net-inf 2019-10-03 14:24:12 -04:00
Colin Kuebler
0b48ababcb Merge branch 'master' into improve-flow 2019-10-03 13:03:09 -04:00
Colin Kuebler
0c3e2d8a4d Use pkill to find and cancel smartconfig process, both in start_flash and after receiving registration call 2019-10-02 15:22:57 -04:00
Colin Kuebler
966d6ab34c Call super 2019-10-01 23:09:53 -04:00
Colin Kuebler
84731def1e Keep track of activation attempts per device to dynamically alter behavior
Try extended schema first, then minimal schema
2019-10-01 22:56:07 -04:00
Colin Kuebler
84f9a59023 Remove trigger_upgrade and run mq_pub_15 directly from fake-registration-server 2019-09-29 16:53:28 -04:00
Colin Kuebler
b427d48741 Typo 2019-09-28 17:24:05 -04:00
Colin Kuebler
5de40b0a70 Warn users if their Tuya device is not ESP based 2019-09-28 17:22:09 -04:00
Colin Kuebler
cba1111814 Simplify schema expression 2019-09-26 14:43:32 -04:00
Colin Kuebler
bb39283d95 Do not imply that payload decryption failure is an issue, it is expected for .active endpoints 2019-09-25 16:56:44 -04:00
Colin Kuebler
ec453412de Activation workaround by extending dummy schema - some devices crash if schema is shorter than expected
Added missing URLs in activation response
Readded .updatestatus to avoid .upgrade from catching this endpoint
Verify payload decryption is JSON
2019-09-25 10:25:40 -04:00
Colin Kuebler
c0e57847a9 Fix variable rename missed 2019-09-23 16:39:31 -04:00
Colin Kuebler
5df7637452 Combined reply_encrypted in reply with encrypted flag
Tidying up by removing some redundant endpoints and adding comments
Now all but the activation endpoints use encryption when requested
2019-09-23 00:01:31 -04:00
Colin Kuebler
2a83af3d29 Set defaults for query params to prevent exceptions when missing 2019-09-22 18:50:24 -04:00
Colin Kuebler
a88db23ee4 Reorganized imports and made secKey configurable via command line option 2019-09-22 18:49:43 -04:00
Colin Kuebler
2104d47be5 Redirect GET requests to our POST handler 2019-09-22 18:29:02 -04:00
Colin Kuebler
da42236a1d Implemented encrypted response support
Removed additional config.get payload, does not appear to be necessary and in some cases was causing problems
Revert upgrade type to 0 since we are trying to update the firmware on the main ESP82xx, not an external MCU
2019-09-22 18:25:30 -04:00
Colin Kuebler
27f1a33605 Enhance logging
Print request details, method, headers, and decrypted payload
Print response payload
2019-09-22 18:19:04 -04:00
Colin Kuebler
769901a673 Added endpoint for /d.json based on reports in #273 2019-09-21 18:32:47 -04:00
Colin Kuebler
5fe523aafe Merge branch 'master' into new-api
Attempted to integrate new API responses with old ones, based on et=1 param
**Untested**
2019-09-21 18:27:31 -04:00
Colin Kuebler
5114b1ef7d Merge branch 'master' into fix-net-inf 2019-09-21 17:28:55 -04:00
Madmartigan
ea815b7d62 fix: gwId was not parsed 2019-09-19 08:33:28 +02:00
Madmartigan
7d588cda4e Circumvent new tuya sdk protection 2019-09-18 21:38:11 +02:00
Colin Kuebler
22bdbb5629 Exit server cleanly on SIGINT (^C) to reduce error message noise 2019-07-04 19:54:12 -04:00
Colin Kuebler
da1966ac42 Bugfixes; file_md5 was type bytes vs str, reply() needed argument default, use get_argument() instead of request.arguments[], json to str lambda to ease schema encoding, true => True in python 2019-07-03 14:02:33 -04:00
Colin Kuebler
39954071bd Added API response for s.gw.upgrade.updatestatus 2019-07-02 15:23:23 -04:00
Colin Kuebler
39b9bcd768 Added API methods: .device.upgrade .timer and .config
tuya.device.upgrade.get and tuya.device.upgrade.silent.get should allow upgrades on devices where s.gw.upgrade is not called
2019-07-02 14:48:36 -04:00
Colin Kuebler
beab732cfe Implemented JSONHandler.reply to reduce code repetition
Adds timestamp, serializes response, and applies appropriate headers
Fetch gwId and a from query parameters instead of manual uri parsing
Represent API responses as dict objects for clarity and flexibility
Compute upgrade.bin md5 and file size only once when the server is started
2019-07-02 14:43:24 -04:00
Colin Kuebler
fcbb35019b Added option for specifying the server bind addr, defaulting to 10.42.42.1
Catch bind error and produce a helpful message if port is unavailable
This should make it possible to run the server without interfering with 0.0.0.0:80
2019-07-02 14:00:18 -04:00
Colin Kuebler
780e62d99f Updated references to upgrade.bin
Simplify schema to lowest common denominator
2019-03-22 17:32:08 -04:00
ms_vtrust
927e5c448a Update fake-registration-server.py 2019-01-22 16:05:54 +01:00
Merlin Schumacher
080a4cb574 Unify python3 usage 2019-01-21 16:42:10 +00:00