Giter Site home page Giter Site logo

dosgo / ngrok-c Goto Github PK

View Code? Open in Web Editor NEW
497.0 497.0 204.0 18.88 MB

ngrok client for c language,Due to the use of GO ngrok language development, porting to embedded devices some inconvenience, such as openwrt, so use C language rewrite a client. Very mini, the need to support polarssl library.

License: MIT License

Shell 0.28% C 94.57% C++ 4.87% Batchfile 0.22% Makefile 0.06%

ngrok-c's People

Contributors

981213 avatar auslin45 avatar b4yuan avatar bootlee-wh avatar bryant1410 avatar dosgo avatar marwahaha avatar maz-1 avatar mzer0-yu avatar onlyjinx avatar rampagex avatar timgates42 avatar ugxhdhlwdxm avatar wjchen 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  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  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

ngrok-c's Issues

openssl的makefile少编译了一个文件,openwrt编译会出错

makefile里少编译了一个文件,参考openwrtbuildv2.sh就知道少了openssldl.o,makefile改成
CC?=gcc
CXX?=g++
CFLAGS+=-fexceptions -DOPENSSL=1 -O2
CXXFLAGS=-fexceptions -DOPENSSL=1 -O2
LIBS=sendmsg.o openssldl.o cJSON.o nonblocking.o sslbio.o ngrok.o main.o
all:: ngrokc $(LIBS)
ngrokc: $(LIBS)
$(CXX) -s $(LIBS) -o ngrokc -lpthread -lssl -lcrypto
sendmsg.o: sendmsg.h
openssldl.o: openssldl.h
cJSON.o: cJSON.h
nonblocking.o: nonblocking.h
sslbio.o: sslbio.h
ngrok.o: ngrok.h
main.o: sendmsg.h openssldl.h sslbio.h ngrok.h cJSON.h bytestool.h nonblocking.h

clean:
rm -f $(LIBS) ngrokc
编译通过,请大神修正一下

openwrt 18.06 luci 错误

使用的固件 :openwrt-x86-64-combined-squashfs.img
编译国际的源码:https://github.com/coolsnowwolf/lede
luci版本:src-git luci https://github.com/coolsnowwolf/luci

在使用时出现以下错误:
Sat Oct 27 06:44:58 2018 daemon.err uhttpd[4655]: /usr/lib/lua/luci/dispatcher.lua:509: Failed to execute cbi dispatcher target for entry '/admin/services/ngrokc'.
Sat Oct 27 06:44:58 2018 daemon.err uhttpd[4655]: The called action terminated with an exception:
Sat Oct 27 06:44:58 2018 daemon.err uhttpd[4655]: /usr/lib/lua/luci/template.lua:97: Failed to execute template 'cbi/map'.
Sat Oct 27 06:44:58 2018 daemon.err uhttpd[4655]: A runtime error occured: /usr/lib/lua/luci/template.lua:97: Failed to execute template 'cbi/tblsection'.
Sat Oct 27 06:44:58 2018 daemon.err uhttpd[4655]: A runtime error occured: /usr/lib/lua/luci/template.lua:97: Failed to execute template 'ngrokc/overview_value'.
Sat Oct 27 06:44:58 2018 daemon.err uhttpd[4655]: A runtime error occured: /usr/lib/lua/luci/model/uci.lua:221: attempt to call method 'get_all' (a nil value)
Sat Oct 27 06:44:58 2018 daemon.err uhttpd[4655]: stack traceback:
Sat Oct 27 06:44:58 2018 daemon.err uhttpd[4655]: [C]: in function 'assert'
Sat Oct 27 06:44:58 2018 daemon.err uhttpd[4655]: /usr/lib/lua/luci/dispatcher.lua:509: in function 'dispatch'
Sat Oct 27 06:44:58 2018 daemon.err uhttpd[4655]: /usr/lib/lua/luci/dispatcher.lua:127: in function </usr/lib/lua/luci/dispatcher.lua:126>

各种文件找不到!

qq 20160626214614
怎办
sdk:OpenWrt-SDK-ramips-for-linux-x86_64-gcc-4.8-linaro_uClibc-0.9.33.2.tar.bz2
系统:ubuntu14.04 64位

openwrt ar71xx 无反应

ngrokc -SER[Shost:ngrok.my.domain,Sport:11003] -AddTun[Type:http,Lhost:127.0.0.1, Lport:2,Sdname:ssh]
使用之后
只是会显示

root@OpenWrt:~# ngrokc -SER[Shost:ngrok.sequencer.xyz,Sport:11003] -AddTun[Type:http,Lhost:127.0.0.1,
Lport:2,Sdname:ssh]
ngrokc v1.40-(2016/10/27)

就没有其他的显示了
服务器也没有任何提示
但是如果使用
ngrokc -SER[Shost:ngrok.my.domain,Sport:4443(一个错误的端口)] -AddTun[Type:http,Lhost:127.0.0.1, Lport:2,Sdname:ssh]
则会出现

ngrokc v1.40-(2016/10/27)
connect failed...!
link err

有没有日志功能让我知道发生了啥...
使用
nc -v -w 10 -z ngrok.my.domain 11001-11003
能够提示success

