Coder Social home page Coder Social logo

cronet-go's Introduction

SagerNet for Android

API Releases License: GPL-3.0

The universal proxy toolchain for Android, written in Kotlin.


⚠️ The SagerNet app is looking for a new maintainer

Due to my physical condition, I may not be able to update SN / plugins in time.

I am looking for a new maintainer for the project. The new maintainer should have a track record of successfully maintaining an open-source project.

Potential maintainers can gain the required experience by contributing to this project. If you are interested, jump in and start contributing.

If you rely on the quality and ongoing maintenance of this package, please get involved by helping to maintain this package or finding people to help maintain the project.


Note for spammers: We never stop maintaining.


Documents

https://sagernet.org

Localization

Is SagerNet not in your language, or the translation is incorrect or incomplete? Get involved in the translations on our Weblate.

Translation status

Adding a new language

First and foremost, Android must already support the specific language and locale you want to add. We cannot work with languages that Android and the SDK do not support, the tools simply break down. Next, if you are considering adding a country-specific variant of a language (e.g. de-AT), first make sure that the main language is well maintained (e.g. de). Your contribution might be useful to more people if you contribute to the existing version of your language rather than the country-specific variant.

Anyone can create a new language via Weblate.

License

Copyright (C) 2021 by nekohasekai <[email protected]>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.

cronet-go's People

Contributors

nekohasekai avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

cronet-go's Issues

Problem with precompiling

I am on the linux64 platform and installed the version of go 1.18.1, but there is a problem with the precompile

INFO[0011] [prebuild]: >> /root/cronet-go/llvm/lib/clang/15.0.0/lib/x86_64-unknown-linux-gnu => llvm/lib/clang/15.0.0/lib/x86_64-cros-linux-gnu 
INFO[0011] [prebuild]: >> /root/cronet-go/llvm/bin/clang => llvm/bin/clang++ 
INFO[0011] [prebuild]: >> /root/cronet-go/llvm/bin/llvm-readobj => llvm/bin/llvm-readelf 
INFO[0011] [prebuild]: >> /root/cronet-go/llvm/bin/llvm-objcopy => llvm/bin/llvm-strip 
INFO[0011] [prebuild]: >> /root/cronet-go/llvm/bin/clang => llvm/bin/clang-cl 
INFO[0011] [prebuild]: >> /root/cronet-go/llvm/bin/lld => llvm/bin/ld.lld 
INFO[0011] [prebuild]: >> /root/cronet-go/llvm/bin/lld => llvm/bin/ld64.lld 
INFO[0011] [prebuild]: >> /root/cronet-go/llvm/bin/lld => llvm/bin/lld-link 
INFO[0011] [prebuild]: >> /root/cronet-go/llvm/bin/lld => llvm/bin/wasm-ld 
FATA[0011] [prebuild]: linux-x64 release not found in https://api.github.com/repos/klzgrad/naiveproxy/releases/67460277/assets 

找到关于padding填充的BUG

该项目似乎在padding填充出现问题。
首先第一处:https://github.com/SagerNet/cronet-go/blob/main/naive/main.go#L223 会引发网页空白,通过调试代码发现的。
发现该BUG是我编译项目后发现,代理页面访问空白。wireshark抓包发现请求可以到达服务器,但服务器似乎无法相应。于是我对项目进行debug,最后找到"Padding": generatePaddingHeader(),引起的,注释掉正常,但头部就没法填充了,作者能否找下原因所在?

第二处,代码的padding填充处理的无限递归问题,程序会突然崩溃!
https://github.com/SagerNet/cronet-go/blob/main/naive/main.go#L277-L282
无限递归处会引发程序崩溃,会出现Runtime: goroutine stack exceeds 1000000000-byte limit fatal error: stack overflow in ACM 溢出错误。并且填充后网页打开证书那些显示不安全,并且也是空白页面,可能填充逻辑需要改进。

作者能否修复下?

Compile from Windows (general question; looking for advice, willing to contribute)

