feat: support custom tracker url (#59)

This commit is contained in:
Li Wei authored and GitHub committed 2022-12-12 15:58:11 +08:00
1 parent 9ef3405e43
commit 691c2f496e
71 files changed
+2209 -891

No files matched your search

+16 -6
View File
@@ -6,19 +6,29 @@ import (
"path/filepath"
)
type Controller interface {
Touch(name string, size int64) (file *os.File, err error)
type Controller struct {
GetConfig func(v any) (bool, error)
FileController
//ContextDialer() (proxy.Dialer, error)
}
type DefaultController struct {
type FileController interface {
Touch(name string, size int64) (file *os.File, err error)
}
func NewController() *DefaultController {
return &DefaultController{}
type DefaultFileController struct {
}
func (c *DefaultController) Touch(name string, size int64) (file *os.File, err error) {
func NewController() *Controller {
return &Controller{
FileController: &DefaultFileController{},
GetConfig: func(v any) (bool, error) {
return false, nil
},
}
}
func (c *DefaultFileController) Touch(name string, size int64) (file *os.File, err error) {
dir := filepath.Dir(name)
if err = os.MkdirAll(dir, os.ModePerm); err != nil {
return