ciniml / WireGuard-ESP32-Arduino

WireGuard implementation for ESP32 Arduino
Other
804 stars 64 forks source link

Trying to port in esp8266 handshake return -8 ERR_USE #16

Closed rjjrbatarao closed 2 years ago

rjjrbatarao commented 2 years ago

Hi thank you for this wonderful library it works perfectly in esp23 from arduino ide but not in esp8266, Maybe you can give me any insights about the error in the handshake where it returns err_t -8 ERR_USE or Address in use, I have managed to overcome this by using the original lwip-wireguard implementation ping works fine but when i try to curl to the esp8266 error comes out Failed to connect to 10.1.0.4 port 80: Connection timed out, the esp8266 seems to receive the packets i can see it on the serial monitor but failed to respond back, I thought this might be some issues of NAT I tried your implementation of ->underlying_netif adn udp_sendto_if but handshake fails saying -8 ERR_USE or Address in use. Thank you, My implementation is a fork of your library with minor changes hope I can make this work soon on esp8266. Here are some changes to make it compile in esp8266.

//in wireguardif.c wireguardif_init
#ifdef ESP8266
  underlying_netif = eagle_lwip_getif(STATION_IF);
#else
  tcpip_adapter_get_netif(TCPIP_ADAPTER_IF_STA, &underlying_netif);
#endif

Using hydrogen x22519.h to prevent crashing esp8266 and replacing it in crypto.h moving all crypto files to root removing all ESP_LOG or just doing #define ESP_LOGI(...) printf(VA_ARGS__) ESP_LOGV(...) printf(VA_ARGS__) etc uncommenting esp32 includes thats isnt compatible with esp8266

rjjrbatarao commented 2 years ago

I just switched to the original source code from smartalock as a base and used a esp8266/esp32 compatible x25519 .h of libhydrogen, with lots of debugging and reading tons of arduino core documentations i've finally got it to work as one library for esp8266 and esp32.