As a full time Linux user, I can compile and use this library in my project just fine on my machine but I also have a developer in my team who is using Windows. I spun up a VM to try and build the project and was met with a nightmare of compilation issues trying to get CGO working on Windows.

I learned that CGO doesn't really support Windows all that well and only supports MINGW for now. So I installed the native compilation toolset from https://www.msys2.org/#installation. I have the following packages installed:

Click to expand
# pacman -Qe
base 2022.06-1
base-devel 2022.12-2
filesystem 2023.02.07-1
lld 11.0.0-5
mingw-w64-i686-binutils 2.41-2
mingw-w64-i686-crt-git 11.0.0.r239.g037ba0184-1
mingw-w64-i686-gcc 13.2.0-2
mingw-w64-i686-gcc-ada 13.2.0-2
mingw-w64-i686-gcc-fortran 13.2.0-2
mingw-w64-i686-gcc-libgfortran 13.2.0-2
mingw-w64-i686-gcc-libs 13.2.0-2
mingw-w64-i686-gcc-objc 13.2.0-2
mingw-w64-i686-gdb 13.2-3
mingw-w64-i686-gdb-multiarch 13.2-3
mingw-w64-i686-headers-git 11.0.0.r239.g037ba0184-1
mingw-w64-i686-libgccjit 13.2.0-2
mingw-w64-i686-libmangle-git 11.0.0.r239.g037ba0184-1
mingw-w64-i686-libwinpthread-git 11.0.0.r239.g037ba0184-1
mingw-w64-i686-make 4.4-2
mingw-w64-i686-pkgconf 1~2.0.3-2
mingw-w64-i686-tools-git 11.0.0.r239.g037ba0184-1
mingw-w64-i686-winpthreads-git 11.0.0.r239.g037ba0184-1
mingw-w64-i686-winstorecompat-git 11.0.0.r239.g037ba0184-1
mingw-w64-ucrt-x86_64-gcc 13.2.0-2
mingw-w64-x86_64-binutils 2.41-2
mingw-w64-x86_64-clang 17.0.2-2
mingw-w64-x86_64-crt-git 11.0.0.r239.g037ba0184-1
mingw-w64-x86_64-gcc 13.2.0-2
mingw-w64-x86_64-gcc-ada 13.2.0-2
mingw-w64-x86_64-gcc-fortran 13.2.0-2
mingw-w64-x86_64-gcc-libgfortran 13.2.0-2
mingw-w64-x86_64-gcc-libs 13.2.0-2
mingw-w64-x86_64-gcc-objc 13.2.0-2
mingw-w64-x86_64-gdb 13.2-3
mingw-w64-x86_64-gdb-multiarch 13.2-3
mingw-w64-x86_64-headers-git 11.0.0.r239.g037ba0184-1
mingw-w64-x86_64-libgccjit 13.2.0-2
mingw-w64-x86_64-libmangle-git 11.0.0.r239.g037ba0184-1
mingw-w64-x86_64-libwinpthread-git 11.0.0.r239.g037ba0184-1
mingw-w64-x86_64-make 4.4-2
mingw-w64-x86_64-pkgconf 1~2.0.3-2
mingw-w64-x86_64-tools-git 11.0.0.r239.g037ba0184-1
mingw-w64-x86_64-winpthreads-git 11.0.0.r239.g037ba0184-1
mingw-w64-x86_64-winstorecompat-git 11.0.0.r239.g037ba0184-1
msys2-runtime 3.4.9-2

And with the appropriate environment variables set:

go env -w CGO_ENABLED=1
go env -w CC=clang

