godprotocol 1.0.7 → 1.0.71
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.
- package/Accounts/cc4f237f478113591296e1c8a1fc5ccf987200c7baca12750a2cf67578e33c46/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
- package/Accounts/cc4f237f478113591296e1c8a1fc5ccf987200c7baca12750a2cf67578e33c46/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/50009ce1da4d15e1c4a04024df691eed5f0d598e2c4c67092f205366d0adf99e/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
- package/Accounts/cc4f237f478113591296e1c8a1fc5ccf987200c7baca12750a2cf67578e33c46/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/625da44e4eaf58d61cf048d168aa6f5e492dea166d8bb54ec06c30de07db57e1/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
- package/Accounts/cc4f237f478113591296e1c8a1fc5ccf987200c7baca12750a2cf67578e33c46/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
- package/Accounts/cc4f237f478113591296e1c8a1fc5ccf987200c7baca12750a2cf67578e33c46/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/74ccd43303847f2655300641a934959cdb11689ce171aa0f00faa92917fbd340/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
- package/Accounts/cc4f237f478113591296e1c8a1fc5ccf987200c7baca12750a2cf67578e33c46/fdc8c39bbfa6e5741f75f97112a2c972174ae63b5e0498f56f27b70d512ddd1e/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
- package/Index.js +1 -1
- package/package.json +1 -1
- package/utils/create_server.js +10 -2
- package/utils/functions.js +29 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
null
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
null
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
null
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
null
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
null
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
null
|
package/Index.js
CHANGED
package/package.json
CHANGED
package/utils/create_server.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import http from "http";
|
|
2
|
+
import { is_port_available } from "./functions";
|
|
2
3
|
|
|
3
4
|
let PORT = 1901,
|
|
4
5
|
domain;
|
|
@@ -9,8 +10,15 @@ const cb = (res, data) => {
|
|
|
9
10
|
res.end(data);
|
|
10
11
|
};
|
|
11
12
|
|
|
12
|
-
const create_server = (initiator, serve) => {
|
|
13
|
-
|
|
13
|
+
const create_server = async (initiator, serve) => {
|
|
14
|
+
if (!(serve && serve.port)) {
|
|
15
|
+
let av = await is_port_available(PORT);
|
|
16
|
+
|
|
17
|
+
while (!av) {
|
|
18
|
+
PORT++;
|
|
19
|
+
av = await is_port_available(PORT);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
14
22
|
|
|
15
23
|
let server = http.createServer((req, res) => {
|
|
16
24
|
let data = "";
|
package/utils/functions.js
CHANGED
|
@@ -39,4 +39,32 @@ const transpile_object = (object) => {
|
|
|
39
39
|
return code_string;
|
|
40
40
|
};
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
const net = require("net");
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Check if a port is available
|
|
46
|
+
* @param {number} port - The port to check
|
|
47
|
+
* @returns {Promise<boolean>} - Resolves to true if the port is available, false otherwise
|
|
48
|
+
*/
|
|
49
|
+
function is_port_available(port) {
|
|
50
|
+
return new Promise((resolve, reject) => {
|
|
51
|
+
const server = net.createServer();
|
|
52
|
+
|
|
53
|
+
server.once("error", (err) => {
|
|
54
|
+
if (err.code === "EADDRINUSE") {
|
|
55
|
+
resolve(false); // Port is in use
|
|
56
|
+
} else {
|
|
57
|
+
reject(err); // Some other error
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
server.once("listening", () => {
|
|
62
|
+
server.close();
|
|
63
|
+
resolve(true); // Port is available
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
server.listen(port);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export { array_to_nested_objects, transpile_object, is_port_available };
|