Compilation error: mbedtls/ssl.h not found

I try to compile the ngrok-c client for my WNDR3800 Router which runs openwrt CC(14.07). I was using the VPS which runs Ubuntu 14.04 for the work. I followed every step you mentioned and still get the error information....Could you please help sort it out? Many thanks.

In file included from sslbio.h:8:0,
from nonblocking.h:21,
from sendmsg.h:4,
from sendmsg.cpp:11:
polarsslbio.h:9:25: fatal error: mbedtls/ssl.h: No such file or directory
#include <mbedtls/ssl.h>
^
compilation terminated.
In file included from sslbio.h:8:0,
from nonblocking.h:21,
from sendmsg.h:4,
from ngrok.h:6,
from main.cpp:33:
polarsslbio.h:9:25: fatal error: mbedtls/ssl.h: No such file or directory
#include <mbedtls/ssl.h>
^
compilation terminated.
In file included from sslbio.h:8:0,
from nonblocking.h:21,
from nonblocking.cpp:1:
polarsslbio.h:9:25: fatal error: mbedtls/ssl.h: No such file or directory
#include <mbedtls/ssl.h>
^
compilation terminated.
In file included from polarsslbio.cpp:4:0:
polarsslbio.h:9:25: fatal error: mbedtls/ssl.h: No such file or directory
#include <mbedtls/ssl.h>
^
compilation terminated.
In file included from sslbio.h:8:0,
from nonblocking.h:21,
from sendmsg.h:4,
from ngrok.h:6,
from ngrok.cpp:13:
polarsslbio.h:9:25: fatal error: mbedtls/ssl.h: No such file or directory
#include <mbedtls/ssl.h>
^
compilation terminated.
mips-openwrt-linux-g++: error: build-mips/main.o: No such file or directory
mips-openwrt-linux-g++: error: build-mips/sendmsg.o: No such file or directory
mips-openwrt-linux-g++: error: build-mips/nonblocking.o: No such file or directory
mips-openwrt-linux-g++: error: build-mips/ngrok.o: No such file or directory
mips-openwrt-linux-g++: error: build-mips/polarsslbio.o: No such file or directory
mips-openwrt-linux-g++: error: libmbedtls.a: No such file or directory
mips-openwrt-linux-g++: error: libmbedx509.a: No such file or directory
mips-openwrt-linux-g++: error: libmbedcrypto.a: No such file or directory

无法处理HTTPS请求

编译了最新版ngrokc v1.44-(2017/07/25),服务端是Ubuntu 16.04上通过apt-get install ngrok-server安装的,运行时提供了受信的SSL证书

HTTP和TCP channel都能正常使用,但HTTPS始终得不到客户端的数据返回,请问可能是什么原因?

另外,我看到有文章提到需要提供一个config文件,里面配置trust_host_root_certs,但ngrok-c貌似并不支持config文件输入

ar71xx 编译出错

之前一直用openwrt 15.05 CC 的SDK来编译ngrokc,一直是成功的,但是1.33/1.34/1.35,每次编译都出现:

mkdir: cannot create directory 'build-mips': File exists
./test.sh: 17: ./test.sh: mips-openwrt-linux-g++: not found
./test.sh: 18: ./test.sh: mips-openwrt-linux-g++: not found
./test.sh: 19: ./test.sh: mips-openwrt-linux-g++: not found
./test.sh: 20: ./test.sh: mips-openwrt-linux-g++: not found
./test.sh: 21: ./test.sh: mips-openwrt-linux-g++: not found
./test.sh: 22: ./test.sh: mips-openwrt-linux-g++: not found
./test.sh: 23: ./test.sh: mips-openwrt-linux-g++: not found
./test.sh: 24: ./test.sh: mips-openwrt-linux-g++: not found
mkdir: cannot create directory 'build-mips': File exists
./test.sh: 48: ./test.sh: mips-openwrt-linux-g++: not found
./test.sh: 49: ./test.sh: mips-openwrt-linux-g++: not found
./test.sh: 50: ./test.sh: mips-openwrt-linux-g++: not found
./test.sh: 51: ./test.sh: mips-openwrt-linux-g++: not found
./test.sh: 52: ./test.sh: mips-openwrt-linux-g++: not found
./test.sh: 53: ./test.sh: mips-openwrt-linux-g++: not found
./test.sh: 54: ./test.sh: mips-openwrt-linux-g++: not found

./test.sh: 55: ./test.sh: mips-openwrt-linux-g++: not found

tesh.sh是我vi建立的,也有sudo chmod +x test.sh

无法编译polarssl版本

我自己编译了libpolarssl.a ,但不管是放在工程目录还是建的polarssl目录下都无法编译成功,提示是编译nonblocking.cpp或sslbio时失败,将这些文件中的include<polarssl/xxx>都改为""还是不行,求指导

给作者大神提供个asus-merlin固件编译脚本

!/bin/sh

