Permalink
Browse files

fix three possible half-opened connections

  • Loading branch information...
1 parent ae3a7b8 commit 55e145844104fe4785bca24fdddf4f4344c47eef @madper madper committed Feb 9, 2015
Showing with 9 additions and 5 deletions.
  1. +5 −1 client/main.go
  2. +4 −4 client/socks5.go
View
@@ -50,7 +50,11 @@ func handleTCPConnection(c net.Conn) {
logger.Debugf("addressType: %d\n", addressType)
logger.Debugf("port: %d\n", port)
- c.Write(reqAnswer)
+ _, err = c.Write(reqAnswer)
+ if err != nil {
+ logger.Warningf("write req answer failed: %s", err)
+ return
+ }
proxyAgent, err := tunnel.NewClient(lc.Tunnel, lc.Server, lc.ServerPort, lc.MasterKey, lc.EncryptMethod, lc.Password, logger)
if err != nil {
View
@@ -29,8 +29,8 @@ func handShake(c net.Conn) error {
return fmt.Errorf("Protocol mismatch: %d", protoVersion)
}
- c.Write(handShakeAnswer)
- return nil
+ _, err = c.Write(handShakeAnswer)
+ return err
}
// commandCode, addressType, address, port, err
@@ -85,8 +85,8 @@ func parseReq(c net.Conn) (byte, byte, []byte, uint16, error) {
}
var port uint16
- binary.Read(r, binary.BigEndian, &port)
+ err = binary.Read(r, binary.BigEndian, &port)
// commandCode, addressType, address, port, err
- return commandCode, addressType, address.Bytes(), port, nil
+ return commandCode, addressType, address.Bytes(), port, err
}

0 comments on commit 55e1458

Please sign in to comment.