@cappitolian/http-local-server-swifter 0.0.30 → 0.0.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -13,17 +13,15 @@ import com.getcapacitor.JSObject;
|
|
|
13
13
|
import com.getcapacitor.Plugin;
|
|
14
14
|
import com.getcapacitor.PluginCall;
|
|
15
15
|
|
|
16
|
-
import org.json.JSONException;
|
|
17
16
|
import org.json.JSONObject;
|
|
18
17
|
|
|
19
18
|
import java.io.IOException;
|
|
20
|
-
import java.util.HashMap
|
|
19
|
+
import java.util.HashMap;
|
|
21
20
|
import java.util.Map;
|
|
22
21
|
import java.util.UUID;
|
|
23
22
|
import java.util.concurrent.CompletableFuture;
|
|
24
23
|
import java.util.concurrent.ConcurrentHashMap;
|
|
25
24
|
import java.util.concurrent.TimeUnit;
|
|
26
|
-
import java.util.concurrent.TimeoutException;
|
|
27
25
|
|
|
28
26
|
import fi.iki.elonen.NanoHTTPD;
|
|
29
27
|
|
|
@@ -40,7 +38,7 @@ public class HttpLocalServerSwifter {
|
|
|
40
38
|
private static final int RATE_LIMIT = 30; // requests
|
|
41
39
|
private static final long RATE_WINDOW_MS = 60_000; // per minute
|
|
42
40
|
|
|
43
|
-
|
|
41
|
+
// Private final properties
|
|
44
42
|
private final Plugin plugin;
|
|
45
43
|
private final int port;
|
|
46
44
|
private final int timeoutSeconds;
|
|
@@ -48,7 +46,7 @@ public class HttpLocalServerSwifter {
|
|
|
48
46
|
// Private properties
|
|
49
47
|
private LocalNanoServer server;
|
|
50
48
|
|
|
51
|
-
private boolean isRateLimited(String ip) {
|
|
49
|
+
private static boolean isRateLimited(String ip) {
|
|
52
50
|
long now = System.currentTimeMillis();
|
|
53
51
|
|
|
54
52
|
rateLimitMap.compute(ip, (key, timestamps) -> {
|
|
@@ -101,7 +99,7 @@ public class HttpLocalServerSwifter {
|
|
|
101
99
|
Log.i(TAG, "Server started at " + localIp + ":" + port);
|
|
102
100
|
} catch (IOException e) {
|
|
103
101
|
Log.e(TAG, "Failed to start server", e);
|
|
104
|
-
|
|
102
|
+
|
|
105
103
|
call.reject("Failed to start server: " + e.getMessage());
|
|
106
104
|
}
|
|
107
105
|
}
|
|
@@ -289,7 +287,7 @@ public class HttpLocalServerSwifter {
|
|
|
289
287
|
Response response = newFixedLengthResponse(Response.Status.NO_CONTENT, "text/plain", "");
|
|
290
288
|
|
|
291
289
|
addCorsHeaders(response);
|
|
292
|
-
|
|
290
|
+
|
|
293
291
|
return response;
|
|
294
292
|
}
|
|
295
293
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cappitolian/http-local-server-swifter",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.31",
|
|
4
4
|
"description": "Runs a local HTTP server on your device, accessible over LAN. Supports connect, disconnect, GET, and POST methods with IP and port discovery.",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|