mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 13:36:09 +05:00
fix bugs
This commit is contained in:
@@ -23,21 +23,12 @@ func Blocker() gin.HandlerFunc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
name := filepath.Join(settings.Path, "bip.txt")
|
name := filepath.Join(settings.Path, "bip.txt")
|
||||||
buf, err := ioutil.ReadFile(name)
|
buf, _ := ioutil.ReadFile(name)
|
||||||
if err != nil {
|
|
||||||
return emptyFN
|
|
||||||
}
|
|
||||||
blackIpList := scanBuf(buf)
|
blackIpList := scanBuf(buf)
|
||||||
|
|
||||||
name = filepath.Join(settings.Path, "wip.txt")
|
name = filepath.Join(settings.Path, "wip.txt")
|
||||||
buf, err = ioutil.ReadFile(name)
|
buf, _ = ioutil.ReadFile(name)
|
||||||
if err != nil {
|
|
||||||
return emptyFN
|
|
||||||
}
|
|
||||||
whiteIpList := scanBuf(buf)
|
whiteIpList := scanBuf(buf)
|
||||||
if blackIpList.NumRanges() == 0 {
|
|
||||||
return emptyFN
|
|
||||||
}
|
|
||||||
|
|
||||||
if blackIpList.NumRanges() == 0 && whiteIpList.NumRanges() == 0 {
|
if blackIpList.NumRanges() == 0 && whiteIpList.NumRanges() == 0 {
|
||||||
return emptyFN
|
return emptyFN
|
||||||
@@ -70,8 +61,11 @@ func Blocker() gin.HandlerFunc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func scanBuf(buf []byte) iplist.Ranger {
|
func scanBuf(buf []byte) iplist.Ranger {
|
||||||
scanner := bufio.NewScanner(strings.NewReader(string(buf)))
|
if len(buf) == 0 {
|
||||||
|
return iplist.New(nil)
|
||||||
|
}
|
||||||
var ranges []iplist.Range
|
var ranges []iplist.Range
|
||||||
|
scanner := bufio.NewScanner(strings.NewReader(string(buf)))
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
r, ok, err := parseLine(scanner.Bytes())
|
r, ok, err := parseLine(scanner.Bytes())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user