export PATH=$PATH:'/home/cijliu/work/asuswrt-merlin/release/src-rt-6.x.4708/toolchains/hndtools-arm-linux-2.6.36-uclibc-4.5.3/bin'
export STAGING_DIR="/home/cijliu/work/asuswrt-merlin/release/src-rt-6.x.4708/toolchains"
DIR=build-mips
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/opt/brcm-arm/lib:/usr/local/lib:/usr/lib
mkdir $DIR
rm -rf $DIR/main.o
rm -rf $DIR/cJSON.o
rm -rf $DIR/sendmsg.o
rm -rf $DIR/sslbio.o
rm -rf $DIR/nonblocking.o
rm -rf $DIR/openssldl.o
rm -rf $DIR/ngrokc

CC=arm-brcm-linux-uclibcgnueabi-g++
YH="-Wall -fexceptions -DOPENSSL=1 -DOPENSSLDL=1 -O2"
$CC $YH -c $1 sendmsg.cpp -o $DIR/sendmsg.o
$CC $YH -c openssldl.cpp -o $DIR/openssldl.o
$CC $YH -c $1 cJSON.c -o $DIR/cJSON.o
$CC $YH -c $1 main.cpp -o $DIR/main.o
$CC $YH -c $1 nonblocking.cpp -o $DIR/nonblocking.o
$CC $YH -c $1 sslbio.cpp -o $DIR/sslbio.o
$CC $YH -c $1 ngrok.cpp -o $DIR/ngrok.o
$CC -s $DIR/main.o $DIR/cJSON.o $DIR/sendmsg.o $DIR/nonblocking.o $DIR/ngrok.o $DIR/sslbio.o $DIR/openssldl.o -o $DIR/ngrokc -ldl

搭建好asus-merlin编译环境之后,设置PATH和STAGING_DIR路径,然后从PATH下找到对应路由器版本的CC编译器名称并在本脚本中修改。

另外,大神您提供的简书教程中,忘了提示编译者修改CC编译器那一步了~~~

非常感谢您的工作,让我能用上最新版本的路由器客户端,哈哈

编译openssl 出错

buildlib.sh文件如下:

export PATH=$PATH:'/home/linux/1/staging_dir/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/bin'
export STAGING_DIR="/home/linux/1/staging_dir"
CC=mipsel-openwrt-linux-gcc
CXX=mipsel-openwrt-linux-g++
AR=mipsel-openwrt-linux-ar
RANLIB=mipsel-openwrt-linux-ranlib
./Configure no-asm shared --prefix=pwd/../out/openssl linux-mips32
make clean
make
make install

错误信息:
making all in crypto...
make[1]: Entering directory /home/linux/openssl-1.0.2h/crypto' /usr/bin/perl ../util/mkbuildinf.pl "gcc -I. -I.. -I../include -fPIC -DOPENSSL_PIC -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -mabi=32 -O3 -Wall -DBN_DIV3W" "linux-mips32" >buildinf.h gcc -I. -I.. -I../include -fPIC -DOPENSSL_PIC -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -mabi=32 -O3 -Wall -DBN_DIV3W -c -o cryptlib.o cryptlib.c gcc: error: unrecognized argument in option '-mabi=32' gcc: note: valid arguments to '-mabi=' are: ms sysv make[1]: *** [cryptlib.o] Error 1 make[1]: Leaving directory/home/linux/openssl-1.0.2h/crypto'
make: *** [build_crypto] Error 1
making all in crypto...
make[1]: Entering directory /home/linux/openssl-1.0.2h/crypto' gcc -I. -I.. -I../include -fPIC -DOPENSSL_PIC -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -mabi=32 -O3 -Wall -DBN_DIV3W -c -o cryptlib.o cryptlib.c gcc: error: unrecognized argument in option '-mabi=32' gcc: note: valid arguments to '-mabi=' are: ms sysv make[1]: *** [cryptlib.o] Error 1 make[1]: Leaving directory/home/linux/openssl-1.0.2h/crypto'
make: *** [build_crypto] Error 1

请问linux服务端能编译吗

我编译的原版ngrok服务端,它是证书编译的,没有toke功能,所以ngrokc连不上。
请问有办法解决证书认证问题吗?或者有没有带toke功能的服务端,我想自己架设服务器。
感谢您

能加入自动重连的功能吗?

能加入自动重连的功能吗?
在openwrt下,3G网络
先执行ngrokc,tcp模式,本地端口22
用ifdown 3g关闭网络
10s后开启网络ifup 3g
等待拨号成功
拨号成功后,发现远程通道未恢复

最后给你一个openwrt的编译包。
这个包在放在源码编译目录的packages目录下
或sdk编译目录(packages)下都可以用。
只是放在sdk编译目录下时,需要解除依赖(比如openssl)
或将源码包和packages的feeds中的相关工程包(比如依赖的openssl)
拷贝到sdk的packages目录下即可编译
ngrok-c.tar.gz

能不能添加上设置Password功能呢

我的服务器有验证Password功能,我看客户端默认是空的,所以只能把服务器的密码设置空才能,能不能添加一个参数,让运行时可以验证Password

./build.sh 报错

ubuntu 14.04 64位 gcc4.8.4
执行./build.sh出现以下报错,请问如何解决?

