@@ -35,6 +35,7 @@ WiFiServer *server_tcp = nullptr;
35
35
WiFiClient client_tcp[TCP_BRIDGE_CONNECTIONS];
36
36
uint8_t client_next = 0 ;
37
37
uint8_t *tcp_buf = nullptr ; // data transfer buffer
38
+ bool ip_filter_enabled = false ;
38
39
IPAddress ip_filter;
39
40
40
41
#include < TasmotaSerial.h>
@@ -65,7 +66,7 @@ void TCPLoop(void)
65
66
66
67
AddLog (LOG_LEVEL_INFO, PSTR (D_LOG_TCP " Got connection from %s" ), new_client.remoteIP ().toString ().c_str ());
67
68
// Check for IP filtering if it's enabled.
68
- if (ip_filter ) {
69
+ if (ip_filter_enabled ) {
69
70
if (ip_filter != new_client.remoteIP ()) {
70
71
AddLog (LOG_LEVEL_INFO, PSTR (D_LOG_TCP " Rejected due to filtering" ));
71
72
new_client.stop ();
@@ -173,9 +174,10 @@ void CmndTCPStart(void) {
173
174
if (ArgC () == 2 ) {
174
175
char sub_string[XdrvMailbox.data_len ];
175
176
ip_filter.fromString (ArgV (sub_string, 2 ));
177
+ ip_filter_enabled = true ;
176
178
} else {
177
179
// Disable whitelist if previously set
178
- ip_filter = ( uint32_t ) 0 ;
180
+ ip_filter_enabled = false ;
179
181
}
180
182
181
183
if (server_tcp) {
@@ -191,7 +193,7 @@ void CmndTCPStart(void) {
191
193
}
192
194
if (tcp_port > 0 ) {
193
195
AddLog (LOG_LEVEL_INFO, PSTR (D_LOG_TCP " Starting TCP server on port %d" ), tcp_port);
194
- if (ip_filter ) {
196
+ if (ip_filter_enabled ) {
195
197
AddLog (LOG_LEVEL_INFO, PSTR (D_LOG_TCP " Filtering %s" ), ip_filter.toString ().c_str ());
196
198
}
197
199
server_tcp = new WiFiServer (tcp_port);
0 commit comments