Comparing version 2.1.1 to 2.1.2
80
index.js
const http = require('http'); | ||
const mdns = require('./src/mdns'); | ||
const bonjour = require('./src/bonjour'); | ||
// Server component | ||
const server = http.createServer((req, res) => { | ||
res.statusCode = 200; | ||
res.setHeader('Content-Type', 'text/plain'); | ||
res.end('A netGet server!'); | ||
res.statusCode = 404; | ||
res.end('Not found'); | ||
}); | ||
// Client component | ||
const connect = (host, port) => { | ||
const options = { | ||
hostname: host, | ||
port: port, | ||
path: '/', | ||
method: 'GET', | ||
}; | ||
const req = http.request(options, (res) => { | ||
let data = ''; | ||
res.on('data', (chunk) => { | ||
data += chunk; | ||
}); | ||
res.on('end', () => { | ||
console.log('Response from netget server:', data); | ||
}); | ||
// Listen on a specific port | ||
const listen = (port) => { | ||
server.listen(port, () => { | ||
console.log(`netget server is listening on port: ${port}`); | ||
}); | ||
req.on('error', (error) => { | ||
console.error('Error connecting to netget server:', error); | ||
}; | ||
// Close the server | ||
const close = () => { | ||
server.close(() => { | ||
console.log('netget server has been closed'); | ||
}); | ||
}; | ||
req.end(); | ||
// Methods: | ||
// Define mdns method | ||
const mdnsMethod = () => { | ||
console.log('mdns method called'); | ||
// Implement the logic for mdns discovery here | ||
}; | ||
const path = require('path'); | ||
const packageJson = require(path.join(__dirname, './package.json')); | ||
// Define bonjour method | ||
const bonjourMethod = () => { | ||
console.log('bonjour method called'); | ||
// Implement the logic for bonjour discovery here | ||
}; | ||
module.exports = { | ||
/*the listen method checks if the port parameter is provided. | ||
If it is, it uses that value. Otherwise, it checks if process.env.PORT is available. | ||
If both are not available, it defaults to port 31415.*/ | ||
listen: (port) => { | ||
const resolvedPort = port || process.env.PORT || 31415; | ||
server.listen(resolvedPort, () => { | ||
console.log("netget server is listening on port: " + resolvedPort); | ||
}); | ||
}, | ||
close: () => { | ||
if (server) { | ||
server.close(() => { | ||
console.log('netget server has been closed'); | ||
}); | ||
} | ||
}, | ||
connect: (host, port) => { | ||
connect(host, port); | ||
}, | ||
version: { | ||
netGet: packageJson.version | ||
} | ||
listen, | ||
close, | ||
mdns: mdnsMethod, | ||
bonjour: bonjourMethod | ||
}; | ||
console.log("indexing netget..."); |
{ | ||
"name": "netget", | ||
"version": "2.1.1", | ||
"version": "2.1.2", | ||
"description": "Rette Adepto/ Recibido Directamente.", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"keywords": [ | ||
"netget" | ||
"netget" | ||
], | ||
@@ -15,13 +15,13 @@ "author": "Sui Gn", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/suiGn/netget" | ||
"type": "git", | ||
"url": "https://github.com/suiGn/netget" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/suiGn/netget/issues" | ||
"url": "https://github.com/suiGn/netget/issues" | ||
}, | ||
"homepage": "https://github.com/suiGn/netget#readme", | ||
"dependencies": { | ||
"bonjour": "^3.5.0", | ||
"mdns": "^2.7.2" | ||
} | ||
} | ||
} |
@@ -10,2 +10,3 @@ # netGet | ||
You can use this netget module in your project by requiring it and calling the exported functions as needed. | ||
Note: This is a basic example and can be further expanded and enhanced based on your specific requirements. | ||
@@ -43,54 +44,2 @@ | ||
By following these steps, you should be able to access the functionalities of the netget module and test that it is loaded correctly in your project. | ||
# Why netget: | ||
- Peer-to-peer communication: Netget can provide a built-in mechanism for nodes to discover and connect with each other in a peer-to-peer network. It can facilitate direct communication between nodes without relying on a centralized server. | ||
- HTTPS and WS support: Netget can handle both HTTPS and WebSocket protocols, allowing nodes to establish secure connections and exchange data in real-time. | ||
- Routing and message passing: Netget can include routing capabilities to route incoming messages to the appropriate nodes based on predefined rules or patterns. It can provide an API for defining routes and handling different types of requests. | ||
- Middleware support: Netget can support middleware functions that can intercept and process incoming and outgoing messages. Middleware functions can perform tasks such as authentication, data transformation, logging, or error handling. | ||
- Event-driven architecture: Netget can be designed with an event-driven architecture, where nodes can subscribe to and emit events. This enables real-time communication and the ability to react to events triggered by other nodes. | ||
- Customizable and extensible: Netget can provide a modular and extensible architecture that allows developers to customize and extend its functionality. It can support plugins or extensions for additional features or integration with other frameworks or services. | ||
- Security and encryption: Netget can prioritize security by providing mechanisms for encrypting communication channels, implementing access control, and handling secure authentication between nodes. | ||
# Features: | ||
Peer-to-peer communication: | ||
Implement a discovery mechanism for nodes to find and connect with each other in a decentralized manner. | ||
Establish direct communication channels between nodes using protocols like WebRTC. | ||
HTTPS and WS support: | ||
Enhance the server component to handle both HTTPS and WebSocket connections. | ||
Implement secure connections using SSL/TLS certificates for HTTPS communication. | ||
Support WebSocket connections for real-time bidirectional communication. | ||
Routing and message passing: | ||
Develop a routing system that can handle incoming requests and messages and route them to the appropriate nodes or handlers based on defined routes or patterns. | ||
Allow developers to define routes and associated callback functions for handling different types of requests. | ||
Middleware support: | ||
Introduce a middleware mechanism to intercept incoming and outgoing messages. | ||
Enable developers to define middleware functions that can perform tasks such as authentication, data transformation, logging, or error handling. | ||
Middleware functions should be able to modify or enrich the messages before passing them along the routing pipeline. | ||
Event-driven architecture: | ||
Implement an event system where nodes can subscribe to and emit events. | ||
Enable real-time communication by triggering events and notifying subscribed nodes. | ||
Provide mechanisms for event filtering and event-based interactions between nodes. | ||
Customizable and extensible: | ||
Design Netget with a modular architecture that allows developers to customize and extend its functionality. | ||
Support plugin or extension system to integrate additional features or third-party services. | ||
Provide clear APIs and guidelines for developing and integrating custom components. | ||
Security and encryption: | ||
Implement encryption mechanisms for secure communication channels, such as SSL/TLS for HTTPS connections and WebSocket Secure (WSS) for secure WebSocket connections. | ||
Integrate authentication mechanisms to ensure secure node-to-node communication. | ||
Implement access control mechanisms to enforce authorization rules and protect sensitive resources. | ||
By following these steps, you should be able to access the functionalities of the netget module and test that it is loaded correctly in your project. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
7
100
0
5493
2
43
+ Addedbonjour@^3.5.0
+ Addedmdns@^2.7.2
+ Addedarray-flatten@2.1.2(transitive)
+ Addedbindings@1.2.1(transitive)
+ Addedbonjour@3.5.0(transitive)
+ Addedbuffer-indexof@1.1.1(transitive)
+ Addedcall-bind@1.0.7(transitive)
+ Addeddeep-equal@1.1.2(transitive)
+ Addeddefine-data-property@1.1.4(transitive)
+ Addeddefine-properties@1.2.1(transitive)
+ Addeddns-equal@1.0.0(transitive)
+ Addeddns-packet@1.3.4(transitive)
+ Addeddns-txt@2.0.2(transitive)
+ Addedes-define-property@1.0.0(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedfunctions-have-names@1.2.3(transitive)
+ Addedget-intrinsic@1.2.4(transitive)
+ Addedgopd@1.0.1(transitive)
+ Addedhas-property-descriptors@1.0.2(transitive)
+ Addedhas-proto@1.0.3(transitive)
+ Addedhas-symbols@1.0.3(transitive)
+ Addedhas-tostringtag@1.0.2(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedip@1.1.9(transitive)
+ Addedis-arguments@1.1.1(transitive)
+ Addedis-date-object@1.0.5(transitive)
+ Addedis-regex@1.1.4(transitive)
+ Addedmdns@2.7.2(transitive)
+ Addedmulticast-dns@6.2.3(transitive)
+ Addedmulticast-dns-service-types@1.1.0(transitive)
+ Addednan@2.22.0(transitive)
+ Addedobject-is@1.1.6(transitive)
+ Addedobject-keys@1.1.1(transitive)
+ Addedregexp.prototype.flags@1.5.3(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedset-function-length@1.2.2(transitive)
+ Addedset-function-name@2.0.2(transitive)
+ Addedthunky@1.1.0(transitive)