→ ./build.sh 
build/main.o: In function `main':
/root/ngrok-c/main.cpp:174: undefined reference to `AbreSSL()'
build/main.o: In function `sendpack(int, ssl_st*, char const*, int)':
/root/ngrok-c/sendmsg.h:155: undefined reference to `SslWrite'
build/nonblocking.o: In function `openssl_free_info(openssl_info*)':
/root/ngrok-c/sslbio.h:52: undefined reference to `SslShutdown'
/root/ngrok-c/sslbio.h:53: undefined reference to `SslFree'
/root/ngrok-c/sslbio.h:54: undefined reference to `SslCtxFree'
build/sslbio.o: In function `openssl_init_info(int, openssl_info*)':
/root/ngrok-c/sslbio.cpp:10: undefined reference to `SslCtxNew'
/root/ngrok-c/sslbio.cpp:10: undefined reference to `SslMethodV23'
/root/ngrok-c/sslbio.cpp:12: undefined reference to `SslCtxCtrl'
/root/ngrok-c/sslbio.cpp:13: undefined reference to `SslNew'
/root/ngrok-c/sslbio.cpp:16: undefined reference to `SsLSetSession'
/root/ngrok-c/sslbio.cpp:19: undefined reference to `SslSetFd'
/root/ngrok-c/sslbio.cpp:20: undefined reference to `SslSetConnectState'
/root/ngrok-c/sslbio.cpp:23: undefined reference to `SslGetError'
/root/ngrok-c/sslbio.cpp:22: undefined reference to `SslDoHandshake'
/root/ngrok-c/sslbio.cpp:34: undefined reference to `SsLGet1Session'
build/ngrok.o: In function `SslRecv(ssl_st*, char*, int)':
/root/ngrok-c/sslbio.h:30: undefined reference to `SslRead'
/root/ngrok-c/sslbio.h:31: undefined reference to `SslGetError'
build/ngrok.o: In function `sendremote(int, ssl_st*, char const*, int, int)':
/root/ngrok-c/sendmsg.h:99: undefined reference to `SslWrite'
collect2: error: ld returned 1 exit status

关于断线重连的问题

我在用ngrok-c的过程中发现,有时ngrok服务器重启或者ngrokd进程死掉后,再启动ngrokd时,发现ngrok-c不能自动重新建立通道,如果正常使用中断网又恢复后,能否自动重连?

好多memleak。

Sublime+Sublimelinter有一堆leak提示。
路由器的内存本来就少,不能这么浪费吧。。。

bcm53xx_gcc-5.4.0_musl 找不到GCC 问题

我这边下载了lede-sdk-17.01.4-bcm53xx_gcc-5.4.0_musl-1.1.16_eabi.Linux-x86_64.tar.xzngrok-c
并参考Openwrt-Ngrokc编译教程
因为型号不同所以将相应的openwrtbuild2.0.sh修改为

#!/bin/sh
export PATH=$PATH:'/root/lede-sdk-17.01.4-bcm53xx_gcc-5.4.0_musl-1.1.16_eabi.Linux-x86_64/staging_dir/toolchain-arm_cortex-a9_gcc-5.4.0_musl-1.1.16_eabi/bin'
export STAGING_DIR="/root/lede-sdk-17.01.4-bcm53xx_gcc-5.4.0_musl-1.1.16_eabi.Linux-x86_64/staging_dir"
DIR=build-mips
mkdir $DIR
rm -rf $DIR/main.o
rm -rf $DIR/cJSON.o
rm -rf $DIR/sendmsg.o
rm -rf $DIR/nonblocking.o
rm -rf $DIR/ngrokc

CC=arm-openwrt-linux-muslgnueabi- #找不到对应的GCC 通过 info.mk找到名称
#CC=arm-openwrt-linux #找不到对应的GCC 通过toolchain-XXXX下目录得到名称
#CC=arm-openwrt-linux-muslgnueabi #找不到对应的GCC 通过toolchain-XXXX下目录得到名称
#CC=mips-openwrt-linux-ar #找不到对应的GCC 通过AR=mips-openwrt-linux-ar 得到名称
YH="-Wall -fexceptions -DOPENSSL=0 -DISMBEDTLS=1 -O2"
$CC $YH -c $1 sendmsg.cpp -o $DIR/sendmsg.o
$CC $YH -c $1 cJSON.c -o $DIR/cJSON.o
$CC $YH -c $1 main.cpp -o $DIR/main.o
$CC $YH -c $1 nonblocking.cpp -o $DIR/nonblocking.o
$CC $YH -c $1 polarsslbio.cpp -o $DIR/polarsslbio.o
$CC $YH -c $1 ngrok.cpp -o $DIR/ngrok.o
$CC -s $DIR/main.o $DIR/cJSON.o $DIR/sendmsg.o $DIR/nonblocking.o $DIR/ngrok.o $DIR/polarsslbio.o libmbedtls.a libmbedx509.a libmbedcrypto.a -o $DIR/ngrokc

#buill openssl
#CC=mips-openwrt-linux-gcc
#CXX=mips-openwrt-linux-g++
#AR=mips-openwrt-linux-ar
#RANLIB=mips-openwrt-linux-ranlib 
#./Configure no-asm shared --prefix=`pwd`/../out/openssl linux-mips32
#make
#make install