I get these warnings and errors when I try to build an example with // #cgo LDFLAGS: -fuse-ld=lld -Wl,--build-id=sha1 -fPIC -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--icf=all -Wl,--color-diagnostics -Wl,-mllvm,-instcombine-lower-dbg-declare=0 -flto=thin -Wl,--thinlto-jobs=all -Wl,--thinlto-cache-dir=thinlto-cache -Wl,--thinlto-cache-policy=cache_size=10%:cache_size_bytes=40g:cache_size_files=100000 -Wl,-mllvm,-import-instr-limit=30 -fwhole-program-vtables -m64 -no-canonical-prefixes -rdynamic -Wl,-z,defs -Wl,--as-needed -Wl,--lto-O2 -pie -Wl,--disable-new-dtags -ldl -lpthread -lrt ./build/windows/amd64/cronet.dll -Wl,-rpath,$ORIGIN :

Click to expand
# CGO_LDFLAGS_ALLOW=.* go build ./cmd/example/main.go
# github.com/sagernet/cronet-go
In file included from _cgo_export.c:4:
cgo-gcc-export-header-prolog:49:35: warning: redeclaration of 'cronetBidirectionalStreamOnStreamReady' should not add 'dllexport' attribute [-Wdll-attribute-on-redeclaration]
bidirectional_stream_impl.go:7:14: note: previous declaration is here
cgo-gcc-export-header-prolog:50:35: warning: redeclaration of 'cronetBidirectionalStreamOnResponseHeadersReceived' should not add 'dllexport' attribute [-Wdll-attribute-on-redeclaration]
bidirectional_stream_impl.go:8:14: note: previous declaration is here
cgo-gcc-export-header-prolog:51:35: warning: redeclaration of 'cronetBidirectionalStreamOnReadCompleted' should not add 'dllexport' attribute [-Wdll-attribute-on-redeclaration]
bidirectional_stream_impl.go:9:14: note: previous declaration is here
cgo-gcc-export-header-prolog:52:35: warning: redeclaration of 'cronetBidirectionalStreamOnWriteCompleted' should not add 'dllexport' attribute [-Wdll-attribute-on-redeclaration]
bidirectional_stream_impl.go:10:14: note: previous declaration is here
cgo-gcc-export-header-prolog:53:35: warning: redeclaration of 'cronetBidirectionalStreamOnResponseTrailersReceived' should not add 'dllexport' attribute [-Wdll-attribute-on-redeclaration]
bidirectional_stream_impl.go:11:14: note: previous declaration is here
cgo-gcc-export-header-prolog:54:35: warning: redeclaration of 'cronetBidirectionalStreamOnSucceed' should not add 'dllexport' attribute [-Wdll-attribute-on-redeclaration]
bidirectional_stream_impl.go:12:14: note: previous declaration is here
cgo-gcc-export-header-prolog:55:35: warning: redeclaration of 'cronetBidirectionalStreamOnFailed' should not add 'dllexport' attribute [-Wdll-attribute-on-redeclaration]
bidirectional_stream_impl.go:13:14: note: previous declaration is here
cgo-gcc-export-header-prolog:56:35: warning: redeclaration of 'cronetBidirectionalStreamOnCanceled' should not add 'dllexport' attribute [-Wdll-attribute-on-redeclaration]
bidirectional_stream_impl.go:14:14: note: previous declaration is here
cgo-gcc-export-header-prolog:57:35: warning: redeclaration of 'cronetBufferCallbackOnDestroy' should not add 'dllexport' attribute [-Wdll-attribute-on-redeclaration]
buffer_callback_impl.go:6:14: note: previous declaration is here
cgo-gcc-export-header-prolog:58:35: warning: redeclaration of 'cronetExecutorExecute' should not add 'dllexport' attribute [-Wdll-attribute-on-redeclaration]
executor_impl.go:6:14: note: previous declaration is here
cgo-gcc-export-header-prolog:59:38: warning: redeclaration of 'cronetUploadDataProviderGetLength' should not add 'dllexport' attribute [-Wdll-attribute-on-redeclaration]
upload_data_provider_impl.go:6:17: note: previous declaration is here
cgo-gcc-export-header-prolog:60:35: warning: redeclaration of 'cronetUploadDataProviderRead' should not add 'dllexport' attribute [-Wdll-attribute-on-redeclaration]
upload_data_provider_impl.go:7:14: note: previous declaration is here
cgo-gcc-export-header-prolog:61:35: warning: redeclaration of 'cronetUploadDataProviderRewind' should not add 'dllexport' attribute [-Wdll-attribute-on-redeclaration]
upload_data_provider_impl.go:8:14: note: previous declaration is here
cgo-gcc-export-header-prolog:62:35: warning: redeclaration of 'cronetUploadDataProviderClose' should not add 'dllexport' attribute [-Wdll-attribute-on-redeclaration]
upload_data_provider_impl.go:9:14: note: previous declaration is here
cgo-gcc-export-header-prolog:63:35: warning: redeclaration of 'cronetURLRequestCallbackOnRedirectReceived' should not add 'dllexport' attribute [-Wdll-attribute-on-redeclaration]
url_request_callback_impl.go:6:14: note: previous declaration is here
cgo-gcc-export-header-prolog:64:35: warning: redeclaration of 'cronetURLRequestCallbackOnResponseStarted' should not add 'dllexport' attribute [-Wdll-attribute-on-redeclaration]
url_request_callback_impl.go:7:14: note: previous declaration is here
cgo-gcc-export-header-prolog:65:35: warning: redeclaration of 'cronetURLRequestCallbackOnReadCompleted' should not add 'dllexport' attribute [-Wdll-attribute-on-redeclaration]
url_request_callback_impl.go:8:14: note: previous declaration is here
cgo-gcc-export-header-prolog:66:35: warning: redeclaration of 'cronetURLRequestCallbackOnSucceeded' should not add 'dllexport' attribute [-Wdll-attribute-on-redeclaration]
url_request_callback_impl.go:9:14: note: previous declaration is here
cgo-gcc-export-header-prolog:67:35: warning: redeclaration of 'cronetURLRequestCallbackOnFailed' should not add 'dllexport' attribute [-Wdll-attribute-on-redeclaration]
url_request_callback_impl.go:10:14: note: previous declaration is here
cgo-gcc-export-header-prolog:68:35: warning: redeclaration of 'cronetURLRequestCallbackOnCanceled' should not add 'dllexport' attribute [-Wdll-attribute-on-redeclaration]
url_request_callback_impl.go:11:14: note: previous declaration is here
cgo-gcc-export-header-prolog:69:35: warning: redeclaration of 'cronetURLRequestFinishedInfoListenerOnRequestFinished' should not add 'dllexport' attribute [-Wdll-attribute-on-redeclaration]
url_request_finished_info_impl.go:6:14: note: previous declaration is here
cgo-gcc-export-header-prolog:70:35: warning: redeclaration of 'cronetURLRequestStatusListenerOnStatus' should not add 'dllexport' attribute [-Wdll-attribute-on-redeclaration]
url_request_status_listener_impl.go:6:14: note: previous declaration is here
# command-line-arguments
C:\Program Files\Go\pkg\tool\windows_amd64\link.exe: running clang failed: exit status 1
clang: warning: argument unused during compilation: '-rdynamic' [-Wunused-command-line-argument]
clang: warning: argument unused during compilation: '-pie' [-Wunused-command-line-argument]
clang: warning: argument unused during compilation: '-rdynamic' [-Wunused-command-line-argument]
clang: warning: argument unused during compilation: '-pie' [-Wunused-command-line-argument]
lld: error: unknown argument: --build-id=sha1
lld: error: unknown argument: -z
lld: error: unknown argument: -z
lld: error: unknown argument: -z
lld: error: unknown argument: --color-diagnostics
lld: error: unknown argument: --thinlto-jobs=all
lld: error: unknown argument: --thinlto-cache-policy=cache_size=10%:cache_size_bytes=40g:cache_size_files=100000
lld: error: unknown argument: -z
lld: error: unknown argument: --as-needed
lld: error: unknown argument: --lto-O2
lld: error: unknown argument: --disable-new-dtags
lld: error: unknown argument: -rpath
lld: error: unknown argument: --build-id=sha1
lld: error: unknown argument: -z
lld: error: unknown argument: -z
lld: error: unknown argument: -z
lld: error: unknown argument: --color-diagnostics
lld: error: unknown argument: --thinlto-jobs=all
lld: error: unknown argument: --thinlto-cache-policy=cache_size=10%:cache_size_bytes=40g:cache_size_files=100000
lld: error: unknown argument: -z
lld: error: too many errors emitted, stopping now
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I hope I didn't forget to mention anything because I tried a lot of things. Let me know and I'll dig for it.

