mirror of
https://github.com/v2ray/v2ray-core.git
synced 2026-11-19 15:02:10 +00:00
use buffered io for socks input
This commit is contained in:
1 parent
ca79db0de1
commit
d1d71e9e38
1 file changed
+6
-3
+6
-3
@@ -1,6 +1,7 @@
|
|||||||
package socks
|
package socks
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bufio"
|
||||||
"errors"
|
"errors"
|
||||||
"net"
|
"net"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -60,8 +61,10 @@ func (server *SocksServer) AcceptConnections(listener net.Listener) error {
|
|||||||
|
|
||||||
func (server *SocksServer) HandleConnection(connection net.Conn) error {
|
func (server *SocksServer) HandleConnection(connection net.Conn) error {
|
||||||
defer connection.Close()
|
defer connection.Close()
|
||||||
|
|
||||||
|
reader := bufio.NewReader(connection)
|
||||||
|
|
||||||
auth, err := socksio.ReadAuthentication(connection)
|
auth, err := socksio.ReadAuthentication(reader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Error on reading authentication: %v", err)
|
log.Error("Error on reading authentication: %v", err)
|
||||||
return err
|
return err
|
||||||
@@ -83,7 +86,7 @@ func (server *SocksServer) HandleConnection(connection net.Conn) error {
|
|||||||
authResponse := socksio.NewAuthenticationResponse(socksio.AuthNotRequired)
|
authResponse := socksio.NewAuthenticationResponse(socksio.AuthNotRequired)
|
||||||
socksio.WriteAuthentication(connection, authResponse)
|
socksio.WriteAuthentication(connection, authResponse)
|
||||||
|
|
||||||
request, err := socksio.ReadRequest(connection)
|
request, err := socksio.ReadRequest(reader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Error on reading socks request: %v", err)
|
log.Error("Error on reading socks request: %v", err)
|
||||||
return err
|
return err
|
||||||
@@ -118,7 +121,7 @@ func (server *SocksServer) HandleConnection(connection net.Conn) error {
|
|||||||
readFinish := make(chan bool)
|
readFinish := make(chan bool)
|
||||||
writeFinish := make(chan bool)
|
writeFinish := make(chan bool)
|
||||||
|
|
||||||
go server.dumpInput(connection, input, readFinish)
|
go server.dumpInput(reader, input, readFinish)
|
||||||
go server.dumpOutput(connection, output, writeFinish)
|
go server.dumpOutput(connection, output, writeFinish)
|
||||||
<-writeFinish
|
<-writeFinish
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user