mirror of
https://github.com/nadoo/glider.git
synced 2025-02-23 17:35:40 +08:00
http: fixed a compatibility issue with some http proxy server. #62
This commit is contained in:
parent
70a88f4789
commit
15b98359b1
4
conf.go
4
conf.go
@ -78,6 +78,7 @@ func confInit() {
|
|||||||
if !path.IsAbs(ruleFile) {
|
if !path.IsAbs(ruleFile) {
|
||||||
ruleFile = path.Join(flag.ConfDir(), ruleFile)
|
ruleFile = path.Join(flag.ConfDir(), ruleFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
rule, err := rule.NewConfFromFile(ruleFile)
|
rule, err := rule.NewConfFromFile(ruleFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
@ -90,14 +91,13 @@ func confInit() {
|
|||||||
if !path.IsAbs(conf.RulesDir) {
|
if !path.IsAbs(conf.RulesDir) {
|
||||||
conf.RulesDir = path.Join(flag.ConfDir(), conf.RulesDir)
|
conf.RulesDir = path.Join(flag.ConfDir(), conf.RulesDir)
|
||||||
}
|
}
|
||||||
ruleFolderFiles, _ := rule.ListDir(conf.RulesDir, ".rule")
|
|
||||||
|
|
||||||
|
ruleFolderFiles, _ := rule.ListDir(conf.RulesDir, ".rule")
|
||||||
for _, ruleFile := range ruleFolderFiles {
|
for _, ruleFile := range ruleFolderFiles {
|
||||||
rule, err := rule.NewConfFromFile(ruleFile)
|
rule, err := rule.NewConfFromFile(ruleFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
conf.rules = append(conf.rules, rule)
|
conf.rules = append(conf.rules, rule)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -242,8 +242,10 @@ func (s *HTTP) Dial(network, addr string) (net.Conn, error) {
|
|||||||
|
|
||||||
respR := bufio.NewReader(rc)
|
respR := bufio.NewReader(rc)
|
||||||
respTP := textproto.NewReader(respR)
|
respTP := textproto.NewReader(respR)
|
||||||
|
|
||||||
_, code, _, ok := parseFirstLine(respTP)
|
_, code, _, ok := parseFirstLine(respTP)
|
||||||
if ok && code == "200" {
|
if ok && code == "200" {
|
||||||
|
respTP.ReadMIMEHeader()
|
||||||
return rc, err
|
return rc, err
|
||||||
} else if code == "407" {
|
} else if code == "407" {
|
||||||
log.F("[http] authencation needed by proxy %s", s.addr)
|
log.F("[http] authencation needed by proxy %s", s.addr)
|
||||||
|
@ -58,8 +58,8 @@ func NewRedirServer(s string, dialer proxy.Dialer) (proxy.Server, error) {
|
|||||||
return NewRedirProxy(s, dialer, false)
|
return NewRedirProxy(s, dialer, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewRedirServer returns a redir server.
|
// NewRedir6Server returns a redir server for ipv6.
|
||||||
func NewRedirServer6(s string, dialer proxy.Dialer) (proxy.Server, error) {
|
func NewRedir6Server(s string, dialer proxy.Dialer) (proxy.Server, error) {
|
||||||
return NewRedirProxy(s, dialer, true)
|
return NewRedirProxy(s, dialer, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user