Do you have an idea how one could get this setup working?

Another approach I haven't tried yet is cross-compilation from a Linux machine to Windows, but the problem is that then my colleague would have to switch to Linux which he probably doesn't want (yet?) 😅 And if WSL works too then I'm not sure how/if debugging would work in that case.

Thanks a lot for your help!

Panic when CheckRedirect is false

Run at Linux docker image golang:1.18.3

cmd/build/a.go

package main

import (
	"github.com/sagernet/cronet-go"
	"net/http"
	"os"
	
)

func main() {
	client := &http.Client{
		Transport: &cronet.RoundTripper{
			CheckRedirect: func(newLocationUrl string) bool {
				return false
			},
		},
	}
	response, _ := client.Get("https://httpbin.org/status/302")
	response.Write(os.Stderr)
	response.Body.Close()

}

Error stack after running:

root@80b5520f4a27:/code/cronet-go# 
root@80b5520f4a27:/code/cronet-go# 
root@80b5520f4a27:/code/cronet-go# ./main  cmd/build/a.go
HOSTNAME=80b5520f4a27
PWD=/code/cronet-go
HOME=/root
GOLANG_VERSION=1.18.3
TERM=xterm
SHLVL=1
PATH=/code/cronet-go/llvm/bin:/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
GOPATH=/go
OLDPWD=/go
_=./main
CGO_LDFLAGS=-pie -I /code/cronet-go --sysroot=/code/cronet-go/sysroot -fuse-ld=lld -m64
CGO_CFLAGS=-I /code/cronet-go --sysroot=/code/cronet-go/sysroot -m64 -march=x86-64 -msse3
CC=clang
CGO_ENABLED=1
CGO_LDFLAGS_ALLOW=.*
root@80b5520f4a27:/code/cronet-go# 
root@80b5520f4a27:/code/cronet-go# 
root@80b5520f4a27:/code/cronet-go# ./a 
SIGTRAP: trace trap
PC=0x7f2f61201f03 m=5 sigcode=128
signal arrived during cgo execution

