Skip to content

Commit

Permalink
Delete gotfo and fastopen
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeuw committed Sep 18, 2018
1 parent bc03e39 commit 35597e5
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 27 deletions.
2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ version=$(shell ver=$$(git log -n 1 --pretty=oneline --format=%D | awk -F, '{pri
echo $$ver)

client:
go get github.com/cbeuw/gotfo
go build -ldflags "-X main.version=${version}" -o ./build/gq-client ./cmd/gq-client

server:
go get github.com/cbeuw/gotfo
go build -ldflags "-X main.version=${version}" -o ./build/gq-server ./cmd/gq-server

all: client server
Expand Down
24 changes: 7 additions & 17 deletions cmd/gq-server/gq-server.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// +build go1.8,!go1.10

package main

import (
Expand All @@ -14,7 +12,6 @@ import (
"time"

"github.com/cbeuw/GoQuiet/gqserver"
"github.com/cbeuw/gotfo"
)

var version string
Expand Down Expand Up @@ -112,8 +109,8 @@ func dispatchConnection(conn net.Conn, sta *gqserver.State) {
go pair.remoteToServer()
go pair.serverToRemote()
}
goSS := func(data []byte) {
pair, err := makeSSPipe(conn, sta, data)
goSS := func() {
pair, err := makeSSPipe(conn, sta)
if err != nil {
log.Fatalf("Making connection to ss-server: %v\n", err)
}
Expand Down Expand Up @@ -163,15 +160,8 @@ func dispatchConnection(conn net.Conn, sta *gqserver.State) {
}
}

// If FastOpen is enabled, we need some data ready to send to ss-server
if sta.FastOpen {
tempBuf := make([]byte, 20480)
i, _ = gqserver.ReadTillDrain(conn, tempBuf)
data = gqserver.PeelRecordLayer(tempBuf[:i])
goSS(data)
} else {
goSS(nil)
}
goSS()

}

func makeWebPipe(remote net.Conn, sta *gqserver.State) (*webPair, error) {
Expand All @@ -186,8 +176,8 @@ func makeWebPipe(remote net.Conn, sta *gqserver.State) (*webPair, error) {
return pair, nil
}

func makeSSPipe(remote net.Conn, sta *gqserver.State, data []byte) (*ssPair, error) {
conn, err := gotfo.Dial(sta.SS_LOCAL_HOST+":"+sta.SS_LOCAL_PORT, sta.FastOpen, data)
func makeSSPipe(remote net.Conn, sta *gqserver.State) (*ssPair, error) {
conn, err := net.Dial("tcp", sta.SS_LOCAL_HOST+":"+sta.SS_LOCAL_PORT)
if err != nil {
return &ssPair{}, errors.New("Connection to SS server failed")
}
Expand Down Expand Up @@ -273,7 +263,7 @@ func main() {
go usedRandomCleaner(sta)

listen := func(addr, port string) {
listener, err := gotfo.Listen(addr+":"+port, sta.FastOpen)
listener, err := net.Listen("tcp", addr+":"+port)
log.Println("Listening on " + addr + ":" + port)
if err != nil {
log.Fatal(err)
Expand Down
3 changes: 1 addition & 2 deletions config/gqclient.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
"ServerName":"www.bing.com",
"Key":"exampleconftest",
"TicketTimeHint":3600,
"Browser":"chrome",
"FastOpen":true
"Browser":"chrome"
}
3 changes: 1 addition & 2 deletions config/gqserver.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"WebServerAddr":"204.79.197.200:443",
"Key":"exampleconftest",
"FastOpen":true
"Key":"exampleconftest"
}
5 changes: 2 additions & 3 deletions gqclient/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ type State struct {
AESKey []byte
ServerName string
Browser string
FastOpen bool
}

// semi-colon separated value. This is for Android plugin options
Expand All @@ -46,9 +45,9 @@ func ssvToJson(ssv string) (ret []byte) {
sp := strings.SplitN(ln, "=", 2)
key := sp[0]
value := sp[1]
// JSON doesn't like quotation marks around int and boolean
// JSON doesn't like quotation marks around int
// Yes this is extremely ugly but it's still better than writing a tokeniser
if key == "TicketTimeHint" || key == "FastOpen" {
if key == "TicketTimeHint" {
ret = append(ret, []byte("\""+key+"\":"+value+",")...)
} else {
ret = append(ret, []byte("\""+key+"\":\""+value+"\",")...)
Expand Down
1 change: 0 additions & 1 deletion gqserver/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ type State struct {
SS_LOCAL_PORT string
SS_REMOTE_HOST string
SS_REMOTE_PORT string
FastOpen bool
M sync.RWMutex
UsedRandom map[[32]byte]int
}
Expand Down

0 comments on commit 35597e5

Please sign in to comment.