| 23 | static const unsigned long RELAY_POLL_MS = 10; |
| 24 | |
| 25 | static void relayLoop(WiFiClient &client, WiFiClient &target) { |
| 26 | uint8_t buf[RELAY_BUF_SIZE]; |
| 27 | while (client.connected() && target.connected()) { |
| 28 | if (check(EscPress)) break; |
| 29 | int n = 0; |
| 30 | if (client.available()) { |
| 31 | n = client.read(buf, sizeof(buf)); |
| 32 | if (n > 0) target.write(buf, (size_t)n); |
| 33 | } |
| 34 | if (target.available()) { |
| 35 | n = target.read(buf, sizeof(buf)); |
| 36 | if (n > 0) client.write(buf, (size_t)n); |
| 37 | } |
| 38 | if (n <= 0) delay(RELAY_POLL_MS); |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | static bool readSocks4Request( |
| 43 | WiFiClient &client, uint8_t &cd, uint16_t &dstPort, uint8_t dstIp[4], char *hostname, size_t hostnameSize |