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

Hosts: Support displaying shared IPs #7568

Merged
merged 1 commit into from
Oct 28, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 34 additions & 2 deletions server/chat-plugins/hosts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,33 @@ export const pages: PageTable = {
buf += `<p>None currently.</p>`;
} else {
buf += `<div class="ladder"><table><tr><th>IP</th><th>Reason</th></tr>`;
Punishments.sharedIpBlacklist.forEach((reason, ip) => {
const sortedSharedIPBlacklist = [...Punishments.sharedIpBlacklist];
sortedSharedIPBlacklist.sort((a, b) => IPTools.ipSort(a[1], b[1]));

for (const [reason, ip] of sortedSharedIPBlacklist) {
buf += `<tr><td>${ip}</td><td>${reason}</td></tr>`;
});
}
buf += `</table></div>`;
}
buf += `</div>`;
return buf;
},

sharedips(args, user, connection) {
this.title = `[Shared IPs]`;
checkCanPerform(this, user, 'globalban');

let buf = `<div class="pad"><h2>IPs marked as shared</h2>`;
if (!Punishments.sharedIps.size) {
buf += `<p>None currently.</p>`;
} else {
buf += `<div class="ladder"><table><tr><th>IP</th><th>Location</th></tr>`;
const sortedSharedIPs = [...Punishments.sharedIps];
sortedSharedIPs.sort((a, b) => IPTools.ipSort(a[0], b[0]));

for (const [ip, location] of sortedSharedIPs) {
buf += `<tr><td>${ip}</td><td>${location}</td></tr>`;
}
buf += `</table></div>`;
}
buf += `</div>`;
Expand Down Expand Up @@ -464,6 +488,14 @@ export const commands: ChatCommands = {
`/nomarkshared remove [IP] - Removes an IP from the nomarkshared list. Requires &`,
`/nomarkshared view - Lists all IPs prevented from being marked as shared. Requires @ &`,
],

sharedips: 'viewsharedips',
viewsharedips() {
return this.parse('/join view-sharedips');
},
viewsharedipshelp: [
`/viewsharedips — Lists IP addresses marked as shared. Requires: hosts manager @ &`,
],
};

process.nextTick(() => {
Expand Down