-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstatus.go
More file actions
64 lines (57 loc) · 1.73 KB
/
status.go
File metadata and controls
64 lines (57 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package main
import (
"fmt"
"os/exec"
"strings"
)
func showNetworkStatus() {
fmt.Println("🌐 Network Interface Status:")
fmt.Println(strings.Repeat("=", 40))
// Show all interfaces
cmd := exec.Command("ifconfig", "-a")
output, err := cmd.Output()
if err != nil {
fmt.Printf("❌ Failed to get interface list: %v\n", err)
return
}
interfaces := strings.Split(string(output), "\n")
for _, line := range interfaces {
if strings.Contains(line, ":") && !strings.HasPrefix(line, "\t") {
interfaceName := strings.Split(line, ":")[0]
if strings.Contains(interfaceName, "tun") ||
strings.Contains(interfaceName, "utun") ||
strings.Contains(interfaceName, "nghost") {
fmt.Printf("🔍 Found TUN-like interface: %s\n", interfaceName)
}
}
}
// Check for utun interfaces specifically
fmt.Println("\n🔍 Checking for utun interfaces:")
for i := 0; i < 10; i++ {
interfaceName := fmt.Sprintf("utun%d", i)
cmd := exec.Command("ifconfig", interfaceName)
if err := cmd.Run(); err == nil {
fmt.Printf("✅ Found existing interface: %s\n", interfaceName)
}
}
// Check for nghost interface
fmt.Println("\n🔍 Checking for nghost interface:")
cmd = exec.Command("ifconfig", "nghost0")
if err := cmd.Run(); err == nil {
fmt.Printf("✅ nghost0 interface exists\n")
} else {
fmt.Printf("❌ nghost0 interface not found\n")
}
// Show routing table
fmt.Println("\n🗺️ Routing table:")
cmd = exec.Command("netstat", "-rn")
output, err = cmd.Output()
if err == nil {
lines := strings.Split(string(output), "\n")
for _, line := range lines {
if strings.Contains(line, "10.100") || strings.Contains(line, "tun") || strings.Contains(line, "utun") {
fmt.Printf("🗺️ %s\n", line)
}
}
}
}