-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhp.go
54 lines (50 loc) · 1.24 KB
/
hp.go
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
package main
import (
"fmt"
"os"
)
func Hp() {
if len(os.Args) == 2 {
HpHelp()
} else if len(os.Args) > 2 {
switch os.Args[2] {
case "install":
InstallPrivoxy()
default:
HpHelp()
}
} else {
HpHelp()
}
}
func HpHelp() {
fmt.Println("命令行 hp http 代理配置工具")
fmt.Println()
fmt.Println(Yellow("Usage:"))
fmt.Println(Blue(" ssr hp <command> [--parameter1=value1 --parameter2=value2 ...]"))
fmt.Println()
fmt.Println(Yellow("Commands:"))
fmt.Println(Red(" install 安装 http 代理软件"))
fmt.Println()
}
func InstallPrivoxy() {
// 安装 privoxy
err := RunCommand("sudo", "apt-get", "update")
if err != nil {
}
err = RunCommand("sudo", "apt-get", "-y", "install", "privoxy")
if err != nil {
return
}
// 配置 privoxy
err = RunCommand("sudo", "sh", "-c", "\"\"sudo echo -e 'forward-socks5 / 127.0.0.1:1080 .' >> /etc/privoxy/config\"\"")
if err != nil {
return
}
err = RunCommand("sudo", "service", "privoxy", "restart")
if err != nil {
return
}
fmt.Println(Yellow("=============== Tips =============== "))
fmt.Println(Yellow("append \"http_proxy=http://127.0.0.1:8118 https_proxy=http://127.0.0.1:8118\" to your bash profile \n and run \"source ~/.zshrc\" or \"source ~/.bashrc\""))
}