Remove unused IP ban system
This commit is contained in:
@@ -70,7 +70,6 @@ const date = (d: string) => (!d || d.startsWith("0001-")) ? "never" : formatDate
|
||||
<tr><td>MD5</td><td>{file.hash_md5}</td></tr>
|
||||
<tr><td>Size</td><td>{formatDataVolume(file.size, 4)} ({file.size} B)</td></tr>
|
||||
<tr><td>Created</td><td>{date(file.created)}</td></tr>
|
||||
<tr><td>Thumbnail</td><td>{file.thumbnail_status || "none"}</td></tr>
|
||||
<tr>
|
||||
<td>Abuse</td>
|
||||
<td>
|
||||
@@ -151,7 +150,6 @@ const date = (d: string) => (!d || d.startsWith("0001-")) ? "never" : formatDate
|
||||
<td>User</td>
|
||||
<td>Size</td>
|
||||
<td>Type</td>
|
||||
<td>Views</td>
|
||||
<td>Created</td>
|
||||
<td>Modified</td>
|
||||
<td>Deleted</td>
|
||||
@@ -166,7 +164,6 @@ const date = (d: string) => (!d || d.startsWith("0001-")) ? "never" : formatDate
|
||||
<td>{ref.user_id}</td>
|
||||
<td>{formatDataVolume(ref.size, 3)}</td>
|
||||
<td>{ref.type}</td>
|
||||
<td>{ref.views}</td>
|
||||
<td>{date(ref.created)}</td>
|
||||
<td>{date(ref.modified)}</td>
|
||||
<td>{ref.deleted ? formatDate(ref.deleted) : ""}</td>
|
||||
|
||||
@@ -1,222 +0,0 @@
|
||||
<script>
|
||||
import { preventDefault, stopPropagation } from 'svelte/legacy';
|
||||
import { onMount } from "svelte";
|
||||
import { formatDate } from "util/Formatting";
|
||||
import Expandable from "util/Expandable.svelte";
|
||||
import { loading_finish, loading_start } from "lib/Loading";
|
||||
|
||||
const abuse_types = [
|
||||
"copyright",
|
||||
"child_abuse",
|
||||
"terrorism",
|
||||
"gore",
|
||||
"zoophilia",
|
||||
"malware",
|
||||
"doxing",
|
||||
"revenge_porn",
|
||||
]
|
||||
|
||||
let rows = $state([])
|
||||
let total_offences = $state(0)
|
||||
|
||||
let expanded = $state(false)
|
||||
let creating = $state(false)
|
||||
let new_ban_address = $state()
|
||||
let new_ban_reason = $state(abuse_types[0])
|
||||
|
||||
const get_bans = async () => {
|
||||
loading_start()
|
||||
try {
|
||||
const resp = await fetch(window.api_endpoint+"/admin/ip_ban");
|
||||
if(resp.status >= 400) {
|
||||
throw new Error(resp.text());
|
||||
}
|
||||
rows = await resp.json()
|
||||
|
||||
total_offences = rows.reduce(
|
||||
(acc, curr) => acc + curr.offences.length, 0,
|
||||
)
|
||||
} catch (err) {
|
||||
alert(err);
|
||||
} finally {
|
||||
loading_finish();
|
||||
}
|
||||
};
|
||||
|
||||
const create_ban = async () => {
|
||||
if (!new_ban_address.value) {
|
||||
alert("Please enter an IP address!")
|
||||
return
|
||||
} else if (!new_ban_reason) {
|
||||
alert("Please enter a reason!")
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const form = new FormData()
|
||||
form.append("address", new_ban_address.value)
|
||||
form.append("reason", new_ban_reason)
|
||||
|
||||
const resp = await fetch(
|
||||
window.api_endpoint+"/admin/ip_ban",
|
||||
{ method: "POST", body: form }
|
||||
);
|
||||
if(resp.status >= 400) {
|
||||
throw new Error(await resp.text());
|
||||
}
|
||||
} catch (err) {
|
||||
alert("Failed to add IP ban! "+err)
|
||||
}
|
||||
|
||||
creating = false
|
||||
get_bans();
|
||||
}
|
||||
|
||||
const delete_ban = async (addr) => {
|
||||
if (!confirm("Delete this banned address?\n\n"+addr)) {
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const resp = await fetch(
|
||||
window.api_endpoint+"/admin/ip_ban/"+encodeURI(addr),
|
||||
{ method: "DELETE" }
|
||||
);
|
||||
if(resp.status >= 400) {
|
||||
throw new Error(await resp.text());
|
||||
}
|
||||
} catch (err) {
|
||||
alert("Failed to delete ban! "+err)
|
||||
}
|
||||
|
||||
get_bans();
|
||||
}
|
||||
|
||||
onMount(get_bans);
|
||||
</script>
|
||||
|
||||
<section>
|
||||
<div class="toolbar">
|
||||
<div class="toolbar_label">
|
||||
Bans {rows.length}
|
||||
</div>
|
||||
<div class="toolbar_label">
|
||||
Offences {total_offences}
|
||||
</div>
|
||||
<div class="toolbar_spacer"></div>
|
||||
<button class:button_highlight={expanded} onclick={() => {expanded = !expanded}}>
|
||||
{#if expanded}
|
||||
<i class="icon">unfold_less</i> Collapse all
|
||||
{:else}
|
||||
<i class="icon">unfold_more</i> Expand all
|
||||
{/if}
|
||||
</button>
|
||||
<button class:button_highlight={creating} onclick={() => {creating = !creating}}>
|
||||
<i class="icon">create</i> Add IP ban
|
||||
</button>
|
||||
</div>
|
||||
{#if creating}
|
||||
<div class="highlight_shaded">
|
||||
<form onsubmit={preventDefault(create_ban)}>
|
||||
<div class="form">
|
||||
<label for="field_address">IP address</label>
|
||||
<input id="field_address" type="text" bind:this={new_ban_address}/>
|
||||
<label for="field_reason">Reason</label>
|
||||
<div id="field_reason">
|
||||
{#each abuse_types as t (t)}
|
||||
<input id="reason_{t}" name="reporter_type" type="radio" bind:group={new_ban_reason} value="{t}" />
|
||||
<label for="reason_{t}">{t}</label>
|
||||
<br/>
|
||||
{/each}
|
||||
</div>
|
||||
<button class="button_highlight" type="submit" style="float: right;">
|
||||
<i class="icon">save</i> Save
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#each rows as row (row.address)}
|
||||
<Expandable expanded={expanded} click_expand>
|
||||
{#snippet header()}
|
||||
<div class="header">
|
||||
<div class="title">{row.address}</div>
|
||||
<div class="stats">
|
||||
Offences<br/>
|
||||
{row.offences.length}
|
||||
</div>
|
||||
<div class="stats">
|
||||
Date<br/>
|
||||
{formatDate(row.offences[0].ban_time, false, false, false)}
|
||||
</div>
|
||||
<button onclick={stopPropagation(() => {delete_ban(row.address)})} class="button button_red" style="align-self: center;">
|
||||
<i class="icon">delete</i>
|
||||
</button>
|
||||
</div>
|
||||
{/snippet}
|
||||
<div class="table_scroll">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<td>Reason</td>
|
||||
<td>Reporter</td>
|
||||
<td>Ban time</td>
|
||||
<td>Expire time</td>
|
||||
<td>File</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{#each row.offences as offence (offence.ban_time)}
|
||||
<tr>
|
||||
<td>{offence.reason}</td>
|
||||
<td>{offence.reporter}</td>
|
||||
<td>{formatDate(offence.ban_time, true, true, false)}</td>
|
||||
<td>{formatDate(offence.expire_time, true, true, false)}</td>
|
||||
<td>
|
||||
{#if offence.file_link}
|
||||
<a href={offence.file_link} target="_blank" rel="noreferrer">
|
||||
{offence.file_name}
|
||||
</a>
|
||||
{/if}
|
||||
</td>
|
||||
</tr>
|
||||
{/each}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</Expandable>
|
||||
{/each}
|
||||
</section>
|
||||
|
||||
<style>
|
||||
.toolbar {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
width: 100%;
|
||||
text-align: left;
|
||||
margin-top: 10px;
|
||||
}
|
||||
.toolbar > * { flex: 0 0 auto; }
|
||||
.toolbar_spacer { flex: 1 1 auto; }
|
||||
.toolbar_label { margin: 5px; }
|
||||
|
||||
|
||||
.header {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
line-height: 1.2em;
|
||||
}
|
||||
.title {
|
||||
flex: 1 1 auto;
|
||||
align-self: center;
|
||||
word-break: break-all;
|
||||
padding-left: 8px;
|
||||
}
|
||||
.stats {
|
||||
flex: 0 0 auto;
|
||||
padding: 0 4px;
|
||||
border-left: 1px solid var(--separator);
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
@@ -1,6 +1,5 @@
|
||||
<script>
|
||||
import AbuseReports from "./AbuseReports.svelte"
|
||||
import IPBans from "./IPBans.svelte"
|
||||
import Home from "./Home.svelte"
|
||||
import BlockFiles from "./BlockFiles.svelte";
|
||||
import TabMenu from "util/TabMenu.svelte";
|
||||
@@ -34,11 +33,6 @@ let pages = [
|
||||
title: "E-mail Reporters",
|
||||
icon: "email",
|
||||
component: EmailReporters,
|
||||
}, {
|
||||
path: "/admin/ip_bans",
|
||||
title: "IP Bans",
|
||||
icon: "remove_circle",
|
||||
component: IPBans,
|
||||
}, {
|
||||
path: "/admin/user_bans",
|
||||
title: "User Bans",
|
||||
|
||||
@@ -1,179 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { get_endpoint } from "lib/NovaAPI";
|
||||
import { user } from "lib/UserStore";
|
||||
import { onMount } from "svelte";
|
||||
import Expandable from "util/Expandable.svelte";
|
||||
import { formatDate } from "util/Formatting";
|
||||
|
||||
let result = $state(null);
|
||||
|
||||
onMount(async () => {
|
||||
try {
|
||||
const resp = await fetch(get_endpoint()+"/misc/ip_address_reputation");
|
||||
if(resp.status >= 400) {
|
||||
throw new Error(await resp.text());
|
||||
}
|
||||
result = await resp.json()
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
{#if result !== null && result.user_banned}
|
||||
<section>
|
||||
<Expandable click_expand>
|
||||
{#snippet header()}
|
||||
<div class="header red">
|
||||
Your account has been banned, click for details
|
||||
</div>
|
||||
{/snippet}
|
||||
<p>
|
||||
Your user account has been banned from uploading to
|
||||
Nova due to violation of the
|
||||
<a href="/abuse">content policy</a>. Below is a list of
|
||||
files originating from your account which have been blocked:
|
||||
</p>
|
||||
|
||||
<div class="table_scroll">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<td>File</td>
|
||||
<td>Reason</td>
|
||||
<td>Ban date</td>
|
||||
<td>Expiry date</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{#each result.user_offences as offence (offence.ban_time)}
|
||||
<tr>
|
||||
<td>
|
||||
{#if offence.file_link}
|
||||
<a href={offence.file_link} target="_blank" rel="noreferrer">
|
||||
{offence.file_name}
|
||||
</a>
|
||||
{/if}
|
||||
</td>
|
||||
<td>{offence.reason}</td>
|
||||
<td>{formatDate(offence.ban_time, false, false, false)}</td>
|
||||
<td>{formatDate(offence.expire_time, false, false, false)}</td>
|
||||
</tr>
|
||||
{/each}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<p>
|
||||
If you would like to dispute your account ban you can mail me at
|
||||
support@nova.storage. Please do not mail unless you have a
|
||||
good reason. If you do not provide a valid reason why the ban
|
||||
should be reversed your e-mail will be ignored. And do not
|
||||
forget to put your username ({$user === null ? "" : $user.username}) in the
|
||||
e-mail.
|
||||
</p>
|
||||
</Expandable>
|
||||
</section>
|
||||
{:else if result !== null && result.ip_offences.length > 0}
|
||||
<section>
|
||||
<Expandable click_expand>
|
||||
{#snippet header()}
|
||||
<div class="header" class:red={result.ip_banned} class:yellow={!result.ip_banned}>
|
||||
{#if result.ip_banned}
|
||||
Your IP address has been banned, click for details
|
||||
{:else}
|
||||
Your IP address has received a copyright strike, click for details
|
||||
{/if}
|
||||
</div>
|
||||
{/snippet}
|
||||
|
||||
{#if result.ip_banned}
|
||||
<p>
|
||||
Your IP address ({result.address}) has been banned from
|
||||
uploading to Nova due to violation of the
|
||||
<a href="/abuse">content policy</a>. Below is a list of
|
||||
files originating from your IP address which have been
|
||||
blocked:
|
||||
</p>
|
||||
{:else}
|
||||
<p>
|
||||
Your IP address ({result.address}) has received copyright
|
||||
strikes. At 10 copyright strikes your IP address will be banned
|
||||
and you will be unable to upload files to Nova. Below is a
|
||||
list of files originating from your IP address which have been
|
||||
blocked:
|
||||
</p>
|
||||
{/if}
|
||||
|
||||
<div class="table_scroll">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<td>File</td>
|
||||
<td>Reason</td>
|
||||
<td>Ban date</td>
|
||||
<td>Expiry date</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{#each result.ip_offences as offence (offence.ban_time)}
|
||||
<tr>
|
||||
<td>
|
||||
{#if offence.file_link}
|
||||
<a href={offence.file_link} target="_blank" rel="noreferrer">
|
||||
{offence.file_name}
|
||||
</a>
|
||||
{/if}
|
||||
</td>
|
||||
<td>{offence.reason}</td>
|
||||
<td>{formatDate(offence.ban_time, false, false, false)}</td>
|
||||
<td>{formatDate(offence.expire_time, false, false, false)}</td>
|
||||
</tr>
|
||||
{/each}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
That these files originated from your IP address does not
|
||||
necessarily mean that they were uploaded by you. It's possible
|
||||
that people on your home/business network are sharing the same
|
||||
IP address. If you're using a VPN then there are often many
|
||||
people using the same IP address. And some ISPs deploy CGNAT, in
|
||||
which case there could be hundreds of people sharing the same IP
|
||||
address. In all of these cases IPv6 is the solution, but most
|
||||
ISPs are decades behind on implementing internet standards. They
|
||||
just don't care.
|
||||
</p>
|
||||
<p>
|
||||
Now you may be asking: If IP banning is so unreliable, why are
|
||||
you still using it? Well, I need to protect my service from
|
||||
abuse somehow. The alternative is authenticating every user.
|
||||
This adds another barrier to entry and generally complicates
|
||||
things.
|
||||
</p>
|
||||
<p>
|
||||
If you would like to dispute your IP ban you can mail me at
|
||||
support@nova.storage. Please do not mail unless you have a good
|
||||
reason. If you do not provide a valid reason why the IP ban should
|
||||
be reversed your e-mail will be ignored. And do not forget to put
|
||||
your IP address ({result.address}) in the e-mail.
|
||||
</p>
|
||||
</Expandable>
|
||||
</section>
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
.header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 100%;
|
||||
border-radius: 6px;
|
||||
}
|
||||
.red {
|
||||
background-color: rgba(255, 0, 0, 0.2);
|
||||
}
|
||||
.yellow {
|
||||
background-color: rgba(255, 255, 0, 0.2);
|
||||
}
|
||||
</style>
|
||||
@@ -2,10 +2,9 @@
|
||||
import Menu from "filesystem/Menu.svelte";
|
||||
import Footer from "layout/Footer.svelte";
|
||||
import { drop_target } from "lib/DropTarget";
|
||||
import AddressReputation from "./AddressReputation.svelte";
|
||||
import GetStarted from "./GetStarted.svelte";
|
||||
import Pricing from "./Pricing.svelte";
|
||||
import SubscriptionPlans from "./SubscriptionPlans.svelte";
|
||||
import SubscriptionPlans from "layout/checkout/SubscriptionPlans.svelte";
|
||||
|
||||
let upload_widget
|
||||
</script>
|
||||
@@ -14,8 +13,6 @@ let upload_widget
|
||||
<div class="header_image_container"></div>
|
||||
</header>
|
||||
|
||||
<AddressReputation/>
|
||||
|
||||
<div class="page_content">
|
||||
<div class="highlight_yellow">
|
||||
This is a development server. All files and accounts may be lost when
|
||||
@@ -63,17 +60,6 @@ let upload_widget
|
||||
</header>
|
||||
<SubscriptionPlans/>
|
||||
|
||||
<header>
|
||||
<h1>Get started</h1>
|
||||
</header>
|
||||
<GetStarted/>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
<br/>
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
<svelte:head>
|
||||
<style>
|
||||
body {
|
||||
@@ -113,8 +99,4 @@ header > h1 {
|
||||
background-size: contain;
|
||||
background-position: center;
|
||||
}
|
||||
.bold {
|
||||
font-weight: bold;
|
||||
color: var(--highlight_color);
|
||||
}
|
||||
</style>
|
||||
|
||||
89
svelte/src/user_home/dashboard/AccountBans.svelte
Normal file
89
svelte/src/user_home/dashboard/AccountBans.svelte
Normal file
@@ -0,0 +1,89 @@
|
||||
<script lang="ts">
|
||||
import { get_endpoint } from "lib/NovaAPI";
|
||||
import { user } from "lib/UserStore";
|
||||
import { onMount } from "svelte";
|
||||
import Expandable from "util/Expandable.svelte";
|
||||
import { formatDate } from "util/Formatting";
|
||||
|
||||
let offences = $state([]);
|
||||
|
||||
onMount(async () => {
|
||||
try {
|
||||
const resp = await fetch(get_endpoint()+"/user/bans");
|
||||
if(resp.status >= 400) {
|
||||
throw new Error(await resp.text());
|
||||
}
|
||||
offences = await resp.json()
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
{#if offences.length > 0}
|
||||
<section>
|
||||
<Expandable click_expand>
|
||||
{#snippet header()}
|
||||
<div class="header red">
|
||||
Your account has been banned, click for details
|
||||
</div>
|
||||
{/snippet}
|
||||
<p>
|
||||
Your user account has been banned from uploading to
|
||||
Nova due to violation of the
|
||||
<a href="/abuse">content policy</a>. Below is a list of
|
||||
files originating from your account which have been blocked:
|
||||
</p>
|
||||
|
||||
<div class="table_scroll">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<td>File</td>
|
||||
<td>Reason</td>
|
||||
<td>Ban date</td>
|
||||
<td>Expiry date</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{#each offences as offence (offence.ban_time)}
|
||||
<tr>
|
||||
<td>
|
||||
{#if offence.file_link}
|
||||
<a href={offence.file_link} target="_blank" rel="noreferrer">
|
||||
{offence.file_name}
|
||||
</a>
|
||||
{/if}
|
||||
</td>
|
||||
<td>{offence.reason}</td>
|
||||
<td>{formatDate(offence.ban_time, false, false, false)}</td>
|
||||
<td>{formatDate(offence.expire_time, false, false, false)}</td>
|
||||
</tr>
|
||||
{/each}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<p>
|
||||
If you would like to dispute your account ban you can mail me at
|
||||
support@nova.storage. Please do not mail unless you have a
|
||||
good reason. If you do not provide a valid reason why the ban
|
||||
should be reversed your e-mail will be ignored. And do not
|
||||
forget to put your username ({$user === null ? "" : $user.username}) in the
|
||||
e-mail.
|
||||
</p>
|
||||
</Expandable>
|
||||
</section>
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
.header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 100%;
|
||||
border-radius: 6px;
|
||||
}
|
||||
.red {
|
||||
background-color: rgba(255, 0, 0, 0.2);
|
||||
}
|
||||
</style>
|
||||
@@ -7,7 +7,7 @@ import CardSubscription from "./CardSubscription.svelte";
|
||||
import CardUsage from "./CardUsage.svelte";
|
||||
import CardActivity from "./CardActivity.svelte";
|
||||
import CardPrepaidTransactions from "./CardPrepaidTransactions.svelte";
|
||||
import AddressReputation from "home_page/AddressReputation.svelte";
|
||||
import AccountBans from "./AccountBans.svelte";
|
||||
import { flip } from "svelte/animate";
|
||||
|
||||
let cards = $state([])
|
||||
@@ -74,7 +74,7 @@ onMount(() => {
|
||||
id: "prepaid_transactions",
|
||||
elem: CardPrepaidTransactions,
|
||||
title: "Prepaid transactions",
|
||||
link: "/user/prepaid/transactions",
|
||||
link: "/user/subscription/transactions",
|
||||
}, {
|
||||
id: "usage",
|
||||
elem: CardUsage,
|
||||
@@ -121,7 +121,7 @@ onMount(() => {
|
||||
|
||||
<div class="separator"></div>
|
||||
|
||||
<AddressReputation/>
|
||||
<AccountBans/>
|
||||
|
||||
<div class="cards">
|
||||
{#each cards as card, i (card.id)}
|
||||
|
||||
Reference in New Issue
Block a user