goroutine 1 [syscall]:
runtime.cgocall(0x55641c3e1740, 0xc000119a88)
	/usr/local/go/src/runtime/cgocall.go:157 +0x5c fp=0xc000119a60 sp=0xc000119a28 pc=0x55641c1c25dc
github.com/sagernet/cronet-go._Cfunc_Cronet_UrlRequest_Read(0x16c8002382a0, 0x16c80023e070)
	_cgo_gotypes.go:2553 +0x50 fp=0xc000119a88 sp=0xc000119a60 pc=0x55641c3d8810
github.com/sagernet/cronet-go.URLRequest.Read.func1({0xc000119af0?}, {0xc000119ae8?})
	/code/cronet-go/url_request.go:73 +0x70 fp=0xc000119ac8 sp=0xc000119a88 pc=0x55641c3dc490
github.com/sagernet/cronet-go.URLRequest.Read({0x0?}, {0xc000152000?})
	/code/cronet-go/url_request.go:73 +0x19 fp=0xc000119ae8 sp=0xc000119ac8 pc=0x55641c3dc3d9
github.com/sagernet/cronet-go.(*urlResponse).Read(0xc00014c000, {0xc000152000, 0x800, 0x2000})
	/code/cronet-go/transport.go:184 +0x128 fp=0xc000119b78 sp=0xc000119ae8 pc=0x55641c3d5588
