Skip to content

Commit

Permalink
Initial commit for listing TS in menu
Browse files Browse the repository at this point in the history
  • Loading branch information
sithtoast committed Sep 12, 2023
1 parent a1c64c9 commit 4d416ba
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Empty file modified build.sh
100644 → 100755
Empty file.
15 changes: 14 additions & 1 deletion menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ static uint32_t menu_key_get(void)
static char* getNet(int spec)
{
int netType = 0;
struct ifaddrs *ifaddr, *ifa, *ifae = 0, *ifaw = 0;
struct ifaddrs *ifaddr, *ifa, *ifae = 0, *ifaw = 0, *ifat = 0;
static char host[NI_MAXHOST];

if (getifaddrs(&ifaddr) == -1)
Expand All @@ -604,6 +604,7 @@ static char* getNet(int spec)

if ((strcmp(ifa->ifa_name, "eth0") == 0) && (ifa->ifa_addr->sa_family == AF_INET)) ifae = ifa;
if ((strncmp(ifa->ifa_name, "wlan", 4) == 0) && (ifa->ifa_addr->sa_family == AF_INET)) ifaw = ifa;
if ((strcmp(ifa->ifa_name, "tailscale", 4) == 0) && (ifa->ifa_addr->sa_family == AF_INET)) ifat = ifa;
}

ifa = 0;
Expand All @@ -620,6 +621,11 @@ static char* getNet(int spec)
netType = 2;
}

if (ifat && (!spec || spec == 3))
{
ifa = ifat;
nettype = 3;

if (spec && ifa)
{
strcpy(host, "IP: ");
Expand Down Expand Up @@ -673,6 +679,13 @@ static void printSysInfo()
infowrite(n++, str);
j++;
}
net = getNet(3);
if (net)
{
sprintf(str, "TS:", net);
infowrite(n++, str);
j++;
}
if (!j) infowrite(n++, "No network");
if (j<2) infowrite(n++, "");

Expand Down

0 comments on commit 4d416ba

Please sign in to comment.