Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
Distortions81 committed Dec 29, 2023
1 parent 29581be commit 2ece5e7
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 19 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
data/*.json
FactBanSync
composite-banlist.json
data/logs
data/logs
data/banCache/
3 changes: 3 additions & 0 deletions json-read.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ func readConfigFile() {
// Read the Factorio ban list file locally
func readServerBanList() {

if serverConfig.PathData.FactorioBanFile == "" {
return
}
file, err := os.Open(serverConfig.PathData.FactorioBanFile)

if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion json-write.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func writeCompositeBanlist() {
err = os.Rename(tempPath, finalPath)

if err != nil {
log.Printf("Couldn't rename VoteFile file.")
log.Printf("Couldn't rename file.")
}

}
3 changes: 1 addition & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ package main
import (
"flag"
"log"
"runtime/debug"
)

func main() {
var runWizard bool

//KB, MB
debug.SetMemoryLimit(1024 * 1024 * 100)
//debug.SetMemoryLimit(1024 * 1024 * 100)

//Launch arguments
flag.StringVar(&configPath, "configPath", defaultConfigPath, "config file path")
Expand Down
19 changes: 7 additions & 12 deletions mainLoop.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,16 @@ func mainLoop() {
fetchBanLists()
compositeBans()
updateWebCache()
}
//Don't run if no file specificed
if serverConfig.PathData.FactorioBanFile != "" {
if time.Since(LastWatch).Seconds() >= float64(serverConfig.ServerPrefs.WatchFileSeconds) {
LastWatch = time.Now()
if serverConfig.PathData.FactorioBanFile != "" {
watchBanFile()
}
}
}
if time.Since(LastRefresh).Hours() >= float64(serverConfig.ServerPrefs.RefreshListHours) {

} else if time.Since(LastWatch).Seconds() >= float64(serverConfig.ServerPrefs.WatchFileSeconds) &&
serverConfig.PathData.FactorioBanFile != "" {
LastWatch = time.Now()
watchBanFile()

} else if time.Since(LastRefresh).Hours() >= float64(serverConfig.ServerPrefs.RefreshListHours) {
LastRefresh = time.Now()

updateServerList()

}
}
}
3 changes: 0 additions & 3 deletions update.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,6 @@ func fetchFile(url string) ([]byte, error) {
}

maxSize := int64(serverConfig.ServerPrefs.DownloadSizeLimitKB * 1024)
if serverConfig.ServerPrefs.DownloadSizeLimitKB > 0 {
maxSize = serverConfig.ServerPrefs.DownloadSizeLimitKB * 1024
}
if resp.ContentLength > maxSize {
return []byte{}, errors.New("file too large")
}
Expand Down

0 comments on commit 2ece5e7

Please sign in to comment.