simplewall icon indicating copy to clipboard operation
simplewall copied to clipboard

[Feature] firewall nostr?

Open stokebreakup opened this issue 1 month ago • 0 comments

Checklist

  • [X] I have used the search function to see if someone else has already submitted the same feature request.
  • [X] I will describe the problem with as much detail as possible.
  • [X] This issue only contains a request for one single feature, not multiple (related) features.

App version

nostr

Problem you are trying to solve

Today many users depend on antivirus, and we can avoid centralizing data through public and shared firewalls. It would be enough for one or more users to share, in a decentralized way, a list of IPs with which they do not want to connect or IPs that do want to connect.

Suggested solution

I was thinking if we couldn't use allowed and disallowed lists in a decentralized way.

Screenshots / Drawings / Technical details

Just a technical concept for something that may or may not be implemented.

import json
import ssl
import time
import uuid
from pynostr.event import Event
from pynostr.relay_manager import RelayManager
from pynostr.filters import FiltersList, Filters
from pynostr.message_type import ClientMessageType
from pynostr.key import PrivateKey

relay_manager = RelayManager(timeout=6)
relay_manager.add_relay("wss://firewall-public-opensource.net")
relay_manager.add_relay("wss://avast.net")
relay_manager.add_relay("wss://malwareybytes.net")
private_key = PrivateKey()

filters = FiltersList([Filters(authors=[private_key.public_key.hex()], limit=100)])
subscription_id = uuid.uuid1().hex
relay_manager.add_subscription_on_all_relays(subscription_id, filters)

event = Event("mask:  255.255.255.255")
event.sign(private_key.hex())
relay_manager.publish_event(event)
relay_manager.run_sync()
time.sleep(5) # allow the messages to send
while relay_manager.message_pool.has_ok_notices():
    ok_msg = relay_manager.message_pool.get_ok_notice()
    print(ok_msg)
while relay_manager.message_pool.has_events():
    event_msg = relay_manager.message_pool.get_event()
    print(event_msg.event.to_dict())

As we can see in the code, I can connect to antivirus company relays.

stokebreakup avatar Jun 29 '24 04:06 stokebreakup