# List of trackers to register with
Trackers:
-- hltracker.com:5499
-- tracker.preterhuman.net:5499
+ - hltracker.com:5499
+ - tracker.preterhuman.net:5499
# Preserve resource forks and file type/creator codes for files uploaded by Macintosh clients.
# This comes with trade-offs. For more details, see:
# Maximum simultaneous connections/IP; currently unimplemented
MaxConnectionsPerIP: 0
+
+# List of Regular Expression filters for the Files list
+IgnoreFiles:
+ - '^\.*' # Ignore all files starting with ".". Leave this set if you are using the PreserveResourceForks option.
+ - '^@' # Ignore all files starting with "@"
\ No newline at end of file
MaxDownloadsPerClient int `yaml:"MaxDownloadsPerClient"` // Per client simultaneous download limit
MaxConnectionsPerIP int `yaml:"MaxConnectionsPerIP"` // Max connections per IP
PreserveResourceForks bool `yaml:"PreserveResourceForks"` // Enable preservation of file info and resource forks in sidecar files
+ IgnoreFiles []string `yaml:"IgnoreFiles"` // List of regular expression for filtering files from the file list
}
"io/ioutil"
"os"
"path/filepath"
+ "regexp"
"strings"
)
return ft, nil
}
-func getFileNameList(path string) (fields []Field, err error) {
+func getFileNameList(path string, ignoreList []string) (fields []Field, err error) {
files, err := os.ReadDir(path)
if err != nil {
return fields, nil
for _, file := range files {
var fnwi FileNameWithInfo
- if strings.HasPrefix(file.Name(), ".") {
+ if ignoreFile(file.Name(), ignoreList) {
continue
}
var c uint32
for _, f := range dir {
- if !strings.HasPrefix(f.Name(), ".") {
+ if !ignoreFile(f.Name(), ignoreList) {
c += 1
}
}
var c uint32
for _, f := range dir {
- if !strings.HasPrefix(f.Name(), ".") {
+ if !ignoreFile(f.Name(), ignoreList) {
c += 1
}
}
return bytes
}
+
+func ignoreFile(fileName string, ignoreList []string) bool {
+ // skip files that match any regular expression present in the IgnoreFiles list
+ matchIgnoreFilter := 0
+ for _, pattern := range ignoreList {
+ if match, _ := regexp.MatchString(pattern, fileName); match {
+ matchIgnoreFilter += 1
+ }
+ }
+ return matchIgnoreFilter > 0
+}