This commit is contained in:
Believethehype 2024-12-13 20:13:40 +01:00
parent 322dfcfbef
commit 35e6199100
5 changed files with 39 additions and 6 deletions

View File

@ -138,7 +138,7 @@ class DVM:
config=self.dvm_config, skip_meta=False) config=self.dvm_config, skip_meta=False)
# if user is blacklisted for some reason, send an error reaction and return # if user is blacklisted for some reason, send an error reaction and return
if user.isblacklisted: if user.isblacklisted:
await send_job_status_reaction(nip90_event, "error", client=self.client, dvm_config=self.dvm_config) # await send_job_status_reaction(nip90_event, "error", client=self.client, dvm_config=self.dvm_config)
print("[" + self.dvm_config.NIP89.NAME + "] Request by blacklisted user, skipped") print("[" + self.dvm_config.NIP89.NAME + "] Request by blacklisted user, skipped")
return return
if self.dvm_config.LOGLEVEL.value >= LogLevel.INFO.value: if self.dvm_config.LOGLEVEL.value >= LogLevel.INFO.value:

View File

@ -215,9 +215,10 @@ async def send_event_outbox(event: Event, client, dvm_config) -> SendEventOutput
# 5. Otherwise, we create a new Outbox client with the inbox relays and send the event there # 5. Otherwise, we create a new Outbox client with the inbox relays and send the event there
relaylimits = RelayLimits.disable() relaylimits = RelayLimits.disable()
connection = Connection().embedded_tor().target(ConnectionTarget.ONION) connection = Connection().embedded_tor().target(ConnectionTarget.ONION)
# connection = Connection().addr("127.0.0.1:9050").target(ConnectionTarget.ONION) # connection = Connection().addr("127.0.0.1:9050").target(ConnectionTarget.ONION)
opts = Options().relay_limits(relaylimits).connection(connection).timeout(timedelta(seconds=5)) opts = Options().relay_limits(relaylimits).connection(connection)
sk = SecretKey.from_hex(dvm_config.PRIVATE_KEY) sk = SecretKey.from_hex(dvm_config.PRIVATE_KEY)
keys = Keys.parse(sk.to_hex()) keys = Keys.parse(sk.to_hex())
outboxclient = ClientBuilder().signer(NostrSigner.keys(keys)).opts(opts).build() outboxclient = ClientBuilder().signer(NostrSigner.keys(keys)).opts(opts).build()

View File

@ -57,7 +57,7 @@ AVOID_OUTBOX_RELAY_LIST = ["wss://nos.lol", "wss://nostr.fmt.wiz.biz", "wss://no
"wss://nostr.cro.social", "wss://datagrave.wild-vibes.ts.net/nostr", "wss://nostr01.sharkshake.net", "wss://nostr.cro.social", "wss://datagrave.wild-vibes.ts.net/nostr", "wss://nostr01.sharkshake.net",
"wss://relay.nostreggs.io", "wss://nostr.rocks", "wss://groups.0xchat.com", "wss://relay.nostreggs.io", "wss://nostr.rocks", "wss://groups.0xchat.com",
"wss://bostr.lecturify.net", "wss://dave.st.germa.in/nostr", "wss://bostr.lecturify.net", "wss://dave.st.germa.in/nostr",
"wss://dvms.f7z.io", "wss://nostr.social", "wss://i.nostr.build", "wss://nostr.social", "wss://i.nostr.build",
"wss://teemie1-relay.duckdns.org", "wss://newperspectives.duckdns.org", "wss://teemie1-relay.duckdns.org", "wss://newperspectives.duckdns.org",
"wss://nostrs.build", "wss://relay.hllo.live", "wss://relay-pub.deschooling.us", "wss://nostrs.build", "wss://relay.hllo.live", "wss://relay-pub.deschooling.us",
"wss://nostr.sandwich.farm", "wss://nostr.lol", "wss://nostr.developer.li", "wss://nostr.sandwich.farm", "wss://nostr.lol", "wss://nostr.developer.li",

View File

@ -1164,12 +1164,12 @@ def playground():
"logger": False} "logger": False}
image = "https://image.nostr.build/53536b3eccb03fdb127849b79f85b0b6ecb241d12068b65f52afe4a4650d5318.jpg" image = "https://image.nostr.build/53536b3eccb03fdb127849b79f85b0b6ecb241d12068b65f52afe4a4650d5318.jpg"
description = "I show popular notes with < 210 symbols" description = "I show popular tweets with < 210 symbols"
custom_processing_msg = ["Tweets are short notes"] custom_processing_msg = ["Tweets are short notes"]
cost = 0 cost = 0
update_db = False # we use the DB scheduler above for a shared database. Or don't use it and let the DVM manage it update_db = False # we use the DB scheduler above for a shared database. Or don't use it and let the DVM manage it
discovery_tweets = build_example_tweets("Popular Tweets", discovery_tweets = build_example_tweets("Free Bird",
"discovery_content_tweets", "discovery_content_tweets",
admin_config, options, admin_config, options,
image=image, image=image,

32
tests/tor_test.py Normal file
View File

@ -0,0 +1,32 @@
import asyncio
from nostr_sdk import Keys, ClientBuilder, Options, EventBuilder, Connection, ConnectionTarget, init_logger, LogLevel, NostrSigner
async def main():
init_logger(LogLevel.INFO)
keys = Keys.generate()
print(keys.public_key().to_bech32())
# Configure client to use embedded tor for `.onion` relays
connection = Connection().embedded_tor().target(ConnectionTarget.ONION)
opts = Options().connection(connection)
signer = NostrSigner.keys(keys)
client = ClientBuilder().signer(signer).opts(opts).build()
await client.add_relay("wss://relay.damus.io")
await client.add_relay("ws://oxtrdevav64z64yb7x6rjg4ntzqjhedm5b5zjqulugknhzr46ny2qbad.onion")
await client.add_relay("ws://2jsnlhfnelig5acq6iacydmzdbdmg7xwunm4xl6qwbvzacw4lwrjmlyd.onion")
await client.connect()
event = EventBuilder.text_note("Hello from rust-nostr Python bindings!")
res = await client.send_event_builder(event)
print("Event sent:")
print(f" hex: {res.id.to_hex()}")
print(f" bech32: {res.id.to_bech32()}")
print(f" Successfully sent to: {res.output.success}")
print(f" Failed to send to: {res.output.failed}")
if __name__ == '__main__':
asyncio.run(main())