分别尝试了4个GCC都无法找到。
不知道是不是缺少了什么东西?
编译系统是Ubuntu 16 64 LTS
info.mk内容

TARGET_CROSS=arm-openwrt-linux-muslgnueabi-
GCC_VERSION=5.4.0
LIBC_TYPE=musl
LIBC_URL=http://www.musl-libc.org/
LIBC_VERSION=1.1.16
LIBC_SO_VERSION=1.1.16

不支持ipv6?

环境为网件4300v1,OpenWrt CC 15.05.1 r49389,用的ipv6线路,一直刷update dns,域名和线路都是通的,添加hosts也不行,换成ipv4的域名就ok了
root@OpenWrt:~# /root/ngrok/ngrokc -SER[Shost:xxx.com,Sport:11111] -AddTun[Type:http,Lhost:127.0.0.1,Lport:80,Sdname:web] -AddTun[Type:tcp,Lhost:127.0.0.1,Lport:23,Rport:11112]
ngrokc v1.41-(2017/01/09)
update dns
update dns
update dns
update dns
update dns

报错!!!

lo@lo-virtual-machine:~/ngrok-c$ sh openwrtbuildv2.sh
mkdir: 无法创建目录"build-mips": 文件已存在
openwrtbuildv2.sh: 16: openwrtbuildv2.sh: mips-openwrt-linux-g++: not found
openwrtbuildv2.sh: 17: openwrtbuildv2.sh: mips-openwrt-linux-g++: not found
openwrtbuildv2.sh: 18: openwrtbuildv2.sh: mips-openwrt-linux-g++: not found
openwrtbuildv2.sh: 19: openwrtbuildv2.sh: mips-openwrt-linux-g++: not found
openwrtbuildv2.sh: 20: openwrtbuildv2.sh: mips-openwrt-linux-g++: not found
openwrtbuildv2.sh: 21: openwrtbuildv2.sh: mips-openwrt-linux-g++: not found
openwrtbuildv2.sh: 22: openwrtbuildv2.sh: mips-openwrt-linux-g++: not found
openwrtbuildv2.sh: 23: openwrtbuildv2.sh: mips-openwrt-linux-g++: not found

!/bin/sh

export PATH=$PATH:'/home/lo/sdk/staging_dir/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/bin'
export STAGING_DIR="/home/lo/sdk/staging_dir"

貌似不支持openssl 1.1版本,能否加入

first,非常棒的项目!小巧精悍,各个平台都可以使用,Thanks for sharing ~~

貌似ngrok-c 不支持openssl 1.1版本,而且在openssl 1.1的环境下运行也会报错

ngrokc v1.48-(2019/01/23)
OpenSSL init fail.
Please check if the OpenSSL is installed.
OPENSSL_add_all_algorithms not found.

由于 OpenSSL 1.0 到 1.1 API有很大的变化,导致很多APP不兼容,可能ngrokc也不支持?

于是验证了一下(以下测试在 x64 系统下进行):

ngrokc 运行时,调用ssl库时是优先寻找 libssl.so 和 libcrypto.so, 然后才是 1.0版本的so

## file openssldl.cpp
 ssl_handle1 = dlopen("libssl.so", RTLD_LAZY);  
    if (ssl_handle1 == 0)
        ssl_handle1 = dlopen("libssl.so.1.0.0", RTLD_LAZY);
    if (ssl_handle1 == 0)
        return "Erro ao carregar libssl.so";
    ssl_handle2 = dlopen("libcrypto.so", RTLD_LAZY);
    if (ssl_handle2 == 0)
    ssl_handle2 = dlopen("libcrypto.so.1.0.0", RTLD_LAZY);
    if (ssl_handle2 == 0)
    {
        dlclose(ssl_handle1);
        ssl_handle1 = 0;
        return "Erro ao carregar libcrypto.so";
    }

而我当前系统同时存在 openssl 1.0和1.1(1.1是后来安装的)

libssl.so 及 libcrypto.so 均是指向最新的1.1版本

# ls -l /usr/lib/libssl.so*
lrwxrwxrwx 1 root root     13  6月 22 10:06 /usr/lib/libssl.so -> libssl.so.1.1
lrwxrwxrwx 1 root root     24  1月 17 2018 /usr/lib/libssl.so.10 -> /usr/lib/libssl.so.1.0.0
-r-xr-xr-x 1 root root 514670  3月 15 2018 /usr/lib/libssl.so.1.0.0
-rwxr-xr-x 1 root root 688857  3月  1 10:37 /usr/lib/libssl.so.1.1

ls -l /usr/lib/libcrypto.so*
lrwxrwxrwx 1 root root      16  6月 22 10:05 /usr/lib/libcrypto.so -> libcrypto.so.1.1
lrwxrwxrwx 1 root root      27  1月 17 2018 /usr/lib/libcrypto.so.10 -> /usr/lib/libcrypto.so.1.0.0
-r-xr-xr-x 1 root root 2668513  3月 15 2018 /usr/lib/libcrypto.so.1.0.0
-rwxr-xr-x 1 root root 3367180  3月  1 10:37 /usr/lib/libcrypto.so.1.1

