diff --git a/README.md b/README.md index 66c8871..6b3f106 100644 --- a/README.md +++ b/README.md @@ -469,7 +469,7 @@ broadcastCh = 2 # channel to send the message to can be 2,3 multiple channels co enable_read_news = False # news command will return the contents of a text file news_file_path = news.txt news_random_line = False # only return a single random line from the news file -enable_runShellCmd = False # enable the use of exernal shell commands, this enables some data in `sysinfo` +enable_runShellCmd = False # enable the use of exernal shell commands, this enables more data in `sysinfo` DM # if runShellCmd and you think it is safe to allow the x: command to run # direct shell command handler the x: command in DMs user must be in bbs_admin_list allowXcmd = True diff --git a/mesh_bot.py b/mesh_bot.py index 0ce49f3..777fbcd 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -91,7 +91,7 @@ def auto_response(message, snr, rssi, hop, pkiStatus, message_from_id, channel_n "sun": lambda: handle_sun(message_from_id, deviceID, channel_number), "survey": lambda: surveyHandler(message, message_from_id, deviceID), "s:": lambda: surveyHandler(message, message_from_id, deviceID), - "sysinfo": lambda: sysinfo(message, message_from_id, deviceID), + "sysinfo": lambda: sysinfo(message, message_from_id, deviceID, isDM), "test": lambda: handle_ping(message_from_id, deviceID, message, hop, snr, rssi, isDM, channel_number), "testing": lambda: handle_ping(message_from_id, deviceID, message, hop, snr, rssi, isDM, channel_number), "tictactoe": lambda: handleTicTacToe(message, message_from_id, deviceID), @@ -1259,7 +1259,7 @@ def handle_sun(message_from_id, deviceID, channel_number, vox=False): location = get_node_location(message_from_id, deviceID, channel_number) return get_sun(str(location[0]), str(location[1])) -def sysinfo(message, message_from_id, deviceID): +def sysinfo(message, message_from_id, deviceID, isDM): if "?" in message: return "sysinfo command returns system information." else: @@ -1271,6 +1271,11 @@ def sysinfo(message, message_from_id, deviceID): if shellData == "" or shellData == None: # no data returned from the script shellData = "shell script data missing" + # if not an admin remove any line in the shellData that had 'IP:' in it + if (str(message_from_id) not in bbs_admin_list) or (not isDM): + shell_lines = shellData.splitlines() + filtered_lines = [line for line in shell_lines if 'IP:' not in line] + shellData = "\n".join(filtered_lines) return get_sysinfo(message_from_id, deviceID) + "\n" + shellData.rstrip() else: return get_sysinfo(message_from_id, deviceID) diff --git a/script/sysEnv.sh b/script/sysEnv.sh index 388744c..1585706 100644 --- a/script/sysEnv.sh +++ b/script/sysEnv.sh @@ -42,3 +42,15 @@ then fi fi fi + +# Get public and local IP addresses +public_ip=$(curl -s https://ifconfig.me 2>/dev/null) +public_ip=${public_ip:-""} +local_ip=$(hostname -I 2>/dev/null | awk '{print $1}') +local_ip=${local_ip:-""} +if [ -n "$public_ip" ]; then + echo "Public IP: $public_ip" +fi +if [ -n "$local_ip" ]; then + echo "Local IP: $local_ip" +fi \ No newline at end of file