This NIP defines a standard for facilitating TCP requests over NOSTR relays to a specified destination. One basic implementation is currently available at [https://github.com/asmogo/nws](https://github.com/asmogo/nws).
While Nostr has been primarily focused on message-based communications, there is a growing need to extend its capabilities to support other types of network communication, such as TCP.
The motivation behind NWS is to leverage the existing Nostr infrastructure to facilitate TCP connections in a decentralized and privacy-preserving manner. By using Nostr relays as intermediaries, clients can establish connections to remote servers without needing direct access to their IP addresses, thereby reducing exposure to potential security risks and censorship.
### Terminology
*`client` - The entity initiating a TCP request over NOSTR.
*`exit-node` - The entity receiving a TCP request over NOSTR and forwarding it to the intended destination.
## Kinds
*`28333: KindEphemeralEvent` - Used to specify TCP messages.
*`38333: KindAnnouncementEvent` - Used to publicly announce the exit node to clients.
*`38334: KindCertificateEvent` - Used to publish the SSL certificate for the exit node.
### Message Format
Every message must have the following format:
```json
{
"key": "3b1f09a8-2b10-4daa-880c-2a392e781f09",
"type": "CONNECT",
"data": "GET /hello HTTP/1.1",
"destination": "google.com",
}
```
The `key` field is used to identify the message and is required. All TCP messages from one stream must have the same key.
The `data` field contains the data to be transmitted to the destination.
The `destination` field specifies the destination of the TCP connection (if the exit node wants to establish a connection to a remote server).
The `type` field specifies the type of message and is required. There are three defined message types within this protocol:
Unlike traditional TCP/IP communications that resolve a domain name to an IP address and establish a direct connection, NIP-74 leverages NOSTR relays as intermediate proxies for TCP communications.
The client must send an encrypted direct message to the desired NOSTR public key, following the format outlined in the [Message Format] section.
Upon receiving the message, the exit node will process the request according to the specified message type, facilitating communication between the client and the destination.