于是我改动了 openssldl.cpp,让它优先使用 1.0版本的库

## file openssldl.cpp
 ssl_handle1 = dlopen("libssl.so.1.0.0", RTLD_LAZY);         # 这里有改动
    if (ssl_handle1 == 0)
        ssl_handle1 = dlopen("libssl.so.1.0.0", RTLD_LAZY);
    if (ssl_handle1 == 0)
        return "Erro ao carregar libssl.so";
    ssl_handle2 = dlopen("libcrypto.so.1.0.0", RTLD_LAZY);        #  这里有改动
    if (ssl_handle2 == 0)
    ssl_handle2 = dlopen("libcrypto.so.1.0.0", RTLD_LAZY);
    if (ssl_handle2 == 0)
    {
        dlclose(ssl_handle1);
        ssl_handle1 = 0;
        return "Erro ao carregar libcrypto.so";
    }

重新编译,运行正常

ngrokc v1.48-(2019/01/23)
{"Type":"AuthResp","Payload":{"Version":"2","MmVersion":"1.7","ClientId":"7fbd328269da12e9def746d781503778","Error":""}}
{"Type":"ReqProxy","Payload":{}}

如何编译ngrok-c在ARM11的6410下

我们需要修改openwrtbuildv2.sh文件,将第二行和第三行环境变量环节注释掉,然后将CC改arm-linux-gcc具体如下图所示
image
这种方式最简单!!!!

lib是否有错?编译windows版本时。

F:\XXX\ngrok-c-1.37-2016-5-25->g++ -s build-win32\main.o build-win32\sendmsg.o build-win32\ngrok.o build-win32\cJSON.o build-win32\nonblocking.o build-win32\sslbio.o -o build-win32\ngrokc.exe libpolarssl-win32.a -lws2_32 -lpthread
build-win32\main.o:main.cpp:(.text+0x4e2): undefined reference to SslWrite' build-win32\main.o:main.cpp:(.text.startup+0xa4): undefined reference to AbreSSL()'
D:/mingw32/bin/../lib/gcc/i686-w64-mingw32/4.8.2/../../../../i686-w64-mingw32/bin/ld.exe: build-win32\main.o: bad reloc address 0xa4 in section `.text.startup'

centos下编绎bcm63XX openwrt 出错.

运行./openwrtbuildv2.sh

提示
mkdir: cannot create directory `build-mips': File exists
/home/OpenWrt-SDK/staging_dir/toolchain-mips_gcc-4.3.3+cs_uClibc-0.9.30.1/usr/bin/../lib/gcc/mips-openwrt-linux-uclibc/4.3.3/../../../../mips-openwrt-linux-uclibc/bin/ld: cannot find -lgcc_s
collect2: ld returned 1 exit status

确定 sh里 需要生成的*.o文件已经编绎好.

arm编译出错,求帮助

脚本:
#!/bin/sh
export PATH=$PATH:'/home/ivan/Lede/1/staging_dir/toolchain-arm_cortex-a15+neon-vfpv4_gcc-5.4.0_musl-1.1.15_eabi/bin'
export STAGING_DIR="/home/ivan/Lede/1/staging_dir"
DIR=build-arm
mkdir $DIR
rm -rf $DIR/main.o
rm -rf $DIR/cJSON.o
rm -rf $DIR/sendmsg.o
rm -rf $DIR/sslbio.o
rm -rf $DIR/nonblocking.o
rm -rf $DIR/openssldl.o
rm -rf $DIR/ngrokc

CC=arm-openwrt-linux-muslgnueabi-g++
YH="-Wall -fexceptions -DOPENSSL=1 -DOPENSSLDL=1 -O2"
$CC $YH -c $1 sendmsg.cpp -o $DIR/sendmsg.o
$CC $YH -c openssldl.cpp -o $DIR/openssldl.o
$CC $YH -c $1 cJSON.c -o $DIR/cJSON.o
$CC $YH -c $1 main.cpp -o $DIR/main.o
$CC $YH -c $1 nonblocking.cpp -o $DIR/nonblocking.o
$CC $YH -c $1 sslbio.cpp -o $DIR/sslbio.o
$CC $YH -c $1 ngrok.cpp -o $DIR/ngrok.o
$CC -s $DIR/main.o $DIR/cJSON.o $DIR/sendmsg.o $DIR/nonblocking.o $DIR/ngrok.o $DIR/sslbio.o $DIR/openssldl.o -o $DIR/ngrokc -ldl

#buill openssl
#CC=arm-openwrt-linux-gcc
#CXX=arm-openwrt-linux-g++
#AR=arm-openwrt-linux-ar
#RANLIB=arm-openwrt-linux-ranlib
#./Configure no-asm shared --prefix=pwd/../out/openssl linux-mips32
#make
#make install