io.(*LimitedReader).Read(0xc00000e138, {0xc000152000?, 0x1d?, 0xc000119c70?})
	/usr/local/go/src/io/io.go:476 +0x45 fp=0xc000119ba8 sp=0xc000119b78 pc=0x55641c240ea5
io.discard.ReadFrom({}, {0x55641c44a768, 0xc00000e138})
	/usr/local/go/src/io/io.go:610 +0x72 fp=0xc000119c00 sp=0xc000119ba8 pc=0x55641c241072
io.(*discard).ReadFrom(0x641c4073e0?, {0x55641c44a768?, 0xc00000e138?})
	<autogenerated>:1 +0x37 fp=0xc000119c20 sp=0xc000119c00 pc=0x55641c241757
io.copyBuffer({0x55641c44af08, 0x55641c5e7700}, {0x55641c44a768, 0xc00000e138}, {0x0, 0x0, 0x0})
	/usr/local/go/src/io/io.go:412 +0x14b fp=0xc000119ca0 sp=0xc000119c20 pc=0x55641c240c8b
io.Copy(...)
	/usr/local/go/src/io/io.go:385
io.CopyN({0x55641c44af08, 0x55641c5e7700}, {0x7f2f376cb848?, 0xc00014c000}, 0x800)
	/usr/local/go/src/io/io.go:361 +0x9a fp=0xc000119cf0 sp=0xc000119ca0 pc=0x55641c240aba
net/http.(*Client).do(0xc00006edb0, 0xc00014a100)
	/usr/local/go/src/net/http/client.go:707 +0x81d fp=0xc000119ef0 sp=0xc000119cf0 pc=0x55641c39559d
net/http.(*Client).Do(...)
	/usr/local/go/src/net/http/client.go:593
net/http.(*Client).Get(0x55641c3e2f10?, {0x55641c14f29c?, 0x0?})
	/usr/local/go/src/net/http/client.go:480 +0x6a fp=0xc000119f48 sp=0xc000119ef0 pc=0x55641c394aea
main.main()
	/code/cronet-go/cmd/build/a.go:18 +0x85 fp=0xc000119f80 sp=0xc000119f48 pc=0x55641c3de105
runtime.main()
	/usr/local/go/src/runtime/proc.go:250 +0x213 fp=0xc000119fe0 sp=0xc000119f80 pc=0x55641c1f4d33
runtime.goexit()
	/usr/local/go/src/runtime/asm_amd64.s:1571 +0x1 fp=0xc000119fe8 sp=0xc000119fe0 pc=0x55641c220b61

rax    0xffffff2f
rbx    0x16c8002382a0
rcx    0x0
rdx    0x1
rdi    0x16c8002180c0
rsi    0xffffff2f
rbp    0x7f2f38706d50
rsp    0x7f2f38706d18
r8     0xc000080000
r9     0x0
r10    0x8
r11    0x10
r12    0xc0000184a0
r13    0x0
r14    0x16c8002382b0
r15    0x16c80023e070
rip    0x7f2f61201f03
rflags 0x202
cs     0x33
fs     0x0
gs     0x0
root@80b5520f4a27:/code/cronet-go# 

Problems running on openwrt

I just saw that you have an update, but it seems that there are still some problems on openwrt, such as the problem that it can easily cause the exit

goroutine 284 [select]:
github.com/sagernet/cronet-go.(*BidirectionalConn).Read(0x400008e9c0, {0x40003e8400, 0x3, 0x7c00})
        /root/cronet-go/bidirectional_conn.go:72 +0xac
io.ReadAtLeast({0x7f8ef91d18, 0x400008e9c0}, {0x40003e8400, 0x3, 0x7c00}, 0x3)
        /usr/local/go/src/io/io.go:331 +0xa4
io.ReadFull(...)
        /usr/local/go/src/io/io.go:350
