Skip to content

Commit

Permalink
Use allowed_rules instead
Browse files Browse the repository at this point in the history
  • Loading branch information
dcadenas committed Mar 25, 2024
1 parent 1a71960 commit c68eafd
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env node

const WHITELIST = {
const ALLOWED = {
pubs: {
add5190be4673768546c18b565da3a699241f0e06a75e2dbc03f18663d1b7b27: true, // Reportinator
},
Expand All @@ -26,10 +26,10 @@ rl.on("line", (line) => {

let res = { id: req.event.id }; // must echo the event's id

const isWhitelistedPub = WHITELIST.pubs.hasOwnProperty(req.event.pubkey);
const isWhitelistedEventKind = WHITELIST.eventKinds.includes(req.event.kind);
const isAllowedPub = ALLOWED.pubs.hasOwnProperty(req.event.pubkey);
const isAllowedEventKind = ALLOWED.eventKinds.includes(req.event.kind);

if (isWhitelistedPub || isWhitelistedEventKind) {
if (isAllowedPub || isAllowedEventKind) {
res.action = "accept";
} else {
res.action = "reject";
Expand Down
2 changes: 1 addition & 1 deletion roles/relay/files/strfry.conf
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ relay {

writePolicy {
# If non-empty, path to an executable script that implements the writePolicy plugin logic
plugin = "./plugins/whitelist.js"
plugin = "./plugins/allowed_rules.js"

# Number of seconds to search backwards for lookback events when starting the writePolicy plugin (0 for no lookback)
lookbackSeconds = 0
Expand Down
6 changes: 3 additions & 3 deletions roles/relay/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@
mode: '0644'


- name: Copy whitelist.js to relay dir
- name: Copy allowed_rules.js to relay dir
become: true
ansible.builtin.copy:
src: "{{ role_path }}/files/whitelist.js"
dest: "{{ homedir }}/services/relay/whitelist.js"
src: "{{ role_path }}/files/allowed_rules.js"
dest: "{{ homedir }}/services/relay/allowed_rules.js"
mode: '0755'


Expand Down
2 changes: 1 addition & 1 deletion roles/relay/templates/docker-compose.yml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ services:
volumes:
- ./strfry.conf:/etc/strfry.conf
- ./strfrydb:/app/strfry-db
- ./whitelist.js:/app/plugins/whitelist.js
- ./allowed_rules.js:/app/plugins/allowed_rules.js
labels:
- "traefik.enable=true"
- "traefik.http.routers.strfry.rule=Host(`{{ domain }}`) && Headers(`Accept`, `application/nostr+json`) || HeadersRegexp(`Connection`, `(?i)Upgrade`) && HeadersRegexp(`Upgrade`, `websocket`)"
Expand Down

0 comments on commit c68eafd

Please sign in to comment.