feat(ftp): support upload, download and PASV rebind (#13)

Co-authored-by: E99p1ant <[email protected]>
This commit is contained in:
Li4n0
2021-05-05 12:59:50 +08:00
committed by GitHub
co-authored by E99p1ant
parent 3d8507e682
commit b39ee101f9
15 changed files with 374 additions and 146 deletions
+12 -4
View File
@@ -1,12 +1,20 @@
package rule
import "strings"
import (
"strings"
)
func CompileTpl(tpl string, vars map[string]string) (compiled string) {
compiled = tpl
// CompileTpl receive []byte or string type tpl and variables map.
// Return the template after variable substitution
func CompileTpl(tpl interface{}, vars map[string]string) (compiled string) {
switch v := tpl.(type) {
case string:
compiled = v
case []byte:
compiled = string(v)
}
for n, v := range vars {
compiled = strings.ReplaceAll(compiled, "${"+n+"}", v)
}
return compiled
}