Skip to content

Commit

Permalink
Merge pull request #25 from Jigsaw-Code/bemasc-13
Browse files Browse the repository at this point in the history
Cleanup and officially move to go 1.13
  • Loading branch information
Benjamin M. Schwartz committed Sep 10, 2019
2 parents e295a14 + ee35214 commit 7046a32
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 71 deletions.
8 changes: 8 additions & 0 deletions README.md
Expand Up @@ -14,6 +14,14 @@ Go package for building [go-tun2socks](https://github.com/eycorsican/go-tun2sock
- Docker (Windows, Linux)
- Other common utilities (e.g.: git)

Additionally, github.com/Jigsaw-Code/outline-ss-server must be in $GOROOT/src, as well as all of its dependencies.
This is necessary because gomobile does not support modules. You can fetch these dependencies in the required way by running

```bash
git clone git@github.com:Jigsaw-Code/outline-ss-server.git $GOPATH/src/github.com/Jigsaw-Code/outline-ss-server
GO111MODULE=off go get -d $GOPATH/src/github.com/Jigsaw-Code/outline-ss-server/...
```

## macOS Framework

As of Go 1.13, gomobile does not support building frameworks for macOS. We have patched gomobile to enable building a framework for macOS by replacing the default iOS simulator build.
Expand Down
24 changes: 13 additions & 11 deletions go.mod
@@ -1,19 +1,21 @@
module github.com/Jigsaw-Code/outline-go-tun2socks

go 1.12
go 1.13

require (
github.com/Jigsaw-Code/getsni v0.0.0-20190807203514-efe2dbf35d1f
github.com/Jigsaw-Code/outline-ss-server v1.0.6
github.com/eycorsican/go-tun2socks v1.16.3
github.com/karalabe/xgo v0.0.0-20190301120235-2d6d1848fb02 // indirect
github.com/miekg/dns v1.1.12 // indirect
golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f // indirect
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522 // indirect
golang.org/x/image v0.0.0-20190523035834-f03afa92d3ff // indirect
golang.org/x/mobile v0.0.0-20190509164839-32b2708ab171 // indirect
golang.org/x/net v0.0.0-20190522155817-f3200d17e092 // indirect
golang.org/x/sys v0.0.0-20190523142557-0e01d883c5c5 // indirect
golang.org/x/text v0.3.2 // indirect
golang.org/x/tools v0.0.0-20190523174634-38d8bcfa38af // indirect
github.com/google/go-cmp v0.3.1 // indirect
github.com/kr/pretty v0.1.0 // indirect
github.com/oschwald/geoip2-golang v1.3.0 // indirect
github.com/oschwald/maxminddb-golang v1.4.0 // indirect
github.com/prometheus/client_golang v1.1.0 // indirect
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4 // indirect
github.com/prometheus/procfs v0.0.4 // indirect
github.com/stretchr/testify v1.4.0 // indirect
golang.org/x/crypto v0.0.0-20190909091759-094676da4a83 // indirect
golang.org/x/net v0.0.0-20190909003024-a7b16738d86b // indirect
golang.org/x/sys v0.0.0-20190910064555-bbd175535a8b // indirect
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
)
138 changes: 82 additions & 56 deletions go.sum

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions outline/apple/tun2socks.go
Expand Up @@ -37,6 +37,8 @@ func init() {
// Apple VPN extensions have a memory limit of 15MB. Conserve memory by increasing garbage
// collection frequency and returning memory to the OS every minute.
debug.SetGCPercent(10)
// TODO: Check if this is still needed in go 1.13, which returns memory to the OS
// automatically.
ticker := time.NewTicker(time.Minute * 1)
go func() {
for range ticker.C {
Expand Down
1 change: 0 additions & 1 deletion outline/shadowsocks/connectivity.go
Expand Up @@ -55,7 +55,6 @@ func CheckConnectivity(host string, port int, password, cipher string) (int, err
// The TCP connectivity checks succeeded, which means UDP is not supported.
return udpConnectivity, nil
}
// TODO: use errors.Is when upgrading to Go 1.13
_, isReachabilityError := tcpErr.(*oss.ReachabilityError)
_, isAuthError := tcpErr.(*oss.AuthenticationError)
if isAuthError {
Expand Down
4 changes: 3 additions & 1 deletion tunnel/intra/retrier.go
@@ -1,6 +1,7 @@
package intra

import (
"errors"
"io"
"math/rand"
"net"
Expand Down Expand Up @@ -123,7 +124,8 @@ func (r *retrier) Read(buf []byte) (n int, err error) {
if !r.retryCompleted() {
r.mutex.Lock()
if err != nil {
if neterr, ok := err.(net.Error); ok {
var neterr net.Error
if errors.As(err, &neterr) {
r.stats.Timeout = neterr.Timeout()
}
// Read failed. Retry.
Expand Down
2 changes: 0 additions & 2 deletions tunnel/intra/tcp.go
Expand Up @@ -68,8 +68,6 @@ func NewTCPHandler(fakedns, truedns net.TCPAddr, alwaysSplitHTTPS bool, listener

// TODO: Propagate TCP RST using local.Abort(), on appropriate errors.
func (h *tcpHandler) handleUpload(local core.TCPConn, remote DuplexConn, upload chan int64) {
// TODO: Handle half-closed sockets more correctly if upstream
// changes `local` to a more detailed type than `net.Conn`.
bytes, _ := remote.ReadFrom(local)
local.CloseRead()
remote.CloseWrite()
Expand Down

0 comments on commit 7046a32

Please sign in to comment.