rofl0r / microsocks

tiny, portable SOCKS5 server with very moderate resource usage
Other
1.48k stars 266 forks source link

Cross-compilation on arm and mips devices #7

Open cyadron opened 6 years ago

cyadron commented 6 years ago

Hello,

I have successfully cross-compiled microsocks on mips and also on arm devices. On mips devices it works good so far. But I have a strange issue when I tested on arm devices. Some sites fail to load (like google.com, yahoo.com) with an error message (reported by proxifier) - Address type not supported. But some sites load fine (except for elements from google.com domain) - like github.com What could be the issue because this does not happen on mips devices?

rofl0r commented 6 years ago

does it work when you add -fsigned-char to your CFLAGS ?

cyadron commented 6 years ago

Unfortunately no. Still no go. I am getting other error also (with the original and the fsigned-char version). Proxy server cannot establish a connection with the target - Network unreachable. But some sites load fine.

rofl0r commented 6 years ago

well from a C language PoV the only difference between x86 and ARM is that ARM defaults to char == unsigned char. so i'd suspect that your issues are related to the specific ARM box you use - maybe some firewall rules, or a bad connection ?

cyadron commented 6 years ago

I have tested another socks server on the same device and it loads the sites ok. Any other idea?

rofl0r commented 6 years ago

you could try this: https://github.com/rofl0r/microsocks/issues/6 - increasing the stacksize

maybe for some reason the ARM implementation of GLIBC or whatever LIBC you use (which one is it?) wastes more RAM, and since google has a ton of DNS elements in its response it's sufficient to overwrite things and cause weird hickups.

cyadron commented 6 years ago

Until now I was using release 0.1.0. Now I am using the latest commit but I still have the problem. I have tried to set size_t stacksz = 512 * 1024; but nothing changed. The C library is uclibc. And I do get the warning that this library sucks when I cross-compile it but no other warning/errors. The error specified by proxifier is:

and I get no other output/error on the arm machine where microsocks is running. Could the uclibc library create this problem?

cyadron commented 6 years ago

After more testing I find out that resolving hostnames through the socks server option causes problems. If I use an external dns server the sites load fine. I see that this is one difference between uclibc and glibc. According to this paper: https://mirrors.edge.kernel.org/pub/linux/libs/uclibc/Glibc_vs_uClibc_Differences.txt uclibc does not support DNS resolution. But since some sites load, I guess it is partially supported?

rofl0r commented 6 years ago

yes, uclibc could be the culprit. i'd strongly suggest to use musl instead to build tiny static-linked binaries (build your own toolchain from the scripts in https://github.com/richfelker/musl-cross-make)

cyadron commented 5 years ago

Hi,

I finally built microsocks using musl. I have used the option for static-linked binaries and I was able to compile microsocks. I ended up with a binary 3 times bigger (64 KB). But the good news is that it works. Resolving hostnames finally works. So this workaround is good but I guess there is no way to make it work with the default compiler?

rofl0r commented 5 years ago

hi, if you want a smaller binary you can try use the following flags in config.mak:

CFLAGS = -Os -flto
LDFLAGS = -s -flto

as for making it work with your uclibc toolchain: did you try latest git ? some bugs have been fixed since you opened your issue.

hdbreaker commented 4 years ago

Hi @cyadron could you explain to me the steps to cross-compile the project to mipsle32?