goproxy0 / goproxy

致敬@phuslu
146 stars 109 forks source link

有没有指导一下编译遇到的问题 #22

Open GLingDroid opened 6 years ago

GLingDroid commented 6 years ago

我是在windows下用docker装了个ubuntu弄的, 按照编译步骤那里,编译 golang 工具链 和 编译 bogo 都通过了, 编译 goproxy 时 awk那里开始出现问题, 一个是

github.com/phuslu/glog (download)
# cd /usr/src/goproxy/gopath/src/github.com/phuslu/glog; git pull --ff-only
fatal: Not possible to fast-forward, aborting.

一个是 golang.org/x/那边几个库版本对不上

然后尝试了下go build -v 出现2种错误

具体请看


root@343beab498c5:/usr/src/goproxy/goproxy# awk 'match($1, /"((github\.com|golan
g\.org|gopkg\.in)\/.+)"/) {if (!seen[$1]++) {gsub("\"", "", $1); print $1}}' $(f
ind . -name "*.go") | xargs -n1 -i go get -v -u {}
github.com/cloudflare/golibs (download)
github.com/phuslu/glog (download)
# cd /usr/src/goproxy/gopath/src/github.com/phuslu/glog; git pull --ff-only
fatal: Not possible to fast-forward, aborting.
package github.com/phuslu/glog: exit status 128
github.com/wangtuanjie/ip17mon (download)
github.com/dsnet/compress (download)
github.com/phuslu/net (download)
package golang.org/x/text/secure/bidirule: directory "/usr/src/goproxy/gopath/sr
c/golang.org/x/text/secure/bidirule" is not using a known version control system
package golang.org/x/text/unicode/bidi: directory "/usr/src/goproxy/gopath/src/g
olang.org/x/text/unicode/bidi" is not using a known version control system
package golang.org/x/text/unicode/norm: directory "/usr/src/goproxy/gopath/src/g
olang.org/x/text/unicode/norm" is not using a known version control system
github.com/phuslu/quic-go (download)
github.com/hashicorp/golang-lru (download)
github.com/lucas-clemente/aes12 (download)
github.com/lucas-clemente/fnv128a (download)
github.com/lucas-clemente/quic-go-certificates (download)
package golang.org/x/net/http2: directory "/usr/src/goproxy/gopath/src/golang.or
g/x/net/http2" is not using a known version control system
package golang.org/x/net/http2/hpack: directory "/usr/src/goproxy/gopath/src/gol
ang.org/x/net/http2/hpack" is not using a known version control system
package golang.org/x/net/idna: directory "/usr/src/goproxy/gopath/src/golang.org
/x/net/idna" is not using a known version control system
package golang.org/x/net/lex/httplex: directory "/usr/src/goproxy/gopath/src/gol
ang.org/x/net/lex/httplex" is not using a known version control system
package golang.org/x/crypto/ssh: directory "/usr/src/goproxy/gopath/src/golang.o
rg/x/crypto/ssh" is not using a known version control system
package golang.org/x/sys/windows/registry: directory "/usr/src/goproxy/gopath/sr
c/golang.org/x/sys/windows/registry" is not using a known version control system
package golang.org/x/sys/unix: directory "/usr/src/goproxy/gopath/src/golang.org
/x/sys/unix" is not using a known version control system
github.com/juju/ratelimit (download)
github.com/miekg/dns (download)
root@343beab498c5:/usr/src/goproxy/goproxy# go build -v
_/usr/src/goproxy/goproxy/httpproxy/helpers
# _/usr/src/goproxy/goproxy/httpproxy/helpers
httpproxy/helpers/dialer2.go:200:35: not enough arguments in call to net.DialTCP
Context
        have (context.Context, string, nil, *net.TCPAddr)
        want (context.Context, string, *net.TCPAddr, *net.TCPAddr, net.ControlFu
nc)
httpproxy/helpers/dialer2.go:278:33: unknown field 'RequestConnectionIDTruncatio
n' in struct literal of type quic.Config
httpproxy/helpers/dialer2.go:295:36: unknown field 'RequestConnectionIDTruncatio
n' in struct literal of type quic.Config
httpproxy/helpers/dialer2.go:303:36: unknown field 'RequestConnectionIDTruncatio
n' in struct literal of type quic.Config
_/usr/src/goproxy/goproxy/httpproxy/proxy
# _/usr/src/goproxy/goproxy/httpproxy/proxy
httpproxy/proxy/quic.go:41:34: unknown field 'RequestConnectionIDTruncation' in
struct literal of type quic.Config
root@343beab498c5:/usr/src/goproxy/goproxy#

该如何处理呢?

Peytonlan commented 6 years ago
cd $GOPATH/src/github.com/phuslu/
rm -rf glog
git clone --depth 1 https://github.com/phuslu/glog

cd $BUILD_ROOT/goproxy/
grep RequestConnectionIDTruncation . -rl | xargs -I {} sed -i "s/RequestConnectionIDTruncation/RequestConnectionIDOmission/g" {}
grep DialTCPContext . -rl | xargs -I {} sed -i "s/DialTCPContext(ctx, network, nil, raddr)/DialTCPContext(ctx, network, nil, raddr, nil)/g" {}
GLingDroid commented 6 years ago

谢谢 Peytonlan 这两个问题已经解决 另外 is not using a known version control system 这个问题因为golang.org被墻,翻上去看好像指向文件的下载被转到github上了,网上搜到这个 https://golangtc.com/t/56f3c175b09ecc66b9000181 就是把 golang.org/x/ 替换成 github.com/golang/ ,把整个 crypto,net ,sys,text go get -u 下来,然后把整支拷贝到golang.org/x/下, 这样,编译能顺利通过,make一下就出来了。

