mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-24 05:35:46 +08:00
ADD github gitlab镜像加速器
This commit is contained in:
28
app/controllers/concerns/acceleratorable.rb
Normal file
28
app/controllers/concerns/acceleratorable.rb
Normal file
@@ -0,0 +1,28 @@
|
||||
module Acceleratorable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
def enable_accelerator?(clone_addr)
|
||||
clone_addr.include?(github_domain) || clone_addr.include?(gitlab_domain)
|
||||
end
|
||||
|
||||
def accelerator_url(repo_name)
|
||||
[accelerator_domain, accelerator_username, "#{repo_name}.git"].join('/')
|
||||
end
|
||||
|
||||
def github_domain
|
||||
'github.com'
|
||||
end
|
||||
|
||||
def gitlab_domain
|
||||
'gitlab.com'
|
||||
end
|
||||
|
||||
def accelerator_domain
|
||||
Gitea.gitea_config[:accelerator]["domain"]
|
||||
end
|
||||
|
||||
def accelerator_username
|
||||
Gitea.gitea_config[:accelerator]["access_key_id"]
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user