mirror of
https://github.com/simon-ding/polaris.git
synced 2026-06-09 11:39:46 +08:00
update stun proxy
This commit is contained in:
@@ -12,11 +12,20 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (s *Engine) stunProxyDownloadClient() error {
|
func (s *Engine) stunProxyDownloadClient() error {
|
||||||
|
|
||||||
|
return s.StartStunProxy("")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func (s *Engine) StartStunProxy(name string) error {
|
||||||
downloaders := s.db.GetAllDonloadClients()
|
downloaders := s.db.GetAllDonloadClients()
|
||||||
for _, d := range downloaders {
|
for _, d := range downloaders {
|
||||||
if !d.Enable {
|
if !d.Enable {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if name != "" && d.Name != name {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
if d.Implementation != downloadclients.ImplementationQbittorrent { //TODO only support qbittorrent for now
|
if d.Implementation != downloadclients.ImplementationQbittorrent { //TODO only support qbittorrent for now
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -236,6 +236,12 @@ func (s *Server) AddDownloadClient(c *gin.Context) (interface{}, error) {
|
|||||||
}); err != nil {
|
}); err != nil {
|
||||||
return nil, errors.Wrap(err, "save downloader")
|
return nil, errors.Wrap(err, "save downloader")
|
||||||
}
|
}
|
||||||
|
if in.UseNatTraversal {
|
||||||
|
if err := s.core.StartStunProxy(in.Name); err!= nil {
|
||||||
|
return nil, errors.Wrap(err, "start stun proxy")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user