Closed CaiMiao closed 4 years ago
I translate your words. I agree, I want to host v2ray proxy and set up OpenVPN over http proxy on the same device.
But, technically speaking, don’t these apps on iOS have v2ray-core compiled? Otherwise how can they use Vmess on iOS?
@arinc9 Yes those apps have their v2ray core compiled (and potentional slim), but they are published as a valid iOS app which means they have to be restriced by iOS's backgrounding policy, and that means an unstable tunnel (always crash). If we can make it work as a jailbroken daemon, it would be far more stable than any app you use.
That makes sense. I hope we can get something like that.
Since what these ios developers' care is selling there apps, I beleive no one would provide this for now.
Since what these ios developers' care is selling there apps, I beleive no one would provide this for now.
I don't learn much about CI services but they do have macOS+xcode VMs for compiling. All we need is a script and a xcode config targeting iOS.
I got a hackintosh with Xcode. Let me give this a try.
Since what these ios developers' care is selling there apps, I beleive no one would provide this for now.
I don't learn much about CI services but they do have macOS+xcode VMs for compiling. All we need is a script and a xcode config targeting iOS.
the gomobile do provide build options for ios framework. https://github.com/Tai7sy/v2ray_mobile_lib/blob/7636d71dade56bddc5ab7f5716fe784efdd20237/Makefile#L30 copy from v2rayNG, change a lot for a easier build, and ios untested
I'm not familliar with Golang but I doubt we need this for creating CLI tool
It probably doesn't support latest Xcode. The project was last updated in 2015.
Since what these ios developers' care is selling there apps, I beleive no one would provide this for now.
I don't learn much about CI services but they do have macOS+xcode VMs for compiling. All we need is a script and a xcode config targeting iOS.
the gomobile do provide build options for ios framework. https://github.com/Tai7sy/v2ray_mobile_lib/blob/7636d71dade56bddc5ab7f5716fe784efdd20237/Makefile#L30 copy from v2rayNG, change a lot for a easier build, and ios untested
OK first of all, let's talk about CaiMiao's find. v2ray_mobile_lib is a library of v2ray, meaning we can link this library (called framework) for our app to use v2ray. So, this is not really a jailbreak project, meaning we don't need any other tool to succesfully compile our app on Xcode.
P.S. We've got nothing to do with Theos either.
Compiling the library for iOS is a bit tricky. First we need to export path to iOS SDK which is in some directory in Xcode.app (that's easy) and also the http proxy. Instead of "export"ing before "make"ing the project, I'd rather add these under build_ios in the makefile. That way, just running "make init_env && make build_ios" will be enough. If everything goes smooth, we'll get our framework to link and work on for our own app. Sad fact is, I've got no idea how to code so I'd completely stay out of developing an app but rather make a CLI executable to run.
Any ideas of how we'll turn a framework into an executable are welcome.
Sorry, I just got the time to look over xgo and running the Docker container. You are right indeed! I've successfully compiled v2ray and v2ctl for iphoneos arm64! I'm going to put in my config.json and see if it actually works.
Cool, Would you like to write a guide for this
Sure, that's the plan for today.
I managed to use the Github Actions here but didn't seems producing files. Maybe it's that author's issue.
Clean setup from AWS EC2 instance with Ubuntu 18.04 LTS
cd ~/
sudo -s
# install env
snap install go --classic
snap install docker
# install xgo
docker pull karalabe/xgo-latest
go get github.com/karalabe/xgo
# build v2ray
./go/bin/xgo -v -x -ldflags="-s -w" -out v2ray -pkg main --targets=ios/* github.com/v2ray/v2ray-core
# build v2ctl
./go/bin/xgo -v -x -tags="confonly" -ldflags="-s -w" -out v2ctl -pkg infra/control/main --targets=ios/* github.com/v2ray/v2ray-core
Commands for general Linux (Alpine Linux in Virtualbox in my case):
# prepare working Docker environment yourself
# open Docker container
docker pull karalabe/xgo-latest
docker run -dit --entrypoint="bash" --name="xgo" karalabe/xgo-latest
docker exec -it xgo bash
# export proxies here if you encounter any network issues you know why
# export http_proxy=http://10.0.2.2:10809 && export https_proxy=http://10.0.2.2:10809
# build v2ray
./go/bin/xgo -v -x -ldflags="-s -w" -out v2ray -pkg main --targets=ios/* github.com/v2ray/v2ray-core
# build v2ctl
./go/bin/xgo -v -x -tags="confonly" -ldflags="-s -w" -out v2ctl -pkg infra/control/main --targets=ios/* github.com/v2ray/v2ray-core
# get out and copy binaries out
exit
docker cp xgo:build/ ./
docker stop xgo
ls -al build/
each produces 3 binaries:
<out>-ios-5.0-arm64
<out>-ios-5.0-armv7
<out>-ios-5.0-framework/
binaries not confirmed if working yet, need wait 4 test
Good to go, codesign need if trying to run outside of usr/local/bin
(for modern iOS, may vary by jb).
Working copy of geoip.dat
/geosite.dat
is also needed for routing fuction.
Good job, I will add it to the manual later
Thanks for the simple method of the compiling process @CaiMiao. Don't you also need "docker cp" to copy the binaries out of the container?
By the way I have confirmed that v2ray runs just fine on my iPhone X, iOS 13.3.1.
There're a few things to figure out to automatically run v2ray_core without the need to keep a terminal app open in the background for the server to keep running. Creating a launchdaemon for this is quite easy and we can launch and kill the service by simply;
launchctl load /Library/LaunchDaemons/v2ray.plist
launchctl unload /Library/LaunchDaemons/v2ray.plist
The most important thing would be to turn it into an app like v2rayNG on Android. We could configure the config.json, launch or kill the service with ease and see the logs it produces.
P.S. It would be great if @CaiMiao could help me making a complete step-by-step tutorial to compile the binaries, put them on the device, create a launchdaemon and run the service.
Thanks for the simple method of the compiling process @CaiMiao. Don't you also need "docker cp" to copy the binaries out of the container?
@arinc9
the xgo
wrapper running outside of docker would just copy out the binaries automatically.
for me i have to copy binaries to /usr/local/bin
to make it run or it would throw Killed: 9
, maybe i didn't pseudo sign them. also struggling mysterious config problems...
currently my workaround for backgrounding it is using screen
, old school trick.
You need to add the proper entitlements for it to work outside:
ldid -S/usr/share/entitlements/ld64.xml <binary>
Depending on your jailbreak, /usr/share/entitlements/ld64.xml
might not exist.
I don't understand the error on your side, which port and proxy (http - socks) are you using?
Edit: what is screen
by the way?
I don't understand the error on your side, which port and proxy (http - socks) are you using?
Edit: what is
screen
by the way?
I figured it out with socks/pac, it's now ok to go.
I would keep this issue open until iphoneos builds are officially provided.
And it would be better if unrecognized import path
can get supressed.
get "v2ray.com/core/transport/internet/udp": verifying non-authoritative meta tag
package v2ray.com/core/transport/internet/udp: unrecognized import path "v2ray.com/core/transport/internet/udp" (fetching v2ray.com/core: Get http://www.v2ray.com/core/?go-get=1: redirected from secure URL https://v2ray.com/core?go-get=1 to insecure URL http://www.v2ray.com/core/?go-get=1)
screen
looks very interesting. Any sample code you use to launch v2ray?
just use screen
and then you are in a shell session. as far as you don't manually destory it (e.g.exit
), when dettaching or unexpected disconnecting, anything running would just keep as-is . Useful for maintaining systems from unstable network in production.
從我的 iPad 傳送
arinc9 notifications@github.com<mailto:notifications@github.com> 於 2020年2月19日 下午9:40 寫道:
screen looks very interesting. Any sample code you use to launch v2ray?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/v2ray/v2ray-core/issues/2192?email_source=notifications&email_token=ABDM5YYNU5HJU3TBWFZJB33RDUZE5A5CNFSM4KLWG23KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEMH4FVA#issuecomment-588235476, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABDM5YZMGG3VSC7IY4IHEL3RDUZE5ANCNFSM4KLWG23A.
I have figured these example commands to launch and kill v2ray-core with screen.
v2ray screen launch: screen -dmS v2ray /var/mobile/v2ray/v2ray
v2ray screen kill: ps -ax | grep v2ray kill (pid)
Killing v2ray also ends screen session so it’s quite practical.
I don’t plan on working further on v2ray-core for iOS. I’m leaving everything to @CaiMiao.
This issue is stale because it has been open 120 days with no activity. Remove stale label or comment or this will be closed in 5 days
@CaiMiao
Clean setup from AWS EC2 instance with Ubuntu 18.04 LTS
cd ~/ sudo -s # install env snap install go --classic snap install docker # install xgo docker pull karalabe/xgo-latest go get github.com/karalabe/xgo # build v2ray ./go/bin/xgo -v -x -ldflags="-s -w" -out v2ray -pkg main --targets=ios/* github.com/v2ray/v2ray-core # build v2ctl ./go/bin/xgo -v -x -tags="confonly" -ldflags="-s -w" -out v2ctl -pkg infra/control/main --targets=ios/* github.com/v2ray/v2ray-core
Commands for general Linux (Alpine Linux in Virtualbox in my case):
# prepare working Docker environment yourself # open Docker container docker pull karalabe/xgo-latest docker run -dit --entrypoint="bash" --name="xgo" karalabe/xgo-latest docker exec -it xgo bash # export proxies here if you encounter any network issues you know why # export http_proxy=http://10.0.2.2:10809 && export https_proxy=http://10.0.2.2:10809 # build v2ray ./go/bin/xgo -v -x -ldflags="-s -w" -out v2ray -pkg main --targets=ios/* github.com/v2ray/v2ray-core # build v2ctl ./go/bin/xgo -v -x -tags="confonly" -ldflags="-s -w" -out v2ctl -pkg infra/control/main --targets=ios/* github.com/v2ray/v2ray-core # get out and copy binaries out exit docker cp xgo:build/ ./ docker stop xgo ls -al build/
each produces 3 binaries:
<out>-ios-5.0-arm64 <out>-ios-5.0-armv7 <out>-ios-5.0-framework/
~binaries not confirmed if working yet, need wait 4 test~
Good to go, codesign need if trying to run outside of
usr/local/bin
(for modern iOS, may vary by jb). Working copy ofgeoip.dat
/geosite.dat
is also needed for routing fuction.
Dear friend.
Would you mind sharing some tips to use the v2ray framework in iOS? we want to integrate it into App to connect to the v2ray server. But I have no idea how to do that.
I have mentioned that there are v2ray binary files above, but I suppose we cannot use them directly in App unless the devices are jailbreak, right?
Thank you very much.
yes they are jailbreak only
在 2021年5月26日,18:41,Frank Lee @.***> 写道:
@CaiMiaohttps://github.com/CaiMiao
Clean setup from AWS EC2 instance with Ubuntu 18.04 LTS
cd ~/ sudo -s
snap install go --classic snap install docker
docker pull karalabe/xgo-latest go get github.com/karalabe/xgo
./go/bin/xgo -v -x -ldflags="-s -w" -out v2ray -pkg main --targets=ios/* github.com/v2ray/v2ray-core
./go/bin/xgo -v -x -tags="confonly" -ldflags="-s -w" -out v2ctl -pkg infra/control/main --targets=ios/* github.com/v2ray/v2ray-core
Commands for general Linux (Alpine Linux in Virtualbox in my case):
docker pull karalabe/xgo-latest docker run -dit --entrypoint="bash" --name="xgo" karalabe/xgo-latest docker exec -it xgo bash
./go/bin/xgo -v -x -ldflags="-s -w" -out v2ray -pkg main --targets=ios/* github.com/v2ray/v2ray-core
./go/bin/xgo -v -x -tags="confonly" -ldflags="-s -w" -out v2ctl -pkg infra/control/main --targets=ios/* github.com/v2ray/v2ray-core
exit docker cp xgo:build/ ./ docker stop xgo ls -al build/
each produces 3 binaries:
@CaiMiao So what can I do with the V2ray Framwork? any ideas ?
@CaiMiao @arinc9
Did you see these errors below before? how to fix it?
OS: LSB Version: core-9.20170808ubuntu1-noarch:security-9.20170808ubuntu1-noarch Distributor ID: Ubuntu Description: Ubuntu 18.04.5 LTS Release: 18.04 Codename: bionic
GO: go version go1.14.15 linux/amd64
ENV: GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/root/.cache/go-build" GOENV="/root/.config/go/env" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOINSECURE="" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPATH="/root/go" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/root/go1.14" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/root/go1.14/pkg/tool/linux_amd64" GCCGO="gccgo" AR="ar" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build930548031=/tmp/go-build -gno-record-gcc-switches"
ERROR Message:
Before
cd /go/src/github.com/v2ray/v2ray-core/infra/conf/json /usr/local/go/pkg/tool/linux_amd64/compile -o $WORK/b357/pkg.a -trimpath "$WORK/b357=>" -shared -p v2ray.com/core/infra/conf/json -complete -buildid 8hIAMuZoltgPiNmPtNmT/8hIAMuZoltgPiNmPtNmT -goversion go1.13.4 -D "" -importcfg $WORK/b357/importcfg -pack ./reader.go /usr/local/go/pkg/tool/linux_amd64/buildid -w $WORK/b357/pkg.a # internal cp $WORK/b357/pkg.a /root/.cache/go-build/10/107fbdee15682f467acd34ee0e70c38ec34ae3ea2c4ecb7cbca0f906ee70aebf-d # internal /usr/local/go/pkg/tool/linux_amd64/buildid -w $WORK/b348/pkg.a # internal cp $WORK/b348/pkg.a /root/.cache/go-build/0f/0f066ee09984c8a5a23f6b1967fe6f516245c4d3cd8caa934c412eea702f07dc-d # internal github.com/lucas-clemente/quic-go/internal/qtls mkdir -p $WORK/b347/ cat >$WORK/b347/importcfg << 'EOF' # internal
packagefile crypto=/usr/local/go/pkg/darwin_arm/crypto.a packagefile crypto/cipher=/usr/local/go/pkg/darwin_arm/crypto/cipher.a packagefile crypto/tls=/usr/local/go/pkg/darwin_arm/crypto/tls.a packagefile github.com/marten-seemann/qtls=$WORK/b348/pkg.a packagefile net=/usr/local/go/pkg/darwin_arm/net.a packagefile reflect=/usr/local/go/pkg/darwin_arm/reflect.a EOF cd /go/pkg/mod/github.com/lucas-clemente/quic-go@v0.18.1/internal/qtls /usr/local/go/pkg/tool/linux_amd64/compile -o $WORK/b347/pkg.a -trimpath "$WORK/b347=>" -shared -p github.com/lucas-clemente/quic-go/internal/qtls -complete -buildid M3EUWHNvQmmR5S9ZAMhH/M3EUWHNvQmmR5S9ZAMhH -goversion go1.13.4 -D "" -importcfg $WORK/b347/importcfg -pack ./go114.go ./qtls.go ./structs_equal.go
/go/pkg/mod/github.com/lucas-clemente/quic-go@v0.18.1/internal/qtls/qtls.go:79:25: cannot convert cert (type tls.Certificate) to type qtls.Certificate note: module requires Go 1.14 2021/05/26 23:53:26 Failed to cross compile package: exit status 2.
END
The go cross compiler no longer supports an up to date go compiler for iOS, therefore breaking cross compiling on newer v2ray releases.
A jailbreak with procursus bootstrap includes up to date Go compiler where you can compile the latest v2ray natively on an iOS device. That’s how I do it for now.
A jailbreak with procursus bootstrap
Where can I get more information about this?
A jailbreak with procursus bootstrap
Where can I get more information about this?
Check odysseyra1n and taurine jailbreaks. They use procursus bootstrap.
Any news or method of generating stable version of libv2ray for iOS just like android have?
运行起来了,config也是对的,怎么就是流量不走这边呢?
iphone:~ root# /usr/bin/v2ray -config /usr/local/etc/v2ray/cfg.json runtime/cgo: no Info.plist URL V2Ray 4.19.1 (Po) Custom A unified platform for anti-censorship. 2024/04/10 02:23:28 [Warning] v2ray.com/core: V2Ray 4.19.1 started
由于ios系统限制,现有的工具其实体验都不好,隧道容易爆炸。希望官方可以默认提供iphoneos的编译包给越狱用户自己折腾用。