-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
144 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
//go:build !windows | ||
// +build !windows | ||
|
||
package task | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
) | ||
|
||
func CheckProxyEnabled() bool { | ||
fmt.Println("如果使用WSL建议手动检查是否开启代理") | ||
return os.Getenv("HTTP_PROXY") != "" || os.Getenv("HTTPS_PROXY") != "" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
//go:build windows | ||
// +build windows | ||
|
||
package task | ||
|
||
import ( | ||
"fmt" | ||
"golang.org/x/sys/windows/registry" | ||
) | ||
|
||
func CheckProxyEnabled() bool { | ||
k, err := registry.OpenKey(registry.CURRENT_USER, `Software\Microsoft\Windows\CurrentVersion\Internet Settings`, registry.QUERY_VALUE) | ||
if err != nil { | ||
fmt.Println("无法打开注册表键:", err) | ||
return false | ||
} | ||
defer k.Close() | ||
|
||
proxyEnable, _, err := k.GetIntegerValue("ProxyEnable") | ||
if err != nil { | ||
fmt.Println("无法读取ProxyEnable值:", err) | ||
return false | ||
} | ||
|
||
return proxyEnable == 1 | ||
} |