Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

network blocking #61

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

network blocking #61

wants to merge 2 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Jul 5, 2020

This patch uses the swarm opts.verify hook and cabal.removeConnection() to implement network-level blocking of peers. This is only part of what we'll need for a full implementation of blocking since you can still get the content from blocked peers via other peers. I also had to make some room in the command-handling to support blocks as well as other arbitrary flags. Before these changes any flags that weren't hide/unhide wouldn't show up correctly.

depends on cabal-club/cabal-core#96

@cblgh
Copy link
Member

cblgh commented Jul 5, 2020

this is really dope :3

looks like it is missing logic to show messages on clients when e.g. someone i trust (mod/admin) has blocked someone, see the existing logic for (un)hide/mod/admin

// there was no change in behaviour, e.g. someone modded an already
// modded person, hid someone that was already hidden
const changeOccurred = Object.keys(changedRole).filter(r => changedRole[r]).length > 0
if (!changeOccurred) {
this._emitUpdate('user-updated', { key: info.id, user })
if ((user.flags.get('@') || []).includes('block')) {
// drop the connection to blocked users immediately
this.core.removeConnection(info.id)
}
return
}
const type = doc.type.replace(/^flags\//, '')
let action, text
if (['admin', 'mod'].includes(role)) { action = (type === 'add' ? 'added' : 'removed') }
if (role === 'hide') { action = (type === 'add' ? 'hid' : 'unhid') }
if (role === 'hide') {
text = `${issuerName} ${action} ${user.name} ${reason}`
} else {
text = `${issuerName} ${action} ${user.name} as ${role} ${reason}`
}
const obj = { issuer: info.by, receiver: info.id, role, type, reason }
this._emitUpdate('user-updated', { key: info.id, user })
const msg = {
key: '!status',
value: {
timestamp: timestamp(),
type: 'chat/moderation',
content: {
text,
issuerid: info.by,
receiverid: info.id,
role,
type,
reason
}
}
}
// add to !status channel, to have a canonical log of all moderation actions in one place
this.addStatusMessage(msg, '!status')
// also add to the currently focused channel, so that the moderation action isn't missed
if (this.chname !== '!status') {
this.addStatusMessage(msg)
}
})
})

@garbados
Copy link

garbados commented Jul 5, 2020

Woo! Network-level blocking!

Does this also undownload the blocked peer's feed? Such as in the case of an illegal number attack, spamming, etc.

@ghost
Copy link
Author

ghost commented Jul 5, 2020

This patch doesn't yet delete the remote feed and refuse to replicate it again. That is the second part of implementing this feature fully which will require some changes upstream in multifeed.

@garbados
Copy link

garbados commented Jul 5, 2020

Noted, thanks 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants