mirror of
https://github.com/neocities/neocities.git
synced 2025-04-28 11:12:30 +02:00
limit ip site creation
This commit is contained in:
parent
9140f3b929
commit
15c60cb6a8
2 changed files with 9 additions and 1 deletions
2
app.rb
2
app.rb
|
@ -550,7 +550,7 @@ post '/create' do
|
||||||
}.to_json
|
}.to_json
|
||||||
end
|
end
|
||||||
|
|
||||||
if !black_box_answered || !@site.valid?
|
if !black_box_answered || !@site.valid? || Site.ip_create_limit?(request.ip)
|
||||||
flash[:error] = 'There was an unknown error, please try again.'
|
flash[:error] = 'There was an unknown error, please try again.'
|
||||||
return {result: 'error'}.to_json
|
return {result: 'error'}.to_json
|
||||||
end
|
end
|
||||||
|
|
|
@ -95,6 +95,9 @@ class Site < Sequel::Model
|
||||||
SUGGESTIONS_VIEWS_MIN = 500
|
SUGGESTIONS_VIEWS_MIN = 500
|
||||||
CHILD_SITES_MAX = 100
|
CHILD_SITES_MAX = 100
|
||||||
|
|
||||||
|
IP_CREATE_LIMIT = 50
|
||||||
|
TOTAL_IP_CREATE_LIMIT = 300
|
||||||
|
|
||||||
PLAN_FEATURES[:catbus] = PLAN_FEATURES[:fatcat].merge(
|
PLAN_FEATURES[:catbus] = PLAN_FEATURES[:fatcat].merge(
|
||||||
name: 'Cat Bus',
|
name: 'Cat Bus',
|
||||||
space: Filesize.from('10GB').to_i,
|
space: Filesize.from('10GB').to_i,
|
||||||
|
@ -206,6 +209,11 @@ class Site < Sequel::Model
|
||||||
return nil if site.nil? || site.is_banned || site.owner.is_banned
|
return nil if site.nil? || site.is_banned || site.owner.is_banned
|
||||||
site
|
site
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def ip_create_limit?(ip)
|
||||||
|
Site.where('created_at > ?', Date.today.to_time).where(ip: ip).count > IP_CREATE_LIMIT ||
|
||||||
|
Site.where(ip: ip).count > TOTAL_IP_CREATE_LIMIT
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.banned_ip?(ip)
|
def self.banned_ip?(ip)
|
||||||
|
|
Loading…
Add table
Reference in a new issue