Skip to content

Commit

Permalink
add http basic auth
Browse files Browse the repository at this point in the history
  • Loading branch information
dosgo committed Nov 2, 2019
1 parent c123162 commit 6388b9d
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 55 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ ngrokc.exe -SER[Shost:tunnel.mobi,Sport:44433] -AddTun[Type:http,Lhost:127.0.0.1
 使用方法-AddTun[Type:http,Lhost:127.0.0.1,Lport:80,Hostheader:localhost]
## 2019/07/28
-1.53 add support openssl 1.1。
## 2019/11/2
-1.54 add support http basic auth。
Example -AddTun[Type:http,Lhost:127.0.0.1,Lport:80,Httpauth:"test:test"]

### 关于编译对应路由的版本的ngrokc。
## 一。去http://downloads.openwrt.org/下载你路由对应的SDK版本 ,如OpenWrt-SDK-ar71xx-for-linux-x86_64-gcc-4.8-linaro_uClibc-0.9.33.2.tar.bz2,并且解压。
Expand Down
Binary file modified bin/Release/ngrokc.exe
Binary file not shown.
2 changes: 1 addition & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#endif
using namespace std;
//string VER = "1.35-(2016/5/13)";
char VER[24]= "1.53-(2019/07/28)";
char VER[24]= "1.54-(2019/11/2)";


ssl_info *mainsslinfo=NULL;
Expand Down
6 changes: 4 additions & 2 deletions sendmsg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ int SendReqTunnel(int sock,ssl_context *ssl,TunnelInfo *tunnelInfo)
memset(tunnelInfo->ReqId,0,20);
//copy
memcpy(tunnelInfo->ReqId,guid,strlen(guid));
sprintf(str,"{\"Type\":\"ReqTunnel\",\"Payload\":{\"Protocol\":\"%s\",\"ReqId\":\"%s\",\"Hostname\": \"%s\",\"Subdomain\":\"%s\",\"HttpAuth\":\"\",\"RemotePort\":%d,\"authtoken\":\"%s\"}}",tunnelInfo->protocol,tunnelInfo->ReqId,tunnelInfo->hostname,tunnelInfo->subdomain,tunnelInfo->remoteport,mainInfo.authtoken);
sprintf(str,"{\"Type\":\"ReqTunnel\",\"Payload\":{\"Protocol\":\"%s\",\"ReqId\":\"%s\",\"Hostname\": \"%s\",\"Subdomain\":\"%s\",\"HttpAuth\":\"%s\",\"RemotePort\":%d,\"authtoken\":\"%s\"}}",tunnelInfo->protocol,tunnelInfo->ReqId,tunnelInfo->hostname,tunnelInfo->subdomain,tunnelInfo->httpauth,tunnelInfo->remoteport,mainInfo.authtoken);
tunnelInfo->regtime=getUnixTime();//ÒÑ·¢
return sendpack(sock,ssl,str,1);
}
Expand Down Expand Up @@ -155,6 +155,8 @@ int loadargs( int argc, char **argv )

getvalue(jsonstr,"Sdname",tunnelinfo->subdomain);
getvalue(jsonstr,"Hostheader",tunnelinfo->hostheader);
getvalue(jsonstr,"Httpauth",tunnelinfo->httpauth);
//printf("httpAuth:%s\r\n",tunnelinfo->httpauth);
getvalue(jsonstr,"Hostname",tunnelinfo->hostname);
pos = pos + xpos + 1;
}
Expand All @@ -166,7 +168,7 @@ int loadargs( int argc, char **argv )
}else {
echo( "use " );
echo("%s",argv[0]);
echo( " -SER[Shost:ngrokd.ngrok.com,Sport:443,Atoken:xxxxxxx,Password:xxx] -AddTun[Type:tcp,Lhost:127.0.0.1,Lport:80,Rport:50199,Hostheader:localhost]" );
echo( " -SER[Shost:ngrokd.ngrok.com,Sport:443,Atoken:xx,Password:xx] -AddTun[Type:tcp,Lhost:127.0.0.1,Lport:80,Rport:50199,Hostheader:localhost,Httpauth:\"test:test\"]" );
echo( "\r\n" );
exit( 1 );
}
Expand Down
10 changes: 5 additions & 5 deletions win-ngrok-c.depend
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"opensslbio.h"
"polarsslbio.h"

1564154225 d:\c\ngrok-c\config.h
1572698127 d:\c\ngrok-c\config.h
<stdarg.h>
<stdio.h>
<string.h>
Expand Down Expand Up @@ -62,7 +62,7 @@
<polarssl/error.h>
<polarssl/certs.h>

1564149050 source:d:\c\ngrok-c\main.cpp
1564248782 source:d:\c\ngrok-c\main.cpp
"config.h"
<string.h>
<stdio.h>
Expand Down Expand Up @@ -136,7 +136,7 @@
<netinet/in.h>
<netinet/tcp.h>

1564149050 source:d:\c\ngrok-c\ngrok.cpp
1564311462 source:d:\c\ngrok-c\ngrok.cpp
"config.h"
<string>
<windows.h>
Expand All @@ -159,7 +159,7 @@
"mytime.h"
"opensslbio.h"

