1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-21 17:46:58 -05:00

remove debug info

This commit is contained in:
Darien Raymond 2017-01-08 01:36:03 +01:00
parent 24a8ad6dcf
commit e87a16900e
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
2 changed files with 0 additions and 18 deletions

View File

@ -1,7 +1,6 @@
package freedom_test package freedom_test
import ( import (
"fmt"
"testing" "testing"
"v2ray.com/core/app" "v2ray.com/core/app"
@ -55,7 +54,6 @@ func TestSinglePacket(t *testing.T) {
payload.Append([]byte(data2Send)) payload.Append([]byte(data2Send))
traffic.InboundInput().Write(payload) traffic.InboundInput().Write(payload)
fmt.Println(tcpServerAddr.Network, tcpServerAddr.Address, tcpServerAddr.Port)
go freedom.Dispatch(tcpServerAddr, traffic) go freedom.Dispatch(tcpServerAddr, traffic)
traffic.InboundInput().Close() traffic.InboundInput().Close()

View File

@ -3,8 +3,6 @@ package socks
import ( import (
"io" "io"
"fmt"
"v2ray.com/core/common/buf" "v2ray.com/core/common/buf"
"v2ray.com/core/common/errors" "v2ray.com/core/common/errors"
v2net "v2ray.com/core/common/net" v2net "v2ray.com/core/common/net"
@ -105,13 +103,11 @@ func (s *ServerSession) Handshake(reader io.Reader, writer io.Writer) (*protocol
return nil, err return nil, err
} }
fmt.Println("s a")
if expectedAuth == authPassword { if expectedAuth == authPassword {
username, password, err := readUsernamePassword(reader) username, password, err := readUsernamePassword(reader)
if err != nil { if err != nil {
return nil, errors.Base(err).Message("Socks|Server: Failed to read username or password.") return nil, errors.Base(err).Message("Socks|Server: Failed to read username or password.")
} }
fmt.Println("s b")
if !s.config.HasAccount(username, password) { if !s.config.HasAccount(username, password) {
writeSocks5AuthenticationResponse(writer, 0xFF) writeSocks5AuthenticationResponse(writer, 0xFF)
return nil, errors.Base(err).Message("Socks|Server: Invalid username or password.") return nil, errors.Base(err).Message("Socks|Server: Invalid username or password.")
@ -121,7 +117,6 @@ func (s *ServerSession) Handshake(reader io.Reader, writer io.Writer) (*protocol
return nil, err return nil, err
} }
} }
fmt.Println("s c")
buffer.Clear() buffer.Clear()
if err := buffer.AppendSupplier(buf.ReadFullFrom(reader, 4)); err != nil { if err := buffer.AppendSupplier(buf.ReadFullFrom(reader, 4)); err != nil {
return nil, err return nil, err
@ -202,27 +197,23 @@ func readUsernamePassword(reader io.Reader) (string, string, error) {
return "", "", err return "", "", err
} }
nUsername := int(buffer.Byte(1)) nUsername := int(buffer.Byte(1))
fmt.Println("s username", nUsername)
buffer.Clear() buffer.Clear()
if err := buffer.AppendSupplier(buf.ReadFullFrom(reader, nUsername)); err != nil { if err := buffer.AppendSupplier(buf.ReadFullFrom(reader, nUsername)); err != nil {
return "", "", err return "", "", err
} }
username := buffer.String() username := buffer.String()
fmt.Println("s username", username)
buffer.Clear() buffer.Clear()
if err := buffer.AppendSupplier(buf.ReadFullFrom(reader, 1)); err != nil { if err := buffer.AppendSupplier(buf.ReadFullFrom(reader, 1)); err != nil {
return "", "", err return "", "", err
} }
nPassword := int(buffer.Byte(0)) nPassword := int(buffer.Byte(0))
fmt.Println("s pwd", nPassword)
buffer.Clear() buffer.Clear()
if err := buffer.AppendSupplier(buf.ReadFullFrom(reader, nPassword)); err != nil { if err := buffer.AppendSupplier(buf.ReadFullFrom(reader, nPassword)); err != nil {
return "", "", err return "", "", err
} }
password := buffer.String() password := buffer.String()
fmt.Println("s pwd", password)
return username, password, nil return username, password, nil
} }
@ -411,23 +402,18 @@ func ClientHandshake(request *protocol.RequestHeader, reader io.Reader, writer i
} }
account := rawAccount.(*Account) account := rawAccount.(*Account)
fmt.Println("c username", account.Username)
fmt.Println("c pwd", account.Password)
b.Clear() b.Clear()
b.AppendBytes(socks5Version, byte(len(account.Username))) b.AppendBytes(socks5Version, byte(len(account.Username)))
b.Append([]byte(account.Username)) b.Append([]byte(account.Username))
b.AppendBytes(byte(len(account.Password))) b.AppendBytes(byte(len(account.Password)))
b.Append([]byte(account.Password)) b.Append([]byte(account.Password))
fmt.Println("c a")
if _, err := writer.Write(b.Bytes()); err != nil { if _, err := writer.Write(b.Bytes()); err != nil {
return nil, err return nil, err
} }
fmt.Println("c b")
b.Clear() b.Clear()
if err := b.AppendSupplier(buf.ReadFullFrom(reader, 2)); err != nil { if err := b.AppendSupplier(buf.ReadFullFrom(reader, 2)); err != nil {
return nil, err return nil, err
} }
fmt.Println("c c")
if b.Byte(1) != 0x00 { if b.Byte(1) != 0x00 {
return nil, errors.New("Socks|Client: Server rejects account: ", b.Byte(1)) return nil, errors.New("Socks|Client: Server rejects account: ", b.Byte(1))
} }
@ -441,13 +427,11 @@ func ClientHandshake(request *protocol.RequestHeader, reader io.Reader, writer i
} }
b.AppendBytes(socks5Version, command, 0x00 /* reserved */) b.AppendBytes(socks5Version, command, 0x00 /* reserved */)
appendAddress(b, request.Address, request.Port) appendAddress(b, request.Address, request.Port)
fmt.Println("c e")
if _, err := writer.Write(b.Bytes()); err != nil { if _, err := writer.Write(b.Bytes()); err != nil {
return nil, err return nil, err
} }
b.Clear() b.Clear()
fmt.Println("c f")
if err := b.AppendSupplier(buf.ReadFullFrom(reader, 4)); err != nil { if err := b.AppendSupplier(buf.ReadFullFrom(reader, 4)); err != nil {
return nil, err return nil, err
} }