Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
aztecrabbit committed Jan 27, 2020
1 parent 802a9ec commit 032c9bc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 27 deletions.
39 changes: 18 additions & 21 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"os"
"fmt"
"sync"
"time"

"github.com/aztecrabbit/liblog"
Expand All @@ -17,13 +16,14 @@ import (
const (
appName = "Brainfuck Tunnel"
appVersionName = "Psiphon Pro Go"
appVersionCode = "200125"
appVersionCode = "200127"

copyrightYear = "2020"
copyrightAuthor = "Aztec Rabbit"
)

var (
InterruptHandler = new(libutils.InterruptHandler)
Redsocks = new(libredsocks.Redsocks)
)

Expand All @@ -35,12 +35,10 @@ type Config struct {
}

func init() {
InterruptHandler := &libutils.InterruptHandler{
Handle: func() {
libpsiphon.Stop()
libredsocks.Stop(Redsocks)
liblog.LogKeyboardInterrupt()
},
InterruptHandler.Handle = func() {
libredsocks.Stop(Redsocks)
libpsiphon.Stop()
liblog.LogKeyboardInterrupt()
}
InterruptHandler.Start()
}
Expand All @@ -61,7 +59,14 @@ func main() {
defaultConfig.Inject.Type = 3
defaultConfig.Inject.Rules = map[string][]string{
"akamai.net:80": []string{
"www.pubgmobile.com:80",
"video.iflix.com",
"videocdn-2.iflix.com",
"iflix-videocdn-p1.akamaized.net",
"iflix-videocdn-p2.akamaized.net",
"iflix-videocdn-p3.akamaized.net",
"iflix-videocdn-p6.akamaized.net",
"iflix-videocdn-p7.akamaized.net",
"iflix-videocdn-p8.akamaized.net",
},
}
defaultConfig.Inject.ProxyPayload = ""
Expand All @@ -75,8 +80,8 @@ func main() {
ProxyRotator.Config = config.ProxyRotator

Inject := new(libinject.Inject)
Inject.Config = config.Inject
Inject.Redsocks = Redsocks
Inject.Config = config.Inject

go ProxyRotator.Start()
go Inject.Start()
Expand All @@ -98,26 +103,18 @@ func main() {
return
}

// Defined on global variables
Redsocks.Config = libredsocks.DefaultConfig
if Redsocks.CheckIsEnabled() {
liblog.LogInfo("Redsocks started", "INFO", liblog.Colors["G1"])
}
Redsocks.Start()

var wg sync.WaitGroup

for i := 1; i <= config.PsiphonCore; i++ {
wg.Add(1)

Psiphon := new(libpsiphon.Psiphon)
Psiphon.Config = config.Psiphon
Psiphon.ProxyPort = Inject.Config.Port
Psiphon.KuotaData = libpsiphon.KuotaDataDefault
Psiphon.KuotaData = libpsiphon.DefaultKuotaData
Psiphon.ListenPort = libutils.Atoi(ProxyRotator.Config.Port) + i

go Psiphon.Start(&wg, ProxyRotator)
go Psiphon.Start(ProxyRotator)
}

wg.Wait()
InterruptHandler.Wait()
}
11 changes: 5 additions & 6 deletions src/libpsiphon/libpsiphon.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"os"
"os/exec"
"fmt"
"sync"
"time"
"bufio"
"strconv"
Expand All @@ -31,7 +30,7 @@ var (
KuotaDataLimit: 4,
Authorizations: make([]string, 0),
}
KuotaDataDefault = &KuotaData{
DefaultKuotaData = &KuotaData{
Port: make(map[int]map[string]float64),
All: 0,
}
Expand Down Expand Up @@ -83,7 +82,9 @@ type Psiphon struct {
}

func (p *Psiphon) LogInfo(message string, color string) {
liblog.LogInfo(message, strconv.Itoa(p.ListenPort), color)
if Loop {
liblog.LogInfo(message, strconv.Itoa(p.ListenPort), color)
}
}

func (p *Psiphon) GetAuthorizations() []string {
Expand All @@ -106,9 +107,7 @@ func (p *Psiphon) CheckKuotaDataLimit(sent float64, received float64) bool {
return true
}

func (p *Psiphon) Start(wg *sync.WaitGroup, proxyrotator *libproxyrotator.ProxyRotator) {
defer wg.Done()

func (p *Psiphon) Start(proxyrotator *libproxyrotator.ProxyRotator) {
PsiphonData := &Data{
UpstreamProxyURL: "http://127.0.0.1:" + p.ProxyPort,
DataStoreDirectory: PsiphonDirectory + "/data/" + strconv.Itoa(p.ListenPort),
Expand Down

0 comments on commit 032c9bc

Please sign in to comment.