henrypp / simplewall

Simple tool to configure Windows Filtering Platform (WFP) which can configure network activity on your computer.
GNU General Public License v3.0
5.8k stars 468 forks source link

[Feature] firewall nostr? #1814

Open stokebreakup opened 3 weeks ago

stokebreakup commented 3 weeks ago

Checklist

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.