Skip to content

GhostNet demonstrates a peer-to-peer, private, permissionless, and decentralized communication protocol, drawing inspiration from Waku.

License

Notifications You must be signed in to change notification settings

LordGhostX/GhostNet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GhostNet

GhostNet demonstrates a peer-to-peer, private, permissionless, and decentralized communication protocol, drawing inspiration from Waku.

CAUTION: This is a basic demonstration of a communication protocol and should not be employed in any production setting. It lacks many essential features, particularly in spam prevention, scalability, and security.

API Reference

Get node address

Retrieves the address of a specified node.

GET /address

Request

curl --location '/address'

Response

[NODE ADDRESS]

Ping a node

Sends a ping request to an external node within the network; upon a successful ping, the external node will acknowledge the requesting node as a peer.

POST /ping

Request

curl --location '/ping' \
--header 'Content-Type: application/json' \
--data '{
    "node": "[REQUESTING NODE ADDRESS]"
}'

Response

[PINGED NODE ADDRESS]

Bootstrap a node

Receives a list of external node addresses for establishing connections. Upon successful connections, it acknowledges these nodes as peers, and the external nodes reciprocally recognize the requesting node as a peer.

POST /bootstrap

Request

curl --location '/bootstrap' \
--header 'Content-Type: application/json' \
--data '[
    "EXTERNAL NODE ADDRESS 1",
    "EXTERNAL NODE ADDRESS 2",
    "EXTERNAL NODE ADDRESS 3"
]'

Response

[
    ["SUCCESSFUL NODE CONNECTIONS"],
    ["UNSUCCESSFUL NODE CONNECTIONS"]
]

Get connected nodes

Retrieves the list of connected nodes for a given node.

GET /nodes

Request

curl --location '/nodes'

Response

[
    "CONNECTED NODE ADDRESS 1",
    "CONNECTED NODE ADDRESS 2",
    "CONNECTED NODE ADDRESS 3"
]

Relay a message

Broadcasts a provided message across the entire network, with the capability to accept messages in any arbitrary JSON structure. It returns a list of nodes that acted as relays for the message originating from the source node.

POST /relay

Request

curl --location '/relay' \
--header 'Content-Type: application/json' \
--data '{
    "message": "Hello, World!",
    "timestamp": 1234567890
}'

Response

[
    "RELAYED NODE ADDRESS 1",
    "RELAYED NODE ADDRESS 2",
    "RELAYED NODE ADDRESS 3"
]

Share external nodes

Expands its network of connections by requesting existing nodes to share their list of connected nodes and subsequently establishing connections with them.

GET /node-sharing

Request

curl --location '/node-sharing'

Response

[
    ["SUCCESSFUL NODE CONNECTIONS"],
    ["UNSUCCESSFUL NODE CONNECTIONS"]
]

Run Locally

Clone the project

git clone https://github.com/LordGhostX/GhostNet

Go to the project directory

cd GhostNet

Install dependencies

pip install -r requirements.txt

Run a node instance

# Run an instance on the default port (6969)
python3 node.py

# Run an instance on a custom port number
python3 node.py [PORT NUMBER]

Running Tests

To run tests, run the following command

python3 tests.py

About

GhostNet demonstrates a peer-to-peer, private, permissionless, and decentralized communication protocol, drawing inspiration from Waku.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages