Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
V
Vpn Hole
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
leap
Vpn Hole
Commits
6d959c2b
Commit
6d959c2b
authored
2 years ago
by
Pratik Lagaskar
Browse files
Options
Downloads
Patches
Plain Diff
import go-figure in main
parent
a4e751c8
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/vpnhole/main.go
+7
-40
7 additions, 40 deletions
app/vpnhole/main.go
with
7 additions
and
40 deletions
app/vpnhole/main.go
+
7
−
40
View file @
6d959c2b
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
(
"
\0
33[32m[+]
\0
33[0m===============================================================
\0
33[32m[+]
\0
33[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
(
"
\0
33[31m[+] Stopping VPN-Hole
\0
33[0m"
)
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment