Skip to content

Commit ce070d4

Browse files
author
Delta-Kronecker
committed
feat: archive preservation + clean_failed_subs toggle
1 parent 4ec6c5d commit ce070d4

4 files changed

Lines changed: 13 additions & 2 deletions

File tree

data/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"validation": {
33

4+
"clean_failed_subs": false,
45
"num_workers": 1000,
56
"global_timeout_sec": 20000,
67
"xray_start_timeout_ms": 8000,

src/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func main() {
6969
fmt.Printf(" Loaded %d sources from sub.txt\n", len(subURLs))
7070
var failedURLs []string
7171
allConfigs, failedLinks, failedURLs = fetchAllFromSubs(subURLs)
72-
if len(failedURLs) > 0 {
72+
if len(failedURLs) > 0 && cfg.Validation.CleanFailedSubs {
7373
cleanSubFile("data/sub.txt", failedURLs)
7474
}
7575
} else {

src/types.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ type GeoSettings struct {
2727
}
2828

2929
type ValidationSettings struct {
30-
NumWorkers int `json:"num_workers"`
30+
CleanFailedSubs bool `json:"clean_failed_subs"`
31+
NumWorkers int `json:"num_workers"`
3132
GlobalTimeoutSec float64 `json:"global_timeout_sec"`
3233
XrayStartTimeoutMs int `json:"xray_start_timeout_ms"`
3334
XrayStartIntervalMs int `json:"xray_start_interval_ms"`

src/writer.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,16 @@ func injectClashProxies(baseContent string, proxyEntries []string, proxyNames []
8484
// ── prepareOutputDirs ─────────────────────────────────────────────────────────
8585

8686
func prepareOutputDirs() error {
87+
archiveDir := filepath.Join("config", "archive")
88+
tmpArchive := filepath.Join("config", ".archive_tmp")
89+
if _, err := os.Stat(archiveDir); err == nil {
90+
os.Rename(archiveDir, tmpArchive)
91+
}
8792
os.RemoveAll("config")
93+
if _, err := os.Stat(tmpArchive); err == nil {
94+
os.MkdirAll(archiveDir, 0755)
95+
os.Rename(tmpArchive, archiveDir)
96+
}
8897
dirs := []string{
8998
"config",
9099
cfg.Output.ProtocolsDir,

0 commit comments

Comments
 (0)