# 报错内容:
ivan@ubuntu:~/Lede/ngrok-c-master$ sudo ./openwrtbuildv2.sh
mkdir: cannot create directory ‘build-arm’: File exists
/home/ivan/Lede/1/staging_dir/toolchain-arm_cortex-a15+neon-vfpv4_gcc-5.4.0_musl-1.1.15_eabi/bin/arm-openwrt-linux-muslgnueabi-g++: 1: /home/ivan/Lede/1/staging_dir/toolchain-arm_cortex-a15+neon-vfpv4_gcc-5.4.0_musl-1.1.15_eabi/bin/arm-openwrt-linux-muslgnueabi-g++: Syntax error: word unexpected (expecting ")")
/home/ivan/Lede/1/staging_dir/toolchain-arm_cortex-a15+neon-vfpv4_gcc-5.4.0_musl-1.1.15_eabi/bin/arm-openwrt-linux-muslgnueabi-g++: 1: /home/ivan/Lede/1/staging_dir/toolchain-arm_cortex-a15+neon-vfpv4_gcc-5.4.0_musl-1.1.15_eabi/bin/arm-openwrt-linux-muslgnueabi-g++: Syntax error: word unexpected (expecting ")")
/home/ivan/Lede/1/staging_dir/toolchain-arm_cortex-a15+neon-vfpv4_gcc-5.4.0_musl-1.1.15_eabi/bin/arm-openwrt-linux-muslgnueabi-g++: 1: /home/ivan/Lede/1/staging_dir/toolchain-arm_cortex-a15+neon-vfpv4_gcc-5.4.0_musl-1.1.15_eabi/bin/arm-openwrt-linux-muslgnueabi-g++: Syntax error: word unexpected (expecting ")")
/home/ivan/Lede/1/staging_dir/toolchain-arm_cortex-a15+neon-vfpv4_gcc-5.4.0_musl-1.1.15_eabi/bin/arm-openwrt-linux-muslgnueabi-g++: 1: /home/ivan/Lede/1/staging_dir/toolchain-arm_cortex-a15+neon-vfpv4_gcc-5.4.0_musl-1.1.15_eabi/bin/arm-openwrt-linux-muslgnueabi-g++: Syntax error: word unexpected (expecting ")")
/home/ivan/Lede/1/staging_dir/toolchain-arm_cortex-a15+neon-vfpv4_gcc-5.4.0_musl-1.1.15_eabi/bin/arm-openwrt-linux-muslgnueabi-g++: 1: /home/ivan/Lede/1/staging_dir/toolchain-arm_cortex-a15+neon-vfpv4_gcc-5.4.0_musl-1.1.15_eabi/bin/arm-openwrt-linux-muslgnueabi-g++: Syntax error: word unexpected (expecting ")")
/home/ivan/Lede/1/staging_dir/toolchain-arm_cortex-a15+neon-vfpv4_gcc-5.4.0_musl-1.1.15_eabi/bin/arm-openwrt-linux-muslgnueabi-g++: 1: /home/ivan/Lede/1/staging_dir/toolchain-arm_cortex-a15+neon-vfpv4_gcc-5.4.0_musl-1.1.15_eabi/bin/arm-openwrt-linux-muslgnueabi-g++: Syntax error: word unexpected (expecting ")")
/home/ivan/Lede/1/staging_dir/toolchain-arm_cortex-a15+neon-vfpv4_gcc-5.4.0_musl-1.1.15_eabi/bin/arm-openwrt-linux-muslgnueabi-g++: 1: /home/ivan/Lede/1/staging_dir/toolchain-arm_cortex-a15+neon-vfpv4_gcc-5.4.0_musl-1.1.15_eabi/bin/arm-openwrt-linux-muslgnueabi-g++: Syntax error: word unexpected (expecting ")")
/home/ivan/Lede/1/staging_dir/toolchain-arm_cortex-a15+neon-vfpv4_gcc-5.4.0_musl-1.1.15_eabi/bin/arm-openwrt-linux-muslgnueabi-g++: 1: /home/ivan/Lede/1/staging_dir/toolchain-arm_cortex-a15+neon-vfpv4_gcc-5.4.0_musl-1.1.15_eabi/bin/arm-openwrt-linux-muslgnueabi-g++: Syntax error: word unexpected (expecting ")")

是sdk的问题造成吗? 请问可以帮我编译一个吗?
sdk下载地址:
https://downloads.lede-project.org/snapshots/targets/ipq806x/generic/lede-sdk-ipq806x_gcc-5.4.0_musl-1.1.15_eabi.Linux-x86_64.tar.xz

[email protected]

OPENSSL在MT7620平台编译出现问题

