Skip to content
Snippets Groups Projects
Commit 6d959c2b authored by Pratik Lagaskar's avatar Pratik Lagaskar
Browse files

import go-figure in main

parent a4e751c8
Branches
No related tags found
No related merge requests found
package main
import (
"context"
"fmt"
"log"
"time"
"0xacab.org/leap/vpn-hole/vpnhole/vpnhole"
"github.com/common-nighthawk/go-figure"
"github.com/miekg/dns"
)
func main() {
......@@ -18,46 +14,17 @@ func main() {
Logo := figure.NewColorFigure(" VPN-Hole", "", "green", true)
Logo.Print()
// call Start() to get the config struct with the values
// and then call Stop() to stop the VpnHoleClient
c := vpnhole.NewVpnHoleClient("", "", "", nil)
fmt.Println("\033[32m[+] \033[0m===============================================================\033[32m[+]\033[0m")
err := c.Start()
if err != nil {
log.Fatal(err)
}
defer c.Stop()
fmt.Println(c)
c := vpnhole.NewVpnHoleClient("", "", "", nil)
// start the vpnhole
if err := c.Start(); err != nil {
log.Fatalln(fmt.Errorf("failed to start vpnhole: %w", err))
}
defer func() {
if err := c.Stop(); err != nil {
log.Println(fmt.Errorf("failed to stop vpnhole: %w", err))
}
}()
log.Printf("vpnhole started: %s", c)
subscriptions, err := ReadSubscriptions(c.SubscriptionsFilename)
_, err := c.Start()
if err != nil {
log.Fatalln(fmt.Errorf("failed to read subscriptions list: %w", err))
}
for _, blacklistURL := range subscriptions {
PrivBlacklist.Subscribe(blacklistURL)
}
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
go PrivBlacklist.Watch(ctx, time.Minute*10)
dns.HandleFunc(".", Handler)
if err = dns.ListenAndServe(c.Addr, "udp", nil); err != nil {
log.Println(fmt.Errorf("failed to serve DNS server: %w", err))
log.Fatal(err)
}
// stop the vpnhole
defer c.Stop()
log.Println("\033[31m[+] Stopping VPN-Hole\033[0m")
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment