Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
aztecrabbit committed Feb 2, 2020
1 parent 147bcf9 commit 78c4eef
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
*.ori
*.bak
*.conf
*.json
*.backup

config.json

app
psiphon-tunnel-core
brainfuck-psiphon-pro
Expand Down
20 changes: 13 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ type Config struct {

func init() {
InterruptHandler.Handle = func() {
libredsocks.Stop(Redsocks)
libpsiphon.Stop()
libredsocks.Stop(Redsocks)
liblog.LogKeyboardInterrupt()
}
InterruptHandler.Start()
Expand Down Expand Up @@ -78,18 +78,24 @@ func main() {

libutils.JsonReadWrite(libutils.RealPath("config.json"), config, defaultConfig)

var flagPro = true
var flagFrontend string
var flagWhitelist string

flag.StringVar(&flagFrontend, "f", flagFrontend, "-f bug.com,bug.com:443")
flag.StringVar(&flagWhitelist, "w", flagWhitelist, "-w akamai.net:80")
flag.IntVar(&config.PsiphonCore, "c", config.PsiphonCore, "-c core (e.g. -c 4) (1 for pro version)")
flag.BoolVar(&flagPro, "pro", flagPro, "Pro Version?")
flag.StringVar(&flagFrontend, "f", flagFrontend, "-f frontend-domains (e.g. -f cdn.com,cdn.com:443)")
flag.StringVar(&flagWhitelist, "w", flagWhitelist, "-w whitelist-request (e.g. -w akamai.net:80)")
flag.IntVar(&config.PsiphonCore, "c", config.PsiphonCore, "-c core (e.g. -c 4) (1 for Pro Version)")
flag.StringVar(&config.Psiphon.Region, "r", config.Psiphon.Region, "-r region (e.g. -r sg)")
flag.IntVar(&config.Psiphon.Tunnel, "t", config.Psiphon.Tunnel, "-t tunnel (e.g. -t 4) (1 for reconnect version)")
flag.IntVar(&config.Psiphon.TunnelWorkers, "tw", config.Psiphon.TunnelWorkers, "-tw tunnel-workers (e.g. -tw 4) (8 for pro version)")
flag.IntVar(&config.Psiphon.KuotaDataLimit, "l", config.Psiphon.KuotaDataLimit, "-l limit (in Bytes) (e.g. -l 4000000) (4 MB) (0 for pro version (unlimited))")
flag.IntVar(&config.Psiphon.Tunnel, "t", config.Psiphon.Tunnel, "-t tunnel (e.g. -t 4) (1 for Reconnect Version)")
flag.IntVar(&config.Psiphon.TunnelWorkers, "tw", config.Psiphon.TunnelWorkers, "-tw tunnel-workers (e.g. -tw 6) (8 for Pro Version)")
flag.IntVar(&config.Psiphon.KuotaDataLimit, "l", config.Psiphon.KuotaDataLimit, "-l limit (in MB) (e.g. -l 4) (0 for Pro Version (unlimited))")
flag.Parse()

if !flagPro {
config.Psiphon.Authorizations = make([]string, 0)
}

if flagFrontend != "" || flagWhitelist != "" {
if flagFrontend == "" {
flagFrontend = "*"
Expand Down
6 changes: 3 additions & 3 deletions src/libpsiphon/libpsiphon.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ var (
"FRONTED-MEEK-HTTP-OSSH",
"FRONTED-MEEK-OSSH",
},
TunnelWorkers: 4,
KuotaDataLimit: 4000000,
TunnelWorkers: 6,
KuotaDataLimit: 4,
Authorizations: make([]string, 0),
}
DefaultKuotaData = &KuotaData{
Expand Down Expand Up @@ -100,7 +100,7 @@ func (p *Psiphon) GetAuthorizations() []string {
}

func (p *Psiphon) CheckKuotaDataLimit(sent float64, received float64) bool {
if p.Config.KuotaDataLimit != 0 && int(p.KuotaData.Port[p.ListenPort]["all"]) >= p.Config.KuotaDataLimit &&
if p.Config.KuotaDataLimit != 0 && int(p.KuotaData.Port[p.ListenPort]["all"]) >= (p.Config.KuotaDataLimit * 1000000) &&
int(sent) == 0 && int(received) <= 64000 {
return false
}
Expand Down

0 comments on commit 78c4eef

Please sign in to comment.