1564247285 source:d:\c\ngrok-c\openssldl.cpp
1564250665 source:d:\c\ngrok-c\openssldl.cpp
<stdio.h>
<stdlib.h>
<unistd.h>
Expand All @@ -173,7 +173,7 @@
"mytime.h"
"polarsslbio.h"

1564149050 source:d:\c\ngrok-c\sendmsg.cpp
1572700008 source:d:\c\ngrok-c\sendmsg.cpp
"config.h"
<string>
<windows.h>
Expand Down
94 changes: 47 additions & 47 deletions win-ngrok-c.layout
Original file line number Diff line number Diff line change
Expand Up @@ -2,124 +2,124 @@
<CodeBlocks_layout_file>
<FileVersion major="1" minor="0" />
<ActiveTarget name="Release" />
<File name="base64.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="416" topLine="0" />
</Cursor>
</File>
<File name="sslbio.h" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="cJSON.h" open="0" top="0" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="106" topLine="0" />
<Cursor1 position="0" topLine="63" />
</Cursor>
</File>
<File name="opensslbio.cpp" open="0" top="0" tabpos="12" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="191" topLine="0" />
</Cursor>
</File>
<File name="udp.cpp" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="cJSON.c" open="0" top="0" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="3077" topLine="52" />
<Cursor1 position="0" topLine="21" />
</Cursor>
</File>
<File name="polarsslbio.h" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="nonblocking.h" open="0" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="-1" zoom_2="0">
<Cursor>
<Cursor1 position="2400" topLine="4" />
<Cursor1 position="1661" topLine="50" />
</Cursor>
</File>
<File name="ngrok.h" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="config.h" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="730" topLine="0" />
<Cursor1 position="190" topLine="0" />
</Cursor>
</File>
<File name="opensslbio.h" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="openssldl.cpp" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1593" topLine="52" />
<Cursor1 position="3384" topLine="35" />
</Cursor>
</File>
<File name="global.h" open="0" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="-1" zoom_2="0">
<File name="openssldl.h" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2119" topLine="53" />
<Cursor1 position="3136" topLine="56" />
</Cursor>
</File>
<File name="ngrok.cpp" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="-1" zoom_2="0">
<File name="global.h" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="-1" zoom_2="0">
<Cursor>
<Cursor1 position="4751" topLine="123" />
<Cursor1 position="1201" topLine="53" />
</Cursor>
</File>
<File name="openssldl.h" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="polarsslbio.cpp" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="3136" topLine="56" />
<Cursor1 position="576" topLine="2" />
</Cursor>
</File>
<File name="nonblocking.cpp" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="polarsslbio.h" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1514" topLine="0" />
<Cursor1 position="594" topLine="4" />
</Cursor>
</File>
<File name="sendmsg.cpp" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="bytestool.h" open="0" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="384" topLine="0" />
<Cursor1 position="1694" topLine="15" />
</Cursor>
</File>
<File name="main.cpp" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="727" topLine="30" />
</Cursor>
</File>
<File name="openssldl.cpp" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="udp.h" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="3384" topLine="110" />
<Cursor1 position="964" topLine="0" />
</Cursor>
</File>
<File name="sendmsg.h" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="udp.cpp" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="5012" topLine="30" />
<Cursor1 position="3077" topLine="52" />
</Cursor>
</File>
<File name="udp.h" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="base64.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="964" topLine="0" />
<Cursor1 position="416" topLine="0" />
</Cursor>
</File>
<File name="global.cpp" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="sslbio.h" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="53" topLine="0" />
<Cursor1 position="106" topLine="0" />
</Cursor>
</File>
<File name="base64.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="ngrok.cpp" open="1" top="1" tabpos="6" split="0" active="1" splitpos="0" zoom_1="-1" zoom_2="0">
<Cursor>
<Cursor1 position="6013" topLine="124" />
<Cursor1 position="17715" topLine="569" />
</Cursor>
</File>
<File name="polarsslbio.cpp" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="ngrok.h" open="1" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="86" topLine="0" />
<Cursor1 position="772" topLine="0" />
</Cursor>
</File>
<File name="cJSON.c" open="0" top="0" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="sendmsg.h" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="21" />
<Cursor1 position="5012" topLine="30" />
</Cursor>
</File>
<File name="bytestool.h" open="0" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="nonblocking.cpp" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1694" topLine="15" />
<Cursor1 position="1514" topLine="0" />
</Cursor>
</File>
<File name="nonblocking.h" open="0" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="-1" zoom_2="0">
<File name="global.cpp" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1661" topLine="50" />
<Cursor1 position="53" topLine="0" />
</Cursor>
</File>
<File name="cJSON.h" open="0" top="0" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="base64.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="63" />
<Cursor1 position="6013" topLine="124" />
</Cursor>
</File>
<File name="sendmsg.cpp" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="384" topLine="0" />
</Cursor>
</File>
<File name="config.h" open="0" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="opensslbio.h" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="130" topLine="0" />
<Cursor1 position="1593" topLine="52" />
</Cursor>
</File>
</CodeBlocks_layout_file>

0 comments on commit 6388b9d

Please sign in to comment.