1、先编译openssl(buildlib.sh无法成功编译,后修改了Makefile编译成功),CC=mipsel-openwrt-linux-g++,生成了libssl.a和libcrypto.a,拷贝至ngrok-c-master目录。
2、修改openwrtbuild.sh,出现报错,求助!!!谢谢。
main.cpp:(.text+0x57c): warning: gethostbyname is obsolescent, use getnameinfo() instead.
build-mipsel-openssl/ngrok.o: In function ConnectMain(int*, sockaddr_in, ssl_info**, std::string*, std::map<int, sockinfo*, std::less<int>, std::allocator<std::pair<int const, sockinfo*> > >*, char*, char*)': ngrok.cpp:(.text+0x474): undefined reference to ssl_init_info(int*, ssl_info*)'
ngrok.cpp:(.text+0x570): undefined reference to SSL_write' ngrok.cpp:(.text+0x6a0): undefined reference to SSL_shutdown'
ngrok.cpp:(.text+0x6ac): undefined reference to SSL_free' ngrok.cpp:(.text+0x6b8): undefined reference to SSL_CTX_free'
build-mipsel-openssl/ngrok.o: In function CmdSock(int*, sockinfo*, std::map<int, sockinfo*, std::less<int>, std::allocator<std::pair<int const, sockinfo*> > >*, sockaddr_in, std::string*, char*, std::list<TunnelInfo*, std::allocator<TunnelInfo*> >*, std::map<std::string, TunnelReq*, std::less<std::string>, std::allocator<std::pair<std::string const, TunnelReq*> > >*)': ngrok.cpp:(.text+0x1230): undefined reference to SSL_read'
ngrok.cpp:(.text+0x1240): undefined reference to SSL_get_error' ngrok.cpp:(.text+0x15c8): undefined reference to SSL_write'
ngrok.cpp:(.text+0x16ac): undefined reference to SSL_write' build-mipsel-openssl/ngrok.o: In function RemoteSslInit(std::_Rb_tree_iterator<std::pair<int const, sockinfo*> >, sockinfo, std::string&, std::map<int, sockinfo*, std::less, std::allocator<std::pair<int const, sockinfo*> > >)':
ngrok.cpp:(.text+0x17c8): undefined reference to ssl_init_info(int*, ssl_info*)' ngrok.cpp:(.text+0x18a4): undefined reference to SSL_write'
build-mipsel-openssl/ngrok.o: In function LocalToRemote(std::_Rb_tree_iterator<std::pair<int const, sockinfo*> >*, sockinfo*, ssl_info*, std::map<int, sockinfo*, std::less<int>, std::allocator<std::pair<int const, sockinfo*> > >*)': ngrok.cpp:(.text+0x19d4): undefined reference to SSL_write'
build-mipsel-openssl/ngrok.o: In function ConnectLocal(ssl_info*, std::_Rb_tree_iterator<std::pair<int const, sockinfo*> >*, sockinfo*, std::map<int, sockinfo*, std::less<int>, std::allocator<std::pair<int const, sockinfo*> > >*, std::map<std::string, TunnelReq*, std::less<std::string>, std::allocator<std::pair<std::string const, TunnelReq*> > >*)': ngrok.cpp:(.text+0x1ab8): undefined reference to SSL_read'
ngrok.cpp:(.text+0x1ac8): undefined reference to SSL_get_error' build-mipsel-openssl/ngrok.o: In function RemoteToLocal(ssl_info
, sockinfo*, std::_Rb_tree_iterator<std::pair<int const, sockinfo*> >, std::map<int, sockinfo, std::less, std::allocator<std::pair<int const, sockinfo*> > >*)':
ngrok.cpp:(.text+0x1e64): undefined reference to SSL_read' ngrok.cpp:(.text+0x1e74): undefined reference to SSL_get_error'
build-mipsel-openssl/main.o: In function checkping()': main.cpp:(.text+0x358): undefined reference to SSL_write'
build-mipsel-openssl/main.o: In function main': main.cpp:(.text.startup+0xb4): undefined reference to SSL_library_init'
main.cpp:(.text.startup+0xbc): undefined reference to SSL_load_error_strings' main.cpp:(.text.startup+0xc4): undefined reference to OPENSSL_add_all_algorithms_noconf'
build-mipsel-openssl/sendmsg.o: In function SendReqTunnel(int, ssl_st*, char*, char const*, char const*, char const*, int, char*)': sendmsg.cpp:(.text+0x1bc): undefined reference to SSL_write'
build-mipsel-openssl/nonblocking.o: In function clearsock(int, sockinfo*)': nonblocking.cpp:(.text+0xa0): undefined reference to SSL_shutdown'
nonblocking.cpp:(.text+0xac): undefined reference to SSL_free' nonblocking.cpp:(.text+0xb8): undefined reference to SSL_CTX_free'
collect2: error: ld returned 1 exit status

断线重连问题

当Sdname含有"."时断线重连后会有问题!
测试发现如果Sdname:abc.bcd
第一次运行一切正常,
访问路由器网址为abc.bcd.XXXX.com
当路由器断线后ngrokc重连后会只会返回abc不是返回的abc.bcd
此时访问路由器的网址则变为abc.XXXX.com

同时多个连接会崩溃,如何差错啊?

自己改了一个纯C的(在ubuntu中运行还算正常)移植到嵌入式系统中,同时有超过5、6个连接时就会崩溃,不知道从哪个方面入手查错。
还有没有人有纯C的ngrok啊?

获取DNS失败gethostbyname()

嵌入式设备 应用这个转发模块 当连接的路由器更换/重启,获取dns失败,转发失败?没有相应的判断处理吗?int net_dns( struct sockaddr_in *server_addr, const char *host, int port ) 返回-1!

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.