Permalink
Browse files
fix three possible half-opened connections
- Loading branch information...
Showing
with
9 additions
and
5 deletions.
-
+5
−1
client/main.go
-
+4
−4
client/socks5.go
|
|
@@ -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 {
|
|
|
|
|
|
@@ -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