mirror of
https://github.com/wweir/sower.git
synced 2024-04-21 12:42:15 +00:00
Separate http_proxy interface setting for some case
This commit is contained in:
+4
-4
@@ -20,9 +20,9 @@ var Conf = struct {
|
||||
Cipher string `toml:"cipher"`
|
||||
Password string `toml:"password"`
|
||||
|
||||
ServerPort string `toml:"server_port"`
|
||||
ServerAddr string `toml:"server_addr"`
|
||||
HTTPProxyPort string `toml:"http_proxy_port"`
|
||||
ServerPort string `toml:"server_port"`
|
||||
ServerAddr string `toml:"server_addr"`
|
||||
HTTPProxy string `toml:"http_proxy"`
|
||||
|
||||
DNSServer string `toml:"dns_server"`
|
||||
ClientIP string `toml:"client_ip"`
|
||||
@@ -41,7 +41,7 @@ func init() {
|
||||
flag.StringVar(&Conf.Password, "p", "12345678", "password")
|
||||
flag.StringVar(&Conf.ServerPort, "P", "5533", "server mode listen port")
|
||||
flag.StringVar(&Conf.ServerAddr, "s", "", "server IP (run in client mode if set)")
|
||||
flag.StringVar(&Conf.HTTPProxyPort, "H", "", "http proxy listen port")
|
||||
flag.StringVar(&Conf.HTTPProxy, "H", "", "http proxy listen addr")
|
||||
flag.StringVar(&Conf.DNSServer, "d", "114.114.114.114", "client dns server")
|
||||
flag.StringVar(&Conf.ClientIP, "c", "127.0.0.1", "client dns service redirect IP")
|
||||
|
||||
|
||||
+2
-2
@@ -2,8 +2,8 @@ net_type="TCP"
|
||||
cipher="AES_128_GCM"
|
||||
password="12345678"
|
||||
server_port="5533"
|
||||
server_addr="remote-server:5533" # replce it to remote server
|
||||
http_proxy_port="8080"
|
||||
# server_addr="remote-server:5533" # replce it to remote server
|
||||
http_proxy=":8080" # eg: 192.168.0.2:8080
|
||||
dns_server="223.5.5.5" # Alibaba public dns
|
||||
client_ip="127.0.0.1"
|
||||
# clear_dns_cache="killall -HUP mDNSResponder"
|
||||
|
||||
@@ -15,9 +15,9 @@ func main() {
|
||||
proxy.StartServer(conf.NetType, conf.ServerPort, conf.Cipher, conf.Password)
|
||||
|
||||
} else {
|
||||
if conf.HTTPProxyPort != "" {
|
||||
if conf.HTTPProxy != "" {
|
||||
go proxy.StartHttpProxy(conf.NetType, conf.ServerAddr,
|
||||
conf.Cipher, conf.Password, conf.ClientIP, conf.HTTPProxyPort)
|
||||
conf.Cipher, conf.Password, conf.HTTPProxy)
|
||||
}
|
||||
|
||||
go dns.StartDNS(conf.DNSServer, conf.ClientIP, conf.ClientIPNet)
|
||||
|
||||
+2
-6
@@ -12,15 +12,11 @@ import (
|
||||
"github.com/wweir/sower/shadow"
|
||||
)
|
||||
|
||||
func StartHttpProxy(netType, server, cipher, password, listenIP, port string) {
|
||||
if port[0] != ':' {
|
||||
port = ":" + port
|
||||
}
|
||||
|
||||
func StartHttpProxy(netType, server, cipher, password, addr string) {
|
||||
client := NewClient(netType)
|
||||
|
||||
srv := &http.Server{
|
||||
Addr: listenIP + port,
|
||||
Addr: addr,
|
||||
Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method == http.MethodConnect {
|
||||
httpsProxy(w, r, client, server, cipher, password)
|
||||
|
||||
Reference in New Issue
Block a user