Comparing version 2.2.0 to 2.2.1
69
index.js
@@ -1,43 +0,34 @@ | ||
const http = require('http'); | ||
class Netget { | ||
constructor(host, port, protocol) { | ||
this.host = host; | ||
this.port = port; | ||
this.protocol = protocol; | ||
this.server = null; // We'll store our server instance here | ||
} | ||
// index.js | ||
const express = require('express'); | ||
const axios = require('axios'); // Remember to install it. | ||
const { registerWithRegistry } = require('./lib/networkManager'); | ||
listen() { | ||
switch (this.protocol) { | ||
case 'http': | ||
// Create and listen on an HTTP server | ||
this.server = http.createServer((req, res) => { | ||
res.statusCode = 200; | ||
res.setHeader('Content-Type', 'text/plain'); | ||
res.end('Hello, World!\n'); | ||
}); | ||
this.server.listen(this.port, this.host, () => { | ||
console.log(`HTTP server listening at http://${this.host}:${this.port}`); | ||
}); | ||
break; | ||
case 'ssh': | ||
// Create and listen on an SSH server | ||
// ... | ||
break; | ||
// More cases for other protocols... | ||
default: | ||
throw new Error(`Unsupported protocol: ${this.protocol}`); | ||
} | ||
} | ||
const app = express(); | ||
const PORT = process.env.PORT || 3000; | ||
const REGISTRY_URL = 'https://registry.netget.me'; // Placeholder for your registry | ||
close() { | ||
// Close the server | ||
if (this.server) { | ||
this.server.close(() => { | ||
console.log('Server has been closed'); | ||
}); | ||
// Define a basic route | ||
app.get('/', (req, res) => { | ||
res.send('Welcome to netget service node!'); | ||
}); | ||
app.get('/discover/:nodeName', async (req, res) => { | ||
// Use a placeholder in-memory store for simplicity | ||
const nodes = { | ||
YourNodeName: 'http://localhost:3000', | ||
// ... other nodes ... | ||
}; | ||
const nodeAddress = nodes[req.params.nodeName]; | ||
if (nodeAddress) { | ||
res.json({ address: nodeAddress }); | ||
} else { | ||
res.status(404).json({ error: 'Node not found' }); | ||
} | ||
} | ||
} | ||
}); | ||
module.exports = Netget; | ||
app.listen(PORT, () => { | ||
console.log(`Service node started on http://localhost:${PORT}`); | ||
registerWithRegistry(REGISTRY_URL, PORT); // Pass required parameters to the function. | ||
}); | ||
{ | ||
"name": "netget", | ||
"version": "2.2.0", | ||
"version": "2.2.1", | ||
"description": "Rette Adepto/ Recibido Directamente.", | ||
@@ -11,3 +11,3 @@ "main": "index.js", | ||
"keywords": [ | ||
"netget" | ||
"netget" | ||
], | ||
@@ -17,13 +17,14 @@ "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": { | ||
"axios": "^1.4.0", | ||
"dotenv": "^16.3.1", | ||
"express": "^4.18.2" | ||
} | ||
} | ||
} |
<img src="./_._.svg" alt="SVG Image" width="123" height="123" style="width123px; height:123px;"> | ||
# netget | ||
https://neurons.me | ||
This Netget class can represent a network connection of any protocol, and the listen method starts the server based on the protocol. You can implement the logic for creating and listening on servers of different protocols in the switch statement. The close method should close the server. | ||
Implementation with netget: | ||
To use netget as the package that provides this functionality: | ||
Enhance netget to support the concept of registry nodes and service nodes. | ||
Service nodes, when initialized, use netget to register with the network. | ||
netget handles the process of finding registry nodes, validating the service node, and updating its status. | ||
Additionally, netget can provide methods for service discovery, where clients can find the address and service details of a particular node. | ||
netget Architecture & Features: | ||
Service Node Initialization: | ||
netget will provide a simple API that allows any node to initialize itself as a service node. | ||
During initialization, the service node will specify its metadata, including service details, preferred network (e.g., development, production, custom), and other information. | ||
Registry Node Management: | ||
netget must have a way to identify and communicate with registry nodes. | ||
It could come pre-configured with a list of trusted registry nodes, or nodes might specify them during initialization. | ||
Service Registration: | ||
When a service node is initialized, netget will handle the registration process with the registry nodes. | ||
This includes sharing the node's metadata, IP address, and validating its authenticity. | ||
Service Discovery: | ||
netget will provide APIs that allow any client or service to query for a specific service node. | ||
It will connect to registry nodes, find the requested service details, and return them to the client. | ||
Decentralization Support: | ||
If decentralization is a goal, netget needs mechanisms to manage a distributed list of nodes and synchronize this data. | ||
For example, using a DHT approach as mentioned previously. | ||
Security & Validation: | ||
netget should ensure all communications are secure, possibly using cryptographic techniques. | ||
It should provide methods for validating the authenticity of nodes during the registration process. | ||
Network Management: | ||
Nodes should be able to specify which network they want to be part of (e.g., development, production). | ||
netget will manage these networks separately, ensuring isolation between them. | ||
Node Health & Monitoring: | ||
netget could have built-in features to periodically check the health of registered nodes. | ||
If a node is found to be offline or unresponsive, it could be temporarily removed from the active nodes list. | ||
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
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
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
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
119902
13
195
47
0
3
1
+ Addedaxios@^1.4.0
+ Addeddotenv@^16.3.1
+ Addedexpress@^4.18.2
+ Addedaccepts@1.3.8(transitive)
+ Addedarray-flatten@1.1.1(transitive)
+ Addedasynckit@0.4.0(transitive)
+ Addedaxios@1.7.7(transitive)
+ Addedbody-parser@1.20.3(transitive)
+ Addedbytes@3.1.2(transitive)
+ Addedcall-bind@1.0.7(transitive)
+ Addedcombined-stream@1.0.8(transitive)
+ Addedcontent-disposition@0.5.4(transitive)
+ Addedcontent-type@1.0.5(transitive)
+ Addedcookie@0.7.1(transitive)
+ Addedcookie-signature@1.0.6(transitive)
+ Addeddebug@2.6.9(transitive)
+ Addeddefine-data-property@1.1.4(transitive)
+ Addeddelayed-stream@1.0.0(transitive)
+ Addeddepd@2.0.0(transitive)
+ Addeddestroy@1.2.0(transitive)
+ Addeddotenv@16.4.5(transitive)
+ Addedee-first@1.1.1(transitive)
+ Addedencodeurl@1.0.22.0.0(transitive)
+ Addedes-define-property@1.0.0(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedescape-html@1.0.3(transitive)
+ Addedetag@1.8.1(transitive)
+ Addedexpress@4.21.1(transitive)
+ Addedfinalhandler@1.3.1(transitive)
+ Addedfollow-redirects@1.15.9(transitive)
+ Addedform-data@4.0.1(transitive)
+ Addedforwarded@0.2.0(transitive)
+ Addedfresh@0.5.2(transitive)
+ Addedfunction-bind@1.1.2(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)
+ Addedhasown@2.0.2(transitive)
+ Addedhttp-errors@2.0.0(transitive)
+ Addediconv-lite@0.4.24(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedipaddr.js@1.9.1(transitive)
+ Addedmedia-typer@0.3.0(transitive)
+ Addedmerge-descriptors@1.0.3(transitive)
+ Addedmethods@1.1.2(transitive)
+ Addedmime@1.6.0(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)
+ Addedms@2.0.02.1.3(transitive)
+ Addednegotiator@0.6.3(transitive)
+ Addedobject-inspect@1.13.3(transitive)
+ Addedon-finished@2.4.1(transitive)
+ Addedparseurl@1.3.3(transitive)
+ Addedpath-to-regexp@0.1.10(transitive)
+ Addedproxy-addr@2.0.7(transitive)
+ Addedproxy-from-env@1.1.0(transitive)
+ Addedqs@6.13.0(transitive)
+ Addedrange-parser@1.2.1(transitive)
+ Addedraw-body@2.5.2(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedsend@0.19.0(transitive)
+ Addedserve-static@1.16.2(transitive)
+ Addedset-function-length@1.2.2(transitive)
+ Addedsetprototypeof@1.2.0(transitive)
+ Addedside-channel@1.0.6(transitive)
+ Addedstatuses@2.0.1(transitive)
+ Addedtoidentifier@1.0.1(transitive)
+ Addedtype-is@1.6.18(transitive)
+ Addedunpipe@1.0.0(transitive)
+ Addedutils-merge@1.0.1(transitive)
+ Addedvary@1.1.2(transitive)