1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-21 10:26:06 +03:00

489 Commits

Author SHA1 Message Date
Alexander Emelianov
4bfa2ae889 TCP connect and send delay fix (#6213)
* TCP connect and send delay fix
Implement early exit as connection established or data already sent.
(Previous implementation was exiting only on timeout expired)
2019-07-05 12:11:40 +02:00
Earle F. Philhower, III
a0634a71a9
Fix mixup with boolean/bitwise or for BSSL probing (#6252)
Fix an error identified by -wextra where the size of the SSL extension
section in the probeMFLN call only.
2019-07-04 09:14:50 -07:00
dav1901
16312949c9 Add timeout to STA::waitForConnectResult (#5371) 2019-07-04 14:08:02 +02:00
Chris van Marle
6272b49406 Updater signature validation - format incompatible w/RFC8017 (#6250)
* Add hash OID to signature verification (#6201)

* Add legacy signing option

* Describe and use the legacy option of signing.py
2019-07-04 12:17:30 +02:00
Earle F. Philhower, III
7036297920 Convert ESP8266WebServer* into templatized model (#5982)
* Convert ESP8266WebServer* into templatized model

Supercedes #4912

Refactor the three versions of ESP8266WebServer and *WebServerSecure to a
single templated class. Use "using" to enable old, non-templated names to b
used (so no user changes required to compile or run).

Fixes #4908 and clean up the code base a lot.

Basic tests run (the ones in the example code).

No code changes are required in userland except for setting the SSL
certificates which now use a cleaner "getServer()" accessor and lets the
app use the native BearSSL calls on the WiFiClientSecure object.

@devyte should be proud, it removes virtuals and even has template specialization...

* Fix HTTPUpdate templates and examples

* Fix HTTPUpdateServer library build

Need to remove dot-a linkage since there are no .cpp files in the
directory anymore due to templates.

* Provide backward-compat names for updt template

Allow existing code to use the same well known names for
HTTPUpdateSecure.

* Remove ClientType from all templates, auto-infer

Remove the ClientType template parameter from all objects.  Simplifies
the code and makes it more foolproof.

Add a "using" in each server to define the type of connection returned
by all servers, which is then used in the above templates automatically.

* Can safely include FS.h now that SD/SPIFFS unified

* Move the templates/objects to their own namespaces

* Fix merge issues with untemplated methods

* Address review comments

* Fix mock test, remove warnings inside test dir

Make the simple mock test CI job pass and clean up
any spurious warnings in the test directory.

There still are warnings in the libraries and core, but they
should be addressed in a separate PR.
2019-07-04 10:58:22 +02:00
david gauchard
5306976db1
udp remote pbuf helper: honor fragmented packets (#6222)
fix for #5960 didn't take fragmented packets into account
fixes #6218
2019-06-26 21:35:43 +02:00
david gauchard
59db907647
lwip2: (re)fix setting static ip address (#6194) 2019-06-17 23:57:31 +02:00
Earle F. Philhower, III
9f03bbb8c3
Add an EC keyed certificat to BearSSL Server example (#6202)
Needed for future automated performance test suite use, to allow
selecting between EC and RSA signed keys for the server's cert.
2019-06-14 14:58:29 -07:00
Earle F. Philhower, III
fe01433f78
Obey the BASIC_SSL request for TLS servers (#6187)
When in basic SSL mode, don't include ciphers for EC for the server by
replacinf the BearSSL "support everything" init call with our own
version which obeys the requested BASIC_SSL.

Saves ~46KB on TLS servers, about the same as basic SSL saves for
clients.
2019-06-07 19:40:33 -07:00
Earle F. Philhower, III
8859b818d8
Make CertStore natively use File interface (#6131)
__This is a breaking change, but the header and example did warn
everyone that this API was in flux due to the incompatible SD and SPIFFS
File implementations.__

BearSSL CertStores now simply need a filesystem and the names of the
data (generated on-chip) and archive (uploaded by user) files on it.
No more need to roll your own virtual CertStoreFile class.

Update the library, examples, and device test.
2019-05-30 12:53:03 -07:00
s-hadinger
69311c8fe1 Added BR_OPT_NO_RENEGOTIATION flag to forbid TLS renegociation (#6165) 2019-05-30 06:43:45 -07:00
Jean Lescut-Muller
147b5fbb98 Typo fix in ESP8266WiFiAP.cpp (#6134) 2019-05-23 07:55:46 -07:00
Dave
912c0db091 Remove deadlock when server is not acking our data (#6107)
* Use bounded waiting instead of infinite one to avoid deadlock

* Reduce timeout to fail much sooner if server is not acking our data

* Return timeout to 15 seconds on every disconnect

* Add comment to introduced delay to make it super clear
2019-05-19 22:38:24 +02:00
Dave
25c95ac185 Bugfix for stuck in write method of WiFiClient and WiFiClientSecure until the remote peer closed connection (#6104)
* Bugfix - write method of WiFiClient and WiFiClientSecure can stuck forever

* Adjustment of uint8_t to bool to have it clear flag
2019-05-17 00:00:12 +02:00
Dave
75f01dc35a Drop X509 after connection, avoid hang on TLS broken (#6065)
* Drop X509 context after successful server verification to save heap space

After completing handshake in BSSL, server is already verified and X509 context is no longer needed. Depending on verification method it save more or less heap space.

* Bugfix: Report not connected if there is no ready data and TLS connection is broken

Added the change for reporting not connected if TLS session is broken and there is no more buffered decrypted data. TLS can be broken if message authentication (MAC) cannot be verified. BearSSL enters BR_SSL_CLOSED state when processing invalid encrypted application data fragment. In such situation the current implementation get stuck forever unless user has own timeout mechanism build on top of WiFiClientSecureBearSSL. This change introduce fail fast via connected() returning false. Further it imply return -1 from read methods indicating broken channel upon which user should perform reconnect if needed.

Fixes #6005
2019-05-15 09:55:06 -07:00
Allman-astyler
eea9999dc5 Revert "Allman now (#6080)" (#6090)
This reverts commit 98125f88605cd7e46e9be4e1b3ad0600dd5d2b51.
2019-05-14 00:09:54 +02:00
Allman-astyler
98125f8860 Allman now (#6080)
* switch restyle script for CI

* remove confirmation

* restyle with allman
2019-05-13 16:41:34 +02:00
david gauchard
e071033c3c
minor fix for host emulation (#6046) 2019-05-04 10:32:12 +02:00
david gauchard
1750022601
fix switching to static address with lwip2 (#6026)
fix switching to static address with lwip2

For some reason, ip address is not propagated in a visible way for lwip2
when switching to static address (wifi.config()) *after* wifi.begin().

This patch calls lwip-v1.4's netif_set_addr() with the new ip address to set
all things up, just like it is done and right when wifi.begin() is called
after wifi.config().

Also tested when IPv6 is enabled.

fix documentation: It is more natural to set an IP address before starting WiFi
(.. and not after dhcp has started)
fixes #5839
fixes #6024
2019-05-01 12:35:03 +02:00
david gauchard
cdb549572d
restore proper arduino Client:: & Wire:: API (#5969) 2019-04-26 22:05:46 +02:00
david gauchard
5dd780c571
udp: restore correct address/port when parsing packet (#6011)
do interleave informations on addresses within reception pbuf chain:
before: (data-pbuf) -> (data-pbuf) -> (data-pbuf) -> ... in the receiving order
now: (address+port-info-pbuf -> data-pbuf) -> (address_port-info-pbuf -> data-pbuf) -> ...

address/port informations are updated along with data exposed to user
2019-04-26 20:09:23 +02:00
Earle F. Philhower, III
f6dd826437
Fix MFLN probe and allow returning whether MFLN succeeded or not after a connection. (#6000)
Fixes #5996

* Add extensions to probe message for EC, others

probeMFLN was failing on some connection attempts to servers which only
supported EC based ciphers because it did not include the proper TLS
handshake extensions to list what kinds of ECs it supported.

Add those to the probeMFLN ClientHello message to make probes pass.

* Add client.getMFLNStatus method, returns MFLN state

After a connection it is useful to check whether MFLN negotiation
succeeded.  getMFLNStatus returns a bool (valid only after
client.connect() succeeds, of course) indicating whether the requested
buffer sizes were negotiated successfully.
2019-04-25 12:40:26 -07:00
Earle F. Philhower, III
d9b0480f09
New menu option to minimize BSSL ROM with only RSA (#6006)
* New menu option to minimize BSSL ROM with only RSA

Adds a menu option and define to limit BearSSL to older RSA connection
options.  This saves ~45K program memory and can speed up connections
since EC, while more secure, is significantly slower on the chip.
The supported ciphers are identical to the ones that axTLS supported.

Fixes #6005

* Add default SSLFLAGS(blank) to platform.txt

* Fix unused variable warning

* Add clarifying comment to menu items
2019-04-25 11:13:26 -07:00
Jeroen88
667816ebe0 BearSSL Max Fragment Length Negotation and Node.js server (#5929)
* Minor bug fixes in Maximum Fragment Length Negotation example, mainly giving background processes some time in fetch()

* Minor layout changes to pass travis tests

* Use PolledTimeout for timeout
2019-04-11 14:21:04 +02:00
david gauchard
9a2ed274f3 polledTimeout: add option to use CPU count instead of millis() (#5870)
* polledTimeout: add option to use CPU count instead of millis()

* use more "using" alias

* more c++/clear code, using typename (thanks @devyte)

* rename class name to include unit, introduce timeMax() and check it with assert()

* remove useless defines

* improve api readability, add micro-second unit

* update example

* mock: emulate getCycleCount, add/fix polledTimeout CI test

* + nano-seconds, assert -> message, comments, host test

* allow 0 for timeout (enables immediate timeout, fix division by 0)

* typo, set member instead of local variable

* unify error message

* slight change on checkExpired() allows "never expired"
also removed printed message, add YieldAndDelay, simplify calculations

* remove traces of debug.h/cpp in this PR

* include missing <limits> header

* back to original expired test, introduce boolean _neverExpires, fix reset(), getTimeout() is invalid

* fix expiredOneShot with _timeout==0 check

* reenable getTimeout()

* expose checkExpired with unit conversion

* fix timing comments, move critical code to iram

* add member ::neverExpires and use it where relevant

* improve clarity

* remove exposed checkExpired(), adapt LEAmDNS with equivalent

* add API ::resetToNeverExpires(), use it in LEAmDNS

* remove offending constness from ::flagged() LEAmDNS (due do API fix in PolledTimeout)

* simplify "Fast" base classes

* minor variable rename

* Fix examples

* compliance with good c++ manners

* minor changes for consistency

* add missing const

* expired() and bool() moved to iram

* constexpr compensation computing

* add/update comments

* move neverExpires and alwaysExpired
2019-04-05 10:50:53 -03:00
david gauchard
f0eb5509a0
use static_assert to check on fw structure changes over updates (fix) (#5946) 2019-04-03 23:17:09 +02:00
david gauchard
ca79f2ce39
use static_assert to check on fw structure changes over updates (#5939) 2019-04-02 00:44:27 +02:00
Evgeny Dontsov
68c0a1cc9e sta_config_equal (#5937)
* sta_config_equal

* sta_config_equal bug update
2019-04-01 15:38:09 -03:00
david gauchard
2e75e88c49
bugfix: restore WiFi::setSleepMode functionality with sdk-2.2.x (#5919) 2019-03-26 14:07:49 +01:00
Jiri Bilek
64e30b270b Fix the changed structure of the input file (#5891)
The input file containing certificates has changed.
2019-03-18 15:15:59 -07:00
Earle F. Philhower, III
68bcc41429 Fix SSID reporting for 32-char SSIDs (#5889)
Fixes 5853
2019-03-17 23:06:41 -03:00
david gauchard
a3ea816e65
add optional espressif fw nonos-sdk 2.2.x (19.03.13) (#5873) 2019-03-14 13:35:26 +01:00
david gauchard
e5b4de3633
fix DEBUG macros (#5728)
* fix DEBUG macros

All fmt strings in flash
fix #5658

This also allows to avoid warnings and easy mistakes with (no brace):
    if (something)
        DEBUGV("blah");

* use newlib unaligned-compatible printf for DEBUGV

* remove useless putprintf since ::printf already uses ets_putc
2019-03-14 11:19:21 +01:00
Thomas Friedrichsmeier
071eeb8b67 Allow to disable DHCP gateway offer when set up of AP. (#4421) 2019-03-13 00:28:41 +01:00
Earle F. Philhower, III
95cf925719
Add OOM check and debug message in CertStore (#5820)
Fixes #5819
2019-02-26 02:46:25 +00:00
david gauchard
7745e99046
Revert to nonos-sdk 2.2.1, new sdk-switching option in IDE menu for generic board only (#5763)
This commit allows switching SDK firmware:

nonos-sdk-pre-v3 shipped with release 2.5.0 has issues:

    * Some boards show erratic behavior (radio connection is quickly lost), with an unknown cause.
      These boards work well with previous nonos-sdk-2.2.1 firmware (#5736)

    * Overall performances seem to have decreased (#5513)

This PR restores sdk2.2.1 (as in core-2.4.2).

SDK-pre-3.0 - which has brought long awaited fixes (WiFi sleep modes) - is still available through a menu option available only with generic board.

BREAKING

    * new define `-DNONOSDK221=1` or `-DNONOSDK3V0=1`

    * for external build systems: new library directory: `tools/sdk/lib/<version>/lib`

    * PIO: variable `PIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK3` is needed for sdk-pre-v3.


Fix #5736
2019-02-19 13:10:49 +01:00
david gauchard
6c5269a74b
fix UdpContext::(connect,listen) signature by using IPAddress (#5742)
* fix UdpContext::listen signature by using IPAddress
* fix UdpContext::connect signature by using IPAddress
  by courtesy of @AlfredLamoule
2019-02-11 13:46:40 +01:00
david gauchard
1959311180
UdpContext::setMulticastInterface(): fix for IPv6 (#5743)
Per 'udp_set_multicast_netif_addr()' signature and comments in lwIP sources:
An IPv4 address designating a specific interface must be used.
When an IPv6 address is given, the matching IPv4 in the same interface must be selected.

fix e3bc3c226b (r32235572)
2019-02-08 15:23:08 +01:00
Earle F. Philhower, III
d2a8e8acc2
Add debug messages on BSSL errors (#5723)
Add debugging output when DEBUG_ESP_SSL is defined.
Add dump of actual error when connect fails
2019-02-07 05:18:31 +00:00
Earle F. Philhower, III
56268b166d
Fix memory related issues w/BearSSL server/client (#5706)
Because the constructors of the BSSL client and server add a reference
count to the stack_thunk, if there is no copy constructor defined then
the stack thunk reference count can get out of sync causing the stack
thunk memory to be freed while still in use.  That could cause random
crashes or hangs.

Add a very basic copy constructor to the WiFiClientSecure and
WiFiServerSecure objects, using the default operator= to duplicate
simple types and shared_ptr classes.

The _cipher_list element (used only w/custom ciphers) could be freed
while still in use if copies of the WiFiClientSecure object were made.

Use a shared_ptr which will only free when the last reference is
deleted.

The axTLS compatibility mode calls allocate and store elements needed
for SSL connections (unlike normal BearSSL calls).  These elements could
be freed mistakenly while still in use if copies of the WiFiClientSecure
were made by the app.

Convert to a separately managed shared_ptr to ensure they live as long
as any referencing objects before deletion.

Same done for the axTLS compatability for WiFiServerSecure.
2019-02-02 18:09:19 +00:00
david gauchard
1cacf92ce1 stop lwIP dhcp client when WiFi goes off. (#5703)
* stop lwIP dhcp client with WiFi goes off.

* stop dhcp-client when really unused
2019-02-01 14:33:26 -03:00
Earle F. Philhower, III
3f8cd46dc2
Fix BearSSL Server WDT (#5702)
Fixes #5701 WDTs and other issues with BearSSL::WiFiServerSecure

The BSSL server was creating the client it returns on a connection in a
way that caused the counter for the stack_thunk to get out of sync and
cause it to be freed improperly by having the destructor be called one
more time than the constructor.  Looks like RVO.

Rewrite the ::available() function in order to avoid this issue with
help from @devyte.
2019-02-01 06:47:42 +00:00
david gauchard
f42bfdfc0d
adaptations for lwIP-v1.4 (#5682)
* adaptations for lwIP-v1.4
* add lwIP-v1.4 in CI
2019-01-28 22:31:59 +01:00
SmartBlug
5e4c2e9750 Add capability to have light static DHCP lease (#5594)
* Add capability to have light static DHCP lease

* added ESP8266WiFi StaticLease sample

* Update StaticLease to IPv4
2019-01-25 02:25:04 +00:00
david gauchard
7c5be91430 dynamic WiFi.hostname("newname") (#5652)
* dynamic WiFi.hostname("newname")

* WiFi.hostname() back to String return type

* no silent hostname fix but proceed with debug message and returning false
2019-01-24 17:13:20 -03:00
liebman
049a9eaa5b decorate as override virtual methods in WiFiUDP (#5637)
make WiFiUDP destructor virtual
add empty virtual destructor to Udp
2019-01-20 00:34:21 +01:00
david gauchard
b666435282 WiFiClient::remoteIP: fix nullptr crash (#5634) 2019-01-18 22:08:32 -03:00
david gauchard
cac22e3576
fix dhcp6 in upstream lwIP (#5560) 2018-12-27 19:29:04 +01:00
david gauchard
e3bc3c226b
Fixes for IPv6, added in CI (#5557) 2018-12-27 16:13:48 +01:00
david gauchard
da7ffdaa28
add 1 more IPAddress constructor for IPv6 (#5551) 2018-12-26 15:01:48 +01:00