main.(*PaddingConn).Read(0x400009ae10, {0x40003e8400, 0x7c00, 0x7c00})
        /root/cronet-go/naive/main.go:297 +0x12c
github.com/sagernet/sing/common/bufio.(*ExtendedReaderWrapper).ReadBuffer(0x7fb5edb108?, 0x400009af30)
        /root/go/pkg/mod/github.com/sagernet/[email protected]/common/bufio/conn.go:430 +0x5c
github.com/sagernet/sing/common/bufio.CopyExtendedBuffer({0x5563ed9fd8, 0x400020e7b0}, {0x5563ed9fb0, 0x400020e7c0}, 0x400009af30)
        /root/go/pkg/mod/github.com/sagernet/[email protected]/common/bufio/conn.go:74 +0xf0
github.com/sagernet/sing/common/bufio.CopyExtended({0x5563ed9fd8?, 0x400020e7b0}, {0x5563ed9fb0?, 0x400020e7c0})
        /root/go/pkg/mod/github.com/sagernet/[email protected]/common/bufio/conn.go:66 +0x18c
github.com/sagernet/sing/common/bufio.Copy({0x5563ed9240, 0x400020e7a0}, {0x7f8ef902f8?, 0x400009ae10?})
        /root/go/pkg/mod/github.com/sagernet/[email protected]/common/bufio/conn.go:51 +0x270
github.com/sagernet/sing/common/bufio.(*readOnlyReader).WriteTo(0x4000042538?, {0x5563ed9240?, 0x400020e7a0?})
        /root/go/pkg/mod/github.com/sagernet/[email protected]/common/bufio/conn.go:23 +0x3c
io.copyBuffer({0x5563ed9240, 0x400020e7a0}, {0x5563ed8780, 0x400020e790}, {0x0, 0x0, 0x0})
        /usr/local/go/src/io/io.go:408 +0x128
io.Copy(...)
        /usr/local/go/src/io/io.go:385
net.genericReadFrom({0x5563ed8a00?, 0x400021e078?}, {0x5563ed8780, 0x400020e790})
        /usr/local/go/src/net/net.go:662 +0x6c
net.(*TCPConn).readFrom(0x400021e078, {0x5563ed8780, 0x400020e790})
        /usr/local/go/src/net/tcpsock_posix.go:54 +0x74
net.(*TCPConn).ReadFrom(0x400021e078, {0x5563ed8780?, 0x400020e790?})
        /usr/local/go/src/net/tcpsock.go:130 +0x34
github.com/sagernet/sing/common/bufio.Copy({0x5563ed8a00, 0x400021e078}, {0x7f8ef902f8?, 0x400009ae10?})
        /root/go/pkg/mod/github.com/sagernet/[email protected]/common/bufio/conn.go:49 +0x188
github.com/sagernet/sing/common/bufio.CopyConn.func2()
        /root/go/pkg/mod/github.com/sagernet/[email protected]/common/bufio/conn.go:131 +0xf4
github.com/sagernet/sing/common/task.Run.func1()
        /root/go/pkg/mod/github.com/sagernet/[email protected]/common/task/task.go:18 +0x48
created by github.com/sagernet/sing/common/task.Run
        /root/go/pkg/mod/github.com/sagernet/[email protected]/common/task/task.go:17 +0xf4

goroutine 178 [IO wait]:
internal/poll.runtime_pollWait(0x7f8f1614a8, 0x72)
        /usr/local/go/src/runtime/netpoll.go:302 +0xa4
internal/poll.(*pollDesc).wait(0x400021c780?, 0x40001aa549?, 0x0)
        /usr/local/go/src/internal/poll/fd_poll_runtime.go:83 +0x2c
internal/poll.(*pollDesc).waitRead(...)
        /usr/local/go/src/internal/poll/fd_poll_runtime.go:88
internal/poll.(*FD).Read(0x400021c780, {0x40001aa549, 0x1, 0x1})
        /usr/local/go/src/internal/poll/fd_unix.go:167 +0x1e4
