feat: allow disabling monitor
This commit is contained in:
		
							parent
							
								
									fcf41c3ee7
								
							
						
					
					
						commit
						489ecd65fb
					
				@ -37,6 +37,7 @@ var wgLink *hvpnnode3.WGLink
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
var Country countries.CountryCode
 | 
					var Country countries.CountryCode
 | 
				
			||||||
var UUID uuid.UUID
 | 
					var UUID uuid.UUID
 | 
				
			||||||
 | 
					var Monitor bool = false
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var httpPort int
 | 
					var httpPort int
 | 
				
			||||||
var TLS_ENABLED bool
 | 
					var TLS_ENABLED bool
 | 
				
			||||||
@ -63,7 +64,9 @@ func run(ctx *cli.Context) {
 | 
				
			|||||||
    wgLink.StartedAT = time.Now().UTC()
 | 
					    wgLink.StartedAT = time.Now().UTC()
 | 
				
			||||||
    slog.Info(fmt.Sprintf("Started at %s", wgLink.StartedAT))
 | 
					    slog.Info(fmt.Sprintf("Started at %s", wgLink.StartedAT))
 | 
				
			||||||
    slog.Info(fmt.Sprintf("Country set to %s (%s)", Country.Alpha2(), Country.String()))
 | 
					    slog.Info(fmt.Sprintf("Country set to %s (%s)", Country.Alpha2(), Country.String()))
 | 
				
			||||||
    hvpnnode3.StartMonitor(wgLink, *slog.Default())
 | 
					    if Monitor {
 | 
				
			||||||
 | 
					        hvpnnode3.StartMonitor(wgLink, *slog.Default())
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    apiMux := http.NewServeMux()
 | 
					    apiMux := http.NewServeMux()
 | 
				
			||||||
    apiMux.HandleFunc("GET /node", hvpnnode3.HandleGetNodeInfo(wgLink))
 | 
					    apiMux.HandleFunc("GET /node", hvpnnode3.HandleGetNodeInfo(wgLink))
 | 
				
			||||||
@ -111,7 +114,7 @@ func createCliApp() *cli.App {
 | 
				
			|||||||
    app.Name = os.Args[0]
 | 
					    app.Name = os.Args[0]
 | 
				
			||||||
    app.HideHelpCommand = true
 | 
					    app.HideHelpCommand = true
 | 
				
			||||||
    app.Usage = "HVPN node API server"
 | 
					    app.Usage = "HVPN node API server"
 | 
				
			||||||
    app.Args = true
 | 
					    app.Args = false
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    author1 := cli.Author{
 | 
					    author1 := cli.Author{
 | 
				
			||||||
        Name: "Hesham T. Banafa",
 | 
					        Name: "Hesham T. Banafa",
 | 
				
			||||||
@ -135,6 +138,17 @@ func createCliApp() *cli.App {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
    app.Flags = append(app.Flags, &logLevel)
 | 
					    app.Flags = append(app.Flags, &logLevel)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    monitorFlag := cli.BoolFlag{
 | 
				
			||||||
 | 
					        Name: "monitor",
 | 
				
			||||||
 | 
					        Usage: "Enables a periodic logger with count of current active peers",
 | 
				
			||||||
 | 
					        Value: true,
 | 
				
			||||||
 | 
					        Action: func(ctx *cli.Context, b bool) error {
 | 
				
			||||||
 | 
					            Monitor = b
 | 
				
			||||||
 | 
					            return nil
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    app.Flags = append(app.Flags, &monitorFlag)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    privateKeyFileFlag := cli.PathFlag{
 | 
					    privateKeyFileFlag := cli.PathFlag{
 | 
				
			||||||
        Name: "private-key",
 | 
					        Name: "private-key",
 | 
				
			||||||
        Usage: "Path to file with private key",
 | 
					        Usage: "Path to file with private key",
 | 
				
			||||||
@ -262,6 +276,7 @@ func createCliApp() *cli.App {
 | 
				
			|||||||
    app.Flags = append(app.Flags, &TLSCertKey)
 | 
					    app.Flags = append(app.Flags, &TLSCertKey)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    app.Action = func(ctx *cli.Context) error {
 | 
					    app.Action = func(ctx *cli.Context) error {
 | 
				
			||||||
        err := setup(ctx)
 | 
					        err := setup(ctx)
 | 
				
			||||||
        if err != nil {
 | 
					        if err != nil {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user