Skip to content
Permalink
Browse files

Merge pull request #25 from Jigsaw-Code/bemasc-13

Cleanup and officially move to go 1.13
  • Loading branch information...
bemasc committed Sep 10, 2019
2 parents e295a14 + ee35214 commit 7046a32efd2b086d1d3183d45435fe04401641ad
Showing with 108 additions and 71 deletions.
  1. +8 −0 README.md
  2. +13 −11 go.mod
  3. +82 −56 go.sum
  4. +2 −0 outline/apple/tun2socks.go
  5. +0 −1 outline/shadowsocks/connectivity.go
  6. +3 −1 tunnel/intra/retrier.go
  7. +0 −2 tunnel/intra/tcp.go
@@ -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.
24 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 go.sum

Large diffs are not rendered by default.

@@ -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 {
@@ -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 {
@@ -1,6 +1,7 @@
package intra

import (
"errors"
"io"
"math/rand"
"net"
@@ -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.
@@ -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()

0 comments on commit 7046a32

Please sign in to comment.
You can’t perform that action at this time.