@@ -101,7 +101,7 @@ MOBILE_APP_VERSION='2.4.1.4'
101101# ############################################
102102
103103AWK_TOOL=' awk' # it will be upgrade to gawk, when you have gawk...
104- VERSION=' 1.3.2 '
104+ VERSION=' 1.3.4 '
105105
106106# ############################################
107107# # Network Util
@@ -383,6 +383,26 @@ gw_web_loginaction() {
383383 ) "
384384}
385385
386+ gw_get_rebind_counts () {
387+ # account=&password=
388+ printf ' %s' " $(
389+ curl $CURL_OPT -s \
390+ -A " $AUTH_UA " \
391+ -X POST \
392+ -d " $1 " \
393+ ' http://radius.gwifi.com.cn/cmps/admin.php/Help/getRebindCounts'
394+ ) "
395+ }
396+
397+ gw_get_online_records () {
398+ printf ' %s' " $(
399+ curl $CURL_OPT -s \
400+ -A " $AUTH_UA " \
401+ -X GET \
402+ " http://login.gwifi.com.cn/shop/statistics/get_user_access_records?name=$1 "
403+ ) "
404+ }
405+
386406gw_web_rebindmac () {
387407 # create random three-digit numbers
388408 local str
@@ -976,6 +996,59 @@ mobile_get_token() {
976996
977997}
978998
999+ get_online_records () {
1000+ GET_ONLINE_RTE=" $( gw_get_online_records " $GW_USER " ) "
1001+
1002+ [ $ISLOG ] && echo " " &&
1003+ echo " GET_ONLINE_RTE:" &&
1004+ echo " --> $GET_ONLINE_RTE " &&
1005+ echo ' '
1006+
1007+
1008+ GET_ONLINE_RTE_ERR=" $( echo " $GET_ONLINE_RTE " | grep ' var errormsg = ' ) "
1009+
1010+ [ " $GET_ONLINE_RTE_ERR " ] && {
1011+ logcat " $( str_str " $GET_ONLINE_RTE_ERR " ' var errormsg = "' ' ";' ) " ' E'
1012+ exit 1
1013+ }
1014+
1015+ logcat " $( str_str " $GET_ONLINE_RTE " ' var json = ' ' ;' ) "
1016+ }
1017+
1018+ get_rebind_counts () {
1019+ GET_REBIND_COUNTS_DATA=" account=$GW_USER &password=$GW_PWD "
1020+
1021+ [ $ISLOG ] && echo " " &&
1022+ echo " GET_REBIND_COUNTS_DATA:" &&
1023+ echo " --> $GET_REBIND_COUNTS_DATA " &&
1024+ echo ' '
1025+
1026+ GET_REBIND_COUNTS_RAW_RTE=" $( gw_get_rebind_counts $GET_REBIND_COUNTS_DATA ) "
1027+
1028+ [ $ISLOG ] && echo " " &&
1029+ echo " GET_REBIND_COUNTS_RTE:" &&
1030+ echo " --> $GET_REBIND_COUNTS_RAW_RTE " &&
1031+ echo ' '
1032+
1033+ GET_REBIND_COUNTS_ERR_RTE=" $( echo " $GET_REBIND_COUNTS_RAW_RTE " | grep ' class="error"' ) "
1034+
1035+ [ " $GET_REBIND_COUNTS_ERR_RTE " ] && {
1036+ logcat " $( str_str " $GET_REBIND_COUNTS_ERR_RTE " ' <span class="error">' ' </span>' ) " ' E'
1037+ exit 1
1038+ }
1039+
1040+ GET_REBIND_COUNTS_RTE=" $( printf " $( printf " $GET_REBIND_COUNTS_RAW_RTE " ) " | sed " s@\\\\ @@g" ) "
1041+ GET_REBIND_COUNTS_STATUS=" $( get_json_value " $GET_REBIND_COUNTS_RTE " ' status' ) "
1042+ GET_REBIND_COUNTS_INFO=" $( get_json_value " $GET_REBIND_COUNTS_RTE " ' info' ) "
1043+
1044+ if [ ! " $GET_REBIND_COUNTS_STATUS " = ' 1' ]; then
1045+ logcat " $GET_REBIND_COUNTS_INFO " ' E'
1046+ exit 1
1047+ fi
1048+
1049+ logcat " $GET_REBIND_COUNTS_INFO "
1050+ }
1051+
9791052get_user_info () {
9801053 MOBILE_GET_USER_DATA=" $(
9811054 printf ' {"data":"{\\"staticPassword\\":\\"%s\\",\\"phone\\":\\"%s\\"}","version":"%s","mac":"%s","gatewayId":"%s","token":"%s"}' \
@@ -1102,7 +1175,7 @@ usage() {
11021175giwifi-gear.sh
11031176 A cli tool for login giwifi by cloud auth mode (multi-platform, fast, small)
11041177usage:
1105- giwifi-gear.sh [-h] [-g <GATEWAY>] [-u <USERNAME>] [-p <PASSWORD>] [-t <TYPE>] [-T <TOKEN>] [-i <IFACE>] [-e <EXTRA_IFACE>] [-q] [-b] [-d] [-l] [-v]
1178+ giwifi-gear.sh [-h] [-g <GATEWAY>] [-u <USERNAME>] [-p <PASSWORD>] [-t <TYPE>] [-T <TOKEN>] [-i <IFACE>] [-e <EXTRA_IFACE>] [-I] [-B] [-R] [- q] [-b] [-d] [-l] [-v]
11061179optional arguments:
11071180 -h show this help message and exit
11081181 -g <GATEWAY> set the gateway
@@ -1115,6 +1188,8 @@ optional arguments:
11151188 -b bind or rebind your device
11161189 -q sign out of account authentication
11171190 -I show more user info and host group info
1191+ -B get the rebind mac counts
1192+ -R get the online records (raw data, within 6 months?)
11181193 -d running in the daemon mode (remove sharing restrictions)
11191194 -l print the log info
11201195 -v show the tool version and exit
@@ -1268,6 +1343,34 @@ main() {
12681343 exit 0
12691344 fi
12701345
1346+ # get online records
1347+ if [ " $ISGOR " ]; then
1348+ [ ! " $GW_USER " ] && {
1349+ printf ' %s' " Plz enter username: "
1350+ read GW_USER
1351+ }
1352+
1353+ get_online_records
1354+ exit 0
1355+ fi
1356+
1357+ # get rebind counts
1358+ if [ " $ISGRC " ]; then
1359+ [ ! " $GW_USER " ] && {
1360+ printf ' %s' " Plz enter username: "
1361+ read GW_USER
1362+ }
1363+
1364+ [ ! " $GW_PWD " ] && {
1365+ printf ' %s' " Plz enter password: "
1366+ read -s -t 20 GW_PWD
1367+ echo ' '
1368+ }
1369+
1370+ get_rebind_counts
1371+ exit 0
1372+ fi
1373+
12711374 if [ " $AUTH_STATE " = ' 2' ]; then
12721375 logcat " Good! You are already authed!"
12731376 if [ $ISQUIT ]; then
@@ -1475,7 +1578,7 @@ Logged: $([ "$AUTH_STATE" = '2' ] && echo 'yes' || echo 'no')
14751578 init
14761579
14771580 # paser the opts
1478- while getopts " g:u:p:t:T:i:e:qIbdlvh " option; do
1581+ while getopts " g:u:p:t:T:i:e:IBRqbdlvh " option; do
14791582 case " $option " in
14801583 g)
14811584 GW_GTW=" $OPTARG "
@@ -1502,6 +1605,12 @@ Logged: $([ "$AUTH_STATE" = '2' ] && echo 'yes' || echo 'no')
15021605 I)
15031606 ISUSERINFO=1
15041607 ;;
1608+ B)
1609+ ISGRC=1
1610+ ;;
1611+ R)
1612+ ISGOR=1
1613+ ;;
15051614 q)
15061615 ISQUIT=1
15071616 ;;
0 commit comments