v2.6.3
This commit is contained in:
心隨緣動 2025-08-03 23:16:35 +08:00 committed by GitHub
parent be9d76fcbf
commit d954e3331e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

80
main.go
View File

@ -6,8 +6,8 @@ import (
"log" "log"
"os" "os"
"os/signal" "os/signal"
"os/exec" // "os/exec"
"strings" // "strings"
"syscall" "syscall"
_ "unsafe" _ "unsafe"
@ -131,22 +131,22 @@ func resetSetting() {
func showSetting(show bool) { func showSetting(show bool) {
// 执行 shell 命令获取 IPv4 地址 // 执行 shell 命令获取 IPv4 地址
cmdIPv4 := exec.Command("sh", "-c", "curl -s4m8 ip.p3terx.com -k | sed -n 1p") // cmdIPv4 := exec.Command("sh", "-c", "curl -s4m8 ip.p3terx.com -k | sed -n 1p")
outputIPv4, err := cmdIPv4.Output() // outputIPv4, err := cmdIPv4.Output()
if err != nil { // if err != nil {
log.Fatal(err) // log.Fatal(err)
} // }
// 执行 shell 命令获取 IPv6 地址 // 执行 shell 命令获取 IPv6 地址
cmdIPv6 := exec.Command("sh", "-c", "curl -s6m8 ip.p3terx.com -k | sed -n 1p") // cmdIPv6 := exec.Command("sh", "-c", "curl -s6m8 ip.p3terx.com -k | sed -n 1p")
outputIPv6, err := cmdIPv6.Output() // outputIPv6, err := cmdIPv6.Output()
if err != nil { // if err != nil {
log.Fatal(err) // log.Fatal(err)
} // }
// 去除命令输出中的换行符 // 去除命令输出中的换行符
ipv4 := strings.TrimSpace(string(outputIPv4)) // ipv4 := strings.TrimSpace(string(outputIPv4))
ipv6 := strings.TrimSpace(string(outputIPv6)) // ipv6 := strings.TrimSpace(string(outputIPv6))
// 定义转义字符,定义不同颜色的转义字符 // 定义转义字符,定义不同颜色的转义字符
const ( const (
Reset = "\033[0m" Reset = "\033[0m"
@ -212,33 +212,33 @@ func showSetting(show bool) {
fmt.Println("") fmt.Println("")
fmt.Println("--------------------------------------------------") fmt.Println("--------------------------------------------------")
// 根据条件打印带颜色的字符串 // 根据条件打印带颜色的字符串
if ipv4 != "" { // if ipv4 != "" {
fmt.Println("") // fmt.Println("")
formattedIPv4 := fmt.Sprintf("%s %s%s:%d%s" + Reset, // formattedIPv4 := fmt.Sprintf("%s %s%s:%d%s" + Reset,
Green+"面板 IPv4 访问地址------>>", // Green+"面板 IPv4 访问地址------>>",
Yellow+"http://", // Yellow+"http://",
ipv4, // ipv4,
port, // port,
Yellow+webBasePath + Reset) // Yellow+webBasePath + Reset)
fmt.Println(formattedIPv4) // fmt.Println(formattedIPv4)
fmt.Println("") // fmt.Println("")
} // }
if ipv6 != "" { // if ipv6 != "" {
fmt.Println("") // fmt.Println("")
formattedIPv6 := fmt.Sprintf("%s %s[%s%s%s]:%d%s%s", // formattedIPv6 := fmt.Sprintf("%s %s[%s%s%s]:%d%s%s",
Green+"面板 IPv6 访问地址------>>", // 绿色的提示信息 // Green+"面板 IPv6 访问地址------>>", // 绿色的提示信息
Yellow+"http://", // 黄色的 http:// 部分 // Yellow+"http://", // 黄色的 http:// 部分
Yellow, // 黄色的[ 左方括号 // Yellow, // 黄色的[ 左方括号
ipv6, // IPv6 地址 // ipv6, // IPv6 地址
Yellow, // 黄色的] 右方括号 // Yellow, // 黄色的] 右方括号
port, // 端口号 // port, // 端口号
Yellow+webBasePath, // 黄色的 Web 基础路径 // Yellow+webBasePath, // 黄色的 Web 基础路径
Reset) // 重置颜色 // Reset) // 重置颜色
fmt.Println(formattedIPv6) // fmt.Println(formattedIPv6)
fmt.Println("") // fmt.Println("")
} // }
fmt.Println(Green + ">>>>>>>>注:若您安装了〔证书〕,请把IP换成您的域名用https方式登录" + Reset) fmt.Println(Green + ">>>>>>>>注:若您安装了〔证书〕,请使用您的域名用https方式登录" + Reset)
fmt.Println("") fmt.Println("")
fmt.Println("--------------------------------------------------") fmt.Println("--------------------------------------------------")
fmt.Println("↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑") fmt.Println("↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑")