Skip to content
This repository has been archived by the owner on Aug 27, 2020. It is now read-only.

Commit

Permalink
pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
lzjluzijie committed Jun 13, 2018
1 parent 79072c3 commit 35fb683
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ dist
websocks.cer
websocks.key
*.config.json
*.pac
4 changes: 2 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ var Command = cli.Command{
Usage: "local listening port",
},
cli.StringFlag{
Name: "p",
Name: "pattern",
Value: "/websocks",
Usage: "server.com/pattern, like password, start with '/'",
Usage: "server.com/pattern",
},
cli.BoolFlag{
Name: "tls",
Expand Down
8 changes: 7 additions & 1 deletion config/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/gorilla/websocket"
"github.com/lzjluzijie/websocks/core"
"github.com/pkg/errors"
"github.com/urfave/cli"
)

Expand Down Expand Up @@ -40,12 +41,17 @@ func GetServerConfig(path string) (server *core.Server, err error) {
func GenerateServerConfig(c *cli.Context) (err error) {
path := c.String("path")
listenAddr := c.String("l")
pattern := c.String("p")
pattern := c.String("pattern")
tls := c.Bool("tls")
certPath := c.String("cert")
keyPath := c.String("key")
reverseProxy := c.String("reverse-proxy")

if []byte(pattern)[0] != '/' {
err = errors.New("pattern does not start with '/'")
return
}

config := &core.ServerConfig{
Pattern: pattern,
ListenAddr: listenAddr,
Expand Down
9 changes: 5 additions & 4 deletions websocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import (

"io/ioutil"

"errors"
"runtime"

"github.com/juju/loggo"
"github.com/lzjluzijie/websocks/config"
"github.com/lzjluzijie/websocks/core"
"github.com/urfave/cli"
"runtime"
"errors"
"golang.org/x/sys/windows/registry"
)

Expand Down Expand Up @@ -151,11 +152,11 @@ func main() {
}

k, err := registry.OpenKey(registry.CURRENT_USER, `Software\Microsoft\Windows\CurrentVersion\Internet Settings`, registry.ALL_ACCESS)
if err != nil{
if err != nil {
return
}

err = k.SetStringValue("AutoConfigURL", "http://127.0.0.1:23333/pac")
err = k.SetStringValue("AutoConfigURL", "http://127.0.0.1:10801/pac")
return
},
},
Expand Down

0 comments on commit 35fb683

Please sign in to comment.