client exit optimization

pull/103/head
刘河 2019-03-31 22:12:51 +08:00
parent f56b9ea883
commit c29dd2ad36
1 changed files with 5 additions and 10 deletions

View File

@ -212,31 +212,26 @@ func NewConn(tp string, vkey string, server string, connType string, proxyUrl st
} }
c := conn.NewConn(connection) c := conn.NewConn(connection)
if _, err := c.Write([]byte(common.CONN_TEST)); err != nil { if _, err := c.Write([]byte(common.CONN_TEST)); err != nil {
logs.Error(err) return nil, err
os.Exit(0)
} }
if _, err := c.Write([]byte(crypt.Md5(version.GetVersion()))); err != nil { if _, err := c.Write([]byte(crypt.Md5(version.GetVersion()))); err != nil {
logs.Error(err) return nil, err
os.Exit(0)
} }
if b, err := c.GetShortContent(32); err != nil || crypt.Md5(version.GetVersion()) != string(b) { if b, err := c.GetShortContent(32); err != nil || crypt.Md5(version.GetVersion()) != string(b) {
logs.Error("The client does not match the server version. The current version of the client is", version.GetVersion()) logs.Error("The client does not match the server version. The current version of the client is", version.GetVersion())
os.Exit(0) os.Exit(0)
} }
if _, err := c.Write([]byte(common.Getverifyval(vkey))); err != nil { if _, err := c.Write([]byte(common.Getverifyval(vkey))); err != nil {
logs.Error(err) return nil, err
os.Exit(0)
} }
if s, err := c.ReadFlag(); err != nil { if s, err := c.ReadFlag(); err != nil {
logs.Error(err) return nil, err
os.Exit(0)
} else if s == common.VERIFY_EER { } else if s == common.VERIFY_EER {
logs.Error("Validation key %s incorrect", vkey) logs.Error("Validation key %s incorrect", vkey)
os.Exit(0) os.Exit(0)
} }
if _, err := c.Write([]byte(connType)); err != nil { if _, err := c.Write([]byte(connType)); err != nil {
logs.Error(err) return nil, err
os.Exit(0)
} }
c.SetAlive(tp) c.SetAlive(tp)