Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cross comilation for openwrt? #2

Open
rezad1393 opened this issue Feb 23, 2023 · 16 comments
Open

cross comilation for openwrt? #2

rezad1393 opened this issue Feb 23, 2023 · 16 comments

Comments

@rezad1393
Copy link

how can I compile this (hopefully as a static executable)?

@stokito
Copy link

stokito commented May 9, 2023

for the openwrt you can install sslh

@rezad1393
Copy link
Author

rezad1393 commented May 10, 2023

for the openwrt you can install sslh

I already use this:
https://github.com/Intika-Linux-Proxy/SNI-SSL-Proxy
on openwrt.
I am looking for a replacement cause that project is dead.

update:
I look more closely at that sslh and it is just like other normal sniproxies used for hosting multiple servers on a singple ip.
that is not what I am looking for.

what I look for is what this project (zroxy) and the other one I linked do.

@0x7a657573
Copy link
Owner

I think zroxy not good for use on openwrt, because zroxy not optimize for memory usage and many router has limited ram
but it's good for use on VPS, Raspberry PI or something like that

@rezad1393
Copy link
Author

I think zroxy not good for use on openwrt, because zroxy not optimize for memory usage and many router has limited ram but it's good for use on VPS, Raspberry PI or something like that

openwrt already requires a minimum of hardware level that is 32MB for RAM.
and I have 512MB for RAM.

@0x7a657573
Copy link
Owner

it's good, in next week I tryed add

how can I compile this (hopefully as a static executable)?

unfortunately we can not able to static link zroxy because I use 'getaddrinfo' function for resolve domain name to IP and glibc uses libnss to support a number of different providers for address resolution services and we cannot statically link libnss!
but I searching for another solution for solve this problem, give me a little time :)

@0x7a657573
Copy link
Owner

I found solution, for static build of zroxy we can use 'musl-gcc' but unfortunately musl-gcc don't support "argp.h" library.
I want change this library to other one can support with musl-gcc, whit this change, the problem of static build and build for openwrt to be sulved.

@0x7a657573
Copy link
Owner

@rezad1393
now you can static build zroxy, I added readme about that :)
can you feedback to me it's work for you?

@rezad1393
Copy link
Author

rezad1393 commented May 30, 2023

english is not your first language is it? me too.

I will try and report back.

update:
I need to be able to cross-compile it.
I cant right now.

are you familiar with cross compiling?
for other apps I use this:

#!/bin/bash
# my variables
openwrt_sdk_folder=~/openwrt-sdk-22.03.5-mvebu-cortexa9_gcc-11.2.0_musl_eabi.Linux-x86_64/
openwrt_architecture_host=arm-openwrt-linux-muslgnueabi
openwrt_toolchain=toolchain-arm_cortex-a9+vfpv3-d16_gcc-11.2.0_musl_eabi

# Add that directory to the PATH environment variable:
    #PATH=$PATH:(your toolchain/bin directory here)
    #export PATH
PATH="$PATH:$openwrt_sdk_folder/staging_dir/$openwrt_toolchain/bin/"
export PATH

#Set the STAGING_DIR environment variable to the above toolchain dir and export it:
    #STAGING_DIR=(your toolchain directory here)
    #export STAGING_DIR
STAGING_DIR="$openwrt_sdk_folder/staging_dir/$openwrt_toolchain/"
export STAGING_DIR
make CC=arm-openwrt-linux-muslgnueabi-gcc LD=arm-openwrt-linux-muslgnueabi-ld 

and then

./configure --host=$openwrt_architecture_host --enable-static
and then :
make

but with your app it doesnt work

this also doesnt work
make CC=arm-openwrt-linux-muslgnueabi-gcc LD=arm-openwrt-linux-muslgnueabi-ld
program produced is still compiled for x64 and not arm-openwrt

@rezad1393
Copy link
Author

I think you need to change "cmake .." and make it so make file understand cross-compiling.
if you have no experience with cross-compiling support then I can wait until you figure it out.

@rezad1393
Copy link
Author

I dont think it is just a matter for changing gcc to musl.

@0x7a657573
Copy link
Owner

0x7a657573 commented Jun 8, 2023

@rezad1393
I added openwrt support to zroxy, please read this link:
https://github.com/0x7a657573/zroxy/tree/main/openwrt

@rezad1393
Copy link
Author

rezad1393 commented Jun 8, 2023

may I suggest not using git if you are gonna just
git branch -a
git tag
git checkout v21.02.3

it takes to much too download and too big.

use the zipped sdk for that version. mine is
openwrt-sdk-22.03.5-mvebu-cortexa9_gcc-11.2.0_musl_eabi.Linux-x86_64.tar.xz

postscriptum:
if my openwrt memory if correct I am not sure you need that "./scripts/feeds install -a". as that just selects a lot of packages to compile.
maybe it is needed for packages that have a lot of dependencies but not for your app.

@rezad1393
Copy link
Author

I made the ipk (had to remove the signing option from make menu), and moved the ipk to openwrt and installed it.
it installed to /usr/bin/zproxy and I will try it to see if it works correctly but a bug that I see is that the install exe is not found if I just run zproxy. I have to type full path.

@rezad1393
Copy link
Author

update:
doesnt work.
when I try to connect to youtube on my laptop (which in my router I have set the dns to router ip (which worked with sniproxy)
the zroxy crashes on openwrt.

zsh: segmentation fault  /usr/bin/zroxy -p 80@80,443@443 -s 192.168.1.1:9050
OpenWrt# /usr/bin/zroxy -p 80@80,443@443 -s 192.168.1.1:9050
11:31:01 INFO  main.c:87: enable socks on 192.168.1.1:9050
11:31:01 INFO  sniproxy.c:34: socket listen on 0.0.0.0:443
11:31:01 INFO  sniproxy.c:34: socket listen on 0.0.0.0:80
11:31:04 INFO  sniclient.c:87: SNI start Host { www.youtube.com } 
zsh: segmentation fault  /usr/bin/zroxy -p 80@80,443@443 -s 192.168.1.1:9050
OpenWrt# /usr/bin/zroxy -p 80,443 -s 192.168.1.1:9050 
11:31:17 INFO  main.c:87: enable socks on 192.168.1.1:9050
11:31:17 INFO  sniproxy.c:34: socket listen on 0.0.0.0:443
11:31:17 INFO  sniproxy.c:34: socket listen on 0.0.0.0:80
11:31:20 INFO  sniclient.c:87: SNI start Host { www.youtube.com } 
zsh: segmentation fault  /usr/bin/zroxy -p 80,443 -s 192.168.1.1:9050

@0x7a657573
Copy link
Owner

what is your upstream socks ?
your socks has user and pass or is what's version of that

@rezad1393
Copy link
Author

my upstream is tor running at router. (same device running the zroxy)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants