mirror of https://github.com/cbeuw/Cloak
RedirAddr backward compatibility
This commit is contained in:
parent
07dca1f448
commit
52720ca52f
|
|
@ -259,7 +259,7 @@ func main() {
|
||||||
https, _ := net.ResolveTCPAddr("tcp", ":443")
|
https, _ := net.ResolveTCPAddr("tcp", ":443")
|
||||||
http, _ := net.ResolveTCPAddr("tcp", ":80")
|
http, _ := net.ResolveTCPAddr("tcp", ":80")
|
||||||
sta.BindAddr = []net.Addr{https, http}
|
sta.BindAddr = []net.Addr{https, http}
|
||||||
log.Fatalf("bind address cannot be empty")
|
log.Fatalf("BindAddr cannot be empty")
|
||||||
}
|
}
|
||||||
|
|
||||||
// when cloak is started as a shadowsocks plugin
|
// when cloak is started as a shadowsocks plugin
|
||||||
|
|
|
||||||
|
|
@ -92,9 +92,23 @@ func (sta *State) ParseConfig(conf string) (err error) {
|
||||||
|
|
||||||
sta.Timeout = time.Duration(preParse.StreamTimeout) * time.Second
|
sta.Timeout = time.Duration(preParse.StreamTimeout) * time.Second
|
||||||
|
|
||||||
sta.RedirAddr, err = net.ResolveIPAddr("ip", preParse.RedirAddr)
|
redirAddr := preParse.RedirAddr
|
||||||
|
colonSep := strings.Split(redirAddr, ":")
|
||||||
|
if len(colonSep) != 0 {
|
||||||
|
if len(colonSep) == 2 {
|
||||||
|
logrus.Error("If RedirAddr contains a port number, please remove it.")
|
||||||
|
redirAddr = colonSep[0]
|
||||||
|
} else {
|
||||||
|
if strings.Contains(redirAddr, "[") {
|
||||||
|
logrus.Error("If RedirAddr contains a port number, please remove it.")
|
||||||
|
redirAddr = strings.TrimRight(redirAddr, "]:"+colonSep[len(colonSep)-1])
|
||||||
|
redirAddr = strings.TrimPrefix(redirAddr, "[")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sta.RedirAddr, err = net.ResolveIPAddr("ip", redirAddr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Error("If RedirAddr contains a port number, please remove it.")
|
|
||||||
return fmt.Errorf("unable to resolve RedirAddr: %v. ", err)
|
return fmt.Errorf("unable to resolve RedirAddr: %v. ", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue