Skip to content

Commit

Permalink
Banning (#62)
Browse files Browse the repository at this point in the history
* Add initial support for banning

* Add back a wrongfully deleted line
  • Loading branch information
espebra committed Apr 20, 2024
1 parent 50ec1b6 commit 3c60a0c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
6 changes: 3 additions & 3 deletions dbl/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,19 @@ func (c *ClientDao) Update(client *ds.Client) (err error) {
}

func (c *ClientDao) GetAll() (clients []ds.Client, err error) {
sqlStatement := "SELECT ip, asn, network, city, country, continent, proxy, requests, first_active_at, last_active_at, banned_at, banned_by FROM client ORDER BY last_active_at DESC"
sqlStatement := "SELECT ip, asn, network, city, country, continent, proxy, requests, first_active_at, last_active_at, banned_at, banned_by FROM client ORDER BY last_active_at ASC"
clients, err = c.clientQuery(sqlStatement)
return clients, err
}

func (c *ClientDao) GetByLastActiveAt(limit int) (clients []ds.Client, err error) {
sqlStatement := "SELECT ip, asn, network, city, country, continent, proxy, requests, first_active_at, last_active_at, banned_at, banned_by FROM client ORDER BY last_active_at DESC LIMIT $1"
sqlStatement := "SELECT ip, asn, network, city, country, continent, proxy, requests, first_active_at, last_active_at, banned_at, banned_by FROM client ORDER BY last_active_at ASC LIMIT $1"
clients, err = c.clientQuery(sqlStatement, limit)
return clients, err
}

func (c *ClientDao) GetByRequests(limit int) (clients []ds.Client, err error) {
sqlStatement := "SELECT ip, asn, network, city, country, continent, proxy, requests, first_active_at, last_active_at, banned_at, banned_by FROM client ORDER BY requests DESC LIMIT $1"
sqlStatement := "SELECT ip, asn, network, city, country, continent, proxy, requests, first_active_at, last_active_at, banned_at, banned_by FROM client ORDER BY requests ASC LIMIT $1"
clients, err = c.clientQuery(sqlStatement, limit)
return clients, err
}
Expand Down
6 changes: 3 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ import (

var (
// Various
expirationFlag = flag.Int("expiration", 604800, "Bin expiration time in seconds since the last bin update")
tmpdirFlag = flag.String("tmpdir", os.TempDir(), "Directory for temporary files for upload and download")
baseURLFlag = flag.String("baseurl", "https://filebin.net", "The base URL to use. Required for self-hosted instances.")
expirationFlag = flag.Int("expiration", 604800, "Bin expiration time in seconds since the last bin update")
tmpdirFlag = flag.String("tmpdir", os.TempDir(), "Directory for temporary files for upload and download")
baseURLFlag = flag.String("baseurl", "https://filebin.net", "The base URL to use. Required for self-hosted instances.")
requireApprovalFlag = flag.Bool("manual-approval", false, "Require manual admin approval of new bins before files can be downloaded.")
//enableBanningFlag = flag.Bool("enable-banning", false, "Enable banning. This will allow anyone to ban client IP addresses that upload files to filebin.")
mmdbCityPathFlag = flag.String("mmdb-city", "", "The path to an mmdb formatted geoip database like GeoLite2-City.mmdb.")
Expand Down
6 changes: 6 additions & 0 deletions templates/admin_bar.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
<li class="nav-item">
<a class="nav-link" href="/admin">Dashboard</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/admin/clients">Top clients</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/admin/clients/all">All clients</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/admin/bins">Top bins</a>
</li>
Expand Down

0 comments on commit 3c60a0c

Please sign in to comment.