Skip to content

Commit

Permalink
use local pac txthinking#50
Browse files Browse the repository at this point in the history
  • Loading branch information
txthinking committed Aug 9, 2017
1 parent 2cd194e commit d7ca8c9
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cli/brook/main.go
Expand Up @@ -19,7 +19,7 @@ var debugAddress string
func main() {
app := cli.NewApp()
app.Name = "Brook"
app.Version = "20170723"
app.Version = "20170809"
app.Usage = "A Cross-Platform Proxy Software"
app.Author = "Cloud"
app.Email = "cloud@txthinking.com"
Expand Down
2 changes: 1 addition & 1 deletion gui/bindata_assetfs.go
Expand Up @@ -35724,7 +35724,7 @@ func publicComponentsXSettingHtml() (*asset, error) {
return nil, err
}

info := bindataFileInfo{name: "public/components/x-setting.html", size: 4760, mode: os.FileMode(420), modTime: time.Unix(1494927851, 0)}
info := bindataFileInfo{name: "public/components/x-setting.html", size: 4760, mode: os.FileMode(420), modTime: time.Unix(1495071716, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
Expand Down
1 change: 1 addition & 0 deletions gui/http.go
Expand Up @@ -13,6 +13,7 @@ func RunHTTPServer(address string) error {

r.Methods("POST").Path("/setting").HandlerFunc(PostSetting)
r.Methods("GET").Path("/setting").HandlerFunc(GetSetting)
r.Methods("GET").Path("/pac").HandlerFunc(GetPAC)

n := negroni.New()
n.Use(negroni.NewRecovery())
Expand Down
13 changes: 8 additions & 5 deletions gui/main.go
Expand Up @@ -2,14 +2,15 @@ package main

import (
"os"
"runtime"

"github.com/getlantern/systray"
"github.com/skratchdot/open-golang/open"
"github.com/txthinking/brook"
"github.com/txthinking/brook/sysproxy"
)

const pac = "https://pac.txthinking.com/white/SOCKS5%20local.txthinking.com:1080;%20SOCKS%20local.txthinking.com:1080;%20DIRECT"
const pac = "http://local.txthinking.com:1980/pac"

func main() {
systray.Run(run)
Expand Down Expand Up @@ -38,8 +39,8 @@ func run() {
mSetting := systray.AddMenuItem("Setting", "")
systray.AddMenuItem("---------", "").Disable()
mGithub := systray.AddMenuItem("Upgrade", "")
mEmail := systray.AddMenuItem("Author: cloud@txthinking.com", "")
systray.AddMenuItem("Version: 20170516", "")
mEmail := systray.AddMenuItem("Contact: cloud@txthinking.com", "")
systray.AddMenuItem("Version: 20170809", "")
systray.AddMenuItem("---------", "").Disable()
mQuit := systray.AddMenuItem("Quit", "")

Expand Down Expand Up @@ -97,8 +98,10 @@ func run() {
}

stop := func() error {
if err := sysproxy.TurnOffSystemProxy(); err != nil {
return err
if runtime.GOOS == "windows" {
if err := sysproxy.TurnOffSystemProxy(); err != nil {
return err
}
}
if bk != nil {
bk.Shutdown()
Expand Down
8 changes: 8 additions & 0 deletions gui/pac.go
@@ -0,0 +1,8 @@
package main

import "net/http"

func GetPAC(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/x-ns-proxy-autoconfig")
w.Write([]byte("function FindProxyForURL(url, host){ return \"SOCKS5 local.txthinking.com:1080; SOCKS local.txthinking.com:1080; DIRECT\"; }"))
}

0 comments on commit d7ca8c9

Please sign in to comment.