但是,新的问题出来了,编译出来的比如windows下的程序出现错误异常。。。 log较长,贴图片看吧,唔

log

Peytonlan commented 6 years ago

抱歉, Windows几乎不用 Linux下的运行正常么 先确定下这个问题是否和平台有关

GLingDroid commented 6 years ago

没有linux,不过编了个android的试了下,情况是一样的

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x34 pc=0x2e9eb4]

goroutine 241 [running]:
github.com/phuslu/quic-go.(*streamFramer).maybePopNormalFrames(0x1246a900, 0x48e, 0x0, 0x0, 0x0, 0x0)
        /usr/src/goproxy/gopath/src/github.com/phuslu/quic-go/stream_framer.go:121 +0x1b4
github.com/phuslu/quic-go.(*streamFramer).PopStreamFrames(0x1246a900, 0x48e, 0x0, 0x0, 0x1, 0x11f1d650)
        /usr/src/goproxy/gopath/src/github.com/phuslu/quic-go/stream_framer.go:57 +0x70
github.com/phuslu/quic-go.(*packetPacker).composeNextPacket(0x12462c30, 0x499, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1200ed4c, 0x2e645c)
        /usr/src/goproxy/gopath/src/github.com/phuslu/quic-go/packet_packer.go:269 +0x320
github.com/phuslu/quic-go.(*packetPacker).PackPacket(0x12462c30, 0x0, 0x0, 0x0)
        /usr/src/goproxy/gopath/src/github.com/phuslu/quic-go/packet_packer.go:159 +0x170
github.com/phuslu/quic-go.(*session).sendPacket(0x11c85c00, 0xbe929701, 0x6b4ed659, 0x21)
        /usr/src/goproxy/gopath/src/github.com/phuslu/quic-go/session.go:826 +0x4c4
github.com/phuslu/quic-go.(*session).run(0x11c85c00, 0x0, 0x0)
        /usr/src/goproxy/gopath/src/github.com/phuslu/quic-go/session.go:434 +0xb8
github.com/phuslu/quic-go.(*client).establishSecureConnection.func1(0x123ec660, 0x120ccd28, 0x12500340)
        /usr/src/goproxy/gopath/src/github.com/phuslu/quic-go/client.go:216 +0x28
created by github.com/phuslu/quic-go.(*client).establishSecureConnection
       /usr/src/goproxy/gopath/src/github.com/phuslu/quic-go/client.go:215 +0x6c

可能原因是源码的改动部分,或者是引用的库quic-go版本问题导致有些变动? update:试了下tls,暂时没错误,那可能是引用库问题。

Peytonlan commented 6 years ago

空指针的问题quic-go上游已修复, 等 @phuslu 同步上游代码, 或者手工打补丁 https://github.com/lucas-clemente/quic-go/commit/0b9d805e1ac128e68029335ba96fadf812cd4be5

GLingDroid commented 6 years ago

Thank you @Peytonlan very much. Now I could build a working application under your help.

My intention is to try reducing the battery consumption on mobile devices.

By modifying following parameters I can manager extending the screen on time from 50% to 70% and extending the stand by time from 20% to 90%. gae.json: KeepAlive 5 ---> 240 Level 8 ---> 3 Timeout 5 ---> 240 IdleConnTimeout 5 ---> 240 Here Timeout is looking for new good_addr ,so enlarge it is reduing the dail frequency which is good for screen on time and bad for downloading and sometimes you need to wait minutes under normal using. IdleConnTimeout is reducing dial frequency in the background under system idle which related to stand by time. Keep enlarging these has nothing better but worse to normal use. So,I need two configuration file modified one for normal use and original one for download.

Even that compacts battery a lot.A normal use with SOT 10 hours reduced to 7 hours and even worse if you are moving that makes program dials more.

So,I looked into code to see whether there's some parameters can be modified. Here came with two proposals. One is modifying following parameters: gae.go line 309 KeepAliveTimeout 2 ---> 4 quic.go line 40 IdleTimeout 10 ---> to some minutes

Another better one is change the dealing policy but much harder. Only dial when it receives data request. Just acting like the program started but now every time and only time it received the request,and keep a short time(it said 4 minutes allowed for gae of every ip?) with the picked good_addr from every selection. A short time with full cpu power (even with every 4 minutes cycle) is much less battery consumption than keeping using data connection.

(Please excuse for sensitive reason that using english)

GLingDroid commented 6 years ago

grrr... I've made a misunderstanding about the parameter "EnableDeadProbe" and its description in ConfigIntroduce.md is obscure.

Having a clear view of time related codes is hard for me ,so it's confusing when adjusting some of them after some tries. So at the same time I'm seeking the second method that the protocol how it handles about sending and receiving datas. grrr...even harder. Back to method one ,I've notice "isNetAvailable" just a few lines up "Timeout()" in gae.go of line 390. It returns empty if false or dial roundtrip. A few lines up ,turns out the request I want.

Finally ,setting parameter "EnableDeadProbe" false in gae.json meets the "quiet at background dial at demond" and no need to change time related parameters. The test shows it right meet the battery saving demand.

Cheer to phuslu.

About another tip is about the download . If you feel unhappy with download using this product ,put // before "Default"- "RequestFilters" - "autorange" in httpproxy.json. Yea,just don't use that and using ADM for the downloading .

Peytonlan commented 6 years ago
EnableDeadProbe 这个配置参数的确需要留意, 应该默认设为 false 要好些