0x7a657573 / zroxy

Transparent TLS sni proxy ( sniproxy ) written with pure C.
GNU General Public License v3.0
20 stars 3 forks source link

cross comilation for openwrt? #2

Open rezad1393 opened 1 year ago

rezad1393 commented 1 year ago

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

stokito commented 1 year ago

for the openwrt you can install sslh

rezad1393 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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

rezad1393 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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

0x7a657573 commented 1 year ago

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

rezad1393 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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

rezad1393 commented 1 year ago

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