forked from kutovoys/marzban-torrent-blocker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
52 lines (39 loc) · 957 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package main
import (
"flag"
"fmt"
"log"
"os"
"path/filepath"
"torrents-blocker/config"
"torrents-blocker/utils"
)
var Version string
func main() {
initConfig()
log.Printf("Marzban torrent-blocker: %s", Version)
log.Printf("Service started on %s", config.Hostname)
utils.StartLogMonitor()
}
func initConfig() {
var configPath string
var showVersion bool
flag.StringVar(&configPath, "c", "", "Path to the configuration file")
flag.BoolVar(&showVersion, "v", false, "Display version")
flag.Parse()
if showVersion {
fmt.Printf("Marzban torrent-blocker: %s\n", Version)
os.Exit(0)
}
if configPath == "" {
ex, err := os.Executable()
if err != nil {
log.Fatalf("Error getting executable path: %v", err)
}
configPath = filepath.Join(filepath.Dir(ex), "config.yaml")
}
if err := config.LoadConfig(configPath); err != nil {
log.Fatalf("Failed to load configuration: %v", err)
}
utils.ScheduleBlockedIPsUpdate()
}