net.(*netFD).Read(0x400021c780, {0x40001aa549?, 0x40001f75e8?, 0x5563b55844?})
        /usr/local/go/src/net/fd_posix.go:55 +0x2c
net.(*conn).Read(0x400021e0c8, {0x40001aa549?, 0x40001f7618?, 0x5563db15d8?})
        /usr/local/go/src/net/net.go:183 +0x38
io.ReadAtLeast({0x5563ed89c0, 0x400021e0c8}, {0x40001aa549, 0x1, 0x1}, 0x1)
        /usr/local/go/src/io/io.go:331 +0xa4
io.ReadFull(...)
        /usr/local/go/src/io/io.go:350
github.com/sagernet/sing/common/rw.ReadByte({0x5563ed89c0, 0x400021e0c8})
        /root/go/pkg/mod/github.com/sagernet/[email protected]/common/rw/read.go:22 +0x68
github.com/sagernet/sing/protocol/socks/socks4.readString({0x5563ed89c0, 0x400021e0c8})
        /root/go/pkg/mod/github.com/sagernet/[email protected]/protocol/socks/socks4/protocol.go:160 +0x4c
github.com/sagernet/sing/protocol/socks/socks4.ReadRequest0({0x5563ed89c0, 0x400021e0c8})
        /root/go/pkg/mod/github.com/sagernet/[email protected]/protocol/socks/socks4/protocol.go:67 +0x184
github.com/sagernet/sing/protocol/socks.HandleConnection0({0x5563edb730?, 0x4000024080}, {0x5563edcc28?, 0x400021e0c8}, 0xe8?, {0x0?, 0x0?}, {0x7f8ef90028?, 0x40001010b0}, {{0x5563a95220, ...}, ...})
        /root/go/pkg/mod/github.com/sagernet/[email protected]/protocol/socks/handshake.go:108 +0x10c
github.com/sagernet/sing/transport/mixed.(*Listener).NewConnection(0x4000020230, {0x5563edb730, 0x4000024080}, {0x5563edcc28, 0x400021e0c8?}, {{0x5563a95220, 0x3}, {{{0x0, 0xffffc0a81ffe}, 0x400000e030}, ...}, ...})
        /root/go/pkg/mod/github.com/sagernet/[email protected]/transport/mixed/listener.go:65 +0x998
github.com/sagernet/sing/transport/tcp.(*Listener).loop.func1()
        /root/go/pkg/mod/github.com/sagernet/[email protected]/transport/tcp/listener.go:97 +0xa8
created by github.com/sagernet/sing/transport/tcp.(*Listener).loop
        /root/go/pkg/mod/github.com/sagernet/[email protected]/transport/tcp/listener.go:95 +0x30

failed to go run naive/main.go

How can I solve this problem?

$ go run naive/main.go
# github.com/sagernet/cronet-go
/home/linuxbrew/.linuxbrew/bin/ld: unrecognised emulation mode: llvm

Finish naive command line processing

cronet-go/naive/main.go

Lines 69 to 73 in b2643a8

// command.Flags().BoolVar(&config.EnableRedir, "enable-redir", false, "enable redir support (linux only)")
// command.Flags().IntVar(&config.InsecureConcurrency, "insecure-concurrency=", 1, "use N connections, insecure")
command.Flags().StringVar(&config.ExtraHeaders, "extra-headers", "", "extra headers split by CRLF")
command.Flags().StringVar(&config.HostResolverRules, "host-resolver-rules", "", "resolver rules")
// command.Flags().StringVar(&config.ResolverRange, "resolver-range", "", "resolver-range")

  • Remove support of resolver-range. It's related to a fake DNS resolver. I no longer consider fake DNS a good idea.
  • Add insecure-concurrency using -network-isolation-key header.

About when to call destroy()

Sorry not familiar with c/c++.

When do I need to call destroy() for a cronet-created structure (like RequestFinishedInfo), or not? And what about incoming parameters like HttpHeader?

@klzgrad

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.