mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-01 23:16:23 -05:00
Format: run go fmt ./...
This commit is contained in:
parent
4c9210cf11
commit
1fa89b32d4
@ -200,7 +200,7 @@ func (h *Handler) Dial(ctx context.Context, dest net.Destination) (internet.Conn
|
|||||||
return h.getStatCouterConnection(conn), err
|
return h.getStatCouterConnection(conn), err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Handler) getStatCouterConnection(conn internet.Connection) (internet.Connection) {
|
func (h *Handler) getStatCouterConnection(conn internet.Connection) internet.Connection {
|
||||||
if h.uplinkCounter != nil || h.downlinkCounter != nil {
|
if h.uplinkCounter != nil || h.downlinkCounter != nil {
|
||||||
return &internet.StatCouterConnection{
|
return &internet.StatCouterConnection{
|
||||||
Connection: conn,
|
Connection: conn,
|
||||||
|
@ -57,7 +57,7 @@ func TestOutboundWithStatCounter(t *testing.T) {
|
|||||||
serial.ToTypedMessage(&policy.Config{
|
serial.ToTypedMessage(&policy.Config{
|
||||||
System: &policy.SystemPolicy{
|
System: &policy.SystemPolicy{
|
||||||
Stats: &policy.SystemPolicy_Stats{
|
Stats: &policy.SystemPolicy_Stats{
|
||||||
OutboundUplink: true,
|
OutboundUplink: true,
|
||||||
OutboundDownlink: true,
|
OutboundDownlink: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -2,8 +2,8 @@ package sidh
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
. "v2ray.com/core/external/github.com/cloudflare/sidh/internal/isogeny"
|
|
||||||
"io"
|
"io"
|
||||||
|
. "v2ray.com/core/external/github.com/cloudflare/sidh/internal/isogeny"
|
||||||
)
|
)
|
||||||
|
|
||||||
// I keep it bool in order to be able to apply logical NOT
|
// I keep it bool in order to be able to apply logical NOT
|
||||||
|
@ -3,8 +3,8 @@ package quic
|
|||||||
import (
|
import (
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"v2ray.com/core/external/github.com/lucas-clemente/quic-go/internal/protocol"
|
|
||||||
"v2ray.com/core/common/bytespool"
|
"v2ray.com/core/common/bytespool"
|
||||||
|
"v2ray.com/core/external/github.com/lucas-clemente/quic-go/internal/protocol"
|
||||||
)
|
)
|
||||||
|
|
||||||
type packetBuffer struct {
|
type packetBuffer struct {
|
||||||
|
@ -22,8 +22,8 @@ import (
|
|||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"v2ray.com/core/external/github.com/cloudflare/sidh/sidh"
|
|
||||||
"golang.org/x/crypto/curve25519"
|
"golang.org/x/crypto/curve25519"
|
||||||
|
"v2ray.com/core/external/github.com/cloudflare/sidh/sidh"
|
||||||
)
|
)
|
||||||
|
|
||||||
// numSessionTickets is the number of different session tickets the
|
// numSessionTickets is the number of different session tickets the
|
||||||
|
@ -38,7 +38,7 @@ var addrParser = protocol.NewAddressParser(
|
|||||||
func ReadTCPSession(user *protocol.MemoryUser, reader io.Reader) (*protocol.RequestHeader, buf.Reader, error) {
|
func ReadTCPSession(user *protocol.MemoryUser, reader io.Reader) (*protocol.RequestHeader, buf.Reader, error) {
|
||||||
account := user.Account.(*MemoryAccount)
|
account := user.Account.(*MemoryAccount)
|
||||||
|
|
||||||
hashkdf := hmac.New(func()hash.Hash{return sha256.New()}, []byte("SSBSKDF"))
|
hashkdf := hmac.New(func() hash.Hash { return sha256.New() }, []byte("SSBSKDF"))
|
||||||
hashkdf.Write(account.Key)
|
hashkdf.Write(account.Key)
|
||||||
|
|
||||||
behaviorSeed := crc32.ChecksumIEEE(hashkdf.Sum(nil))
|
behaviorSeed := crc32.ChecksumIEEE(hashkdf.Sum(nil))
|
||||||
@ -50,7 +50,6 @@ func ReadTCPSession(user *protocol.MemoryUser, reader io.Reader) (*protocol.Requ
|
|||||||
DrainSize := BaseDrainSize + 16 + 38 + RandDrainRolled
|
DrainSize := BaseDrainSize + 16 + 38 + RandDrainRolled
|
||||||
readSizeRemain := DrainSize
|
readSizeRemain := DrainSize
|
||||||
|
|
||||||
|
|
||||||
buffer := buf.New()
|
buffer := buf.New()
|
||||||
defer buffer.Release()
|
defer buffer.Release()
|
||||||
|
|
||||||
@ -59,7 +58,7 @@ func ReadTCPSession(user *protocol.MemoryUser, reader io.Reader) (*protocol.Requ
|
|||||||
if ivLen > 0 {
|
if ivLen > 0 {
|
||||||
if _, err := buffer.ReadFullFrom(reader, ivLen); err != nil {
|
if _, err := buffer.ReadFullFrom(reader, ivLen); err != nil {
|
||||||
readSizeRemain -= int(buffer.Len())
|
readSizeRemain -= int(buffer.Len())
|
||||||
DrainConnN(reader,readSizeRemain)
|
DrainConnN(reader, readSizeRemain)
|
||||||
return nil, nil, newError("failed to read IV").Base(err)
|
return nil, nil, newError("failed to read IV").Base(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,7 +68,7 @@ func ReadTCPSession(user *protocol.MemoryUser, reader io.Reader) (*protocol.Requ
|
|||||||
r, err := account.Cipher.NewDecryptionReader(account.Key, iv, reader)
|
r, err := account.Cipher.NewDecryptionReader(account.Key, iv, reader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
readSizeRemain -= int(buffer.Len())
|
readSizeRemain -= int(buffer.Len())
|
||||||
DrainConnN(reader,readSizeRemain)
|
DrainConnN(reader, readSizeRemain)
|
||||||
return nil, nil, newError("failed to initialize decoding stream").Base(err).AtError()
|
return nil, nil, newError("failed to initialize decoding stream").Base(err).AtError()
|
||||||
}
|
}
|
||||||
br := &buf.BufferedReader{Reader: r}
|
br := &buf.BufferedReader{Reader: r}
|
||||||
@ -87,7 +86,7 @@ func ReadTCPSession(user *protocol.MemoryUser, reader io.Reader) (*protocol.Requ
|
|||||||
addr, port, err := addrParser.ReadAddressPort(buffer, br)
|
addr, port, err := addrParser.ReadAddressPort(buffer, br)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
readSizeRemain -= int(buffer.Len())
|
readSizeRemain -= int(buffer.Len())
|
||||||
DrainConnN(reader,readSizeRemain)
|
DrainConnN(reader, readSizeRemain)
|
||||||
return nil, nil, newError("failed to read address").Base(err)
|
return nil, nil, newError("failed to read address").Base(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,13 +100,13 @@ func ReadTCPSession(user *protocol.MemoryUser, reader io.Reader) (*protocol.Requ
|
|||||||
|
|
||||||
if request.Option.Has(RequestOptionOneTimeAuth) && account.OneTimeAuth == Account_Disabled {
|
if request.Option.Has(RequestOptionOneTimeAuth) && account.OneTimeAuth == Account_Disabled {
|
||||||
readSizeRemain -= int(buffer.Len())
|
readSizeRemain -= int(buffer.Len())
|
||||||
DrainConnN(reader,readSizeRemain)
|
DrainConnN(reader, readSizeRemain)
|
||||||
return nil, nil, newError("rejecting connection with OTA enabled, while server disables OTA")
|
return nil, nil, newError("rejecting connection with OTA enabled, while server disables OTA")
|
||||||
}
|
}
|
||||||
|
|
||||||
if !request.Option.Has(RequestOptionOneTimeAuth) && account.OneTimeAuth == Account_Enabled {
|
if !request.Option.Has(RequestOptionOneTimeAuth) && account.OneTimeAuth == Account_Enabled {
|
||||||
readSizeRemain -= int(buffer.Len())
|
readSizeRemain -= int(buffer.Len())
|
||||||
DrainConnN(reader,readSizeRemain)
|
DrainConnN(reader, readSizeRemain)
|
||||||
return nil, nil, newError("rejecting connection with OTA disabled, while server enables OTA")
|
return nil, nil, newError("rejecting connection with OTA disabled, while server enables OTA")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -119,20 +118,20 @@ func ReadTCPSession(user *protocol.MemoryUser, reader io.Reader) (*protocol.Requ
|
|||||||
_, err := buffer.ReadFullFrom(br, AuthSize)
|
_, err := buffer.ReadFullFrom(br, AuthSize)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
readSizeRemain -= int(buffer.Len())
|
readSizeRemain -= int(buffer.Len())
|
||||||
DrainConnN(reader,readSizeRemain)
|
DrainConnN(reader, readSizeRemain)
|
||||||
return nil, nil, newError("Failed to read OTA").Base(err)
|
return nil, nil, newError("Failed to read OTA").Base(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !bytes.Equal(actualAuth, buffer.BytesFrom(-AuthSize)) {
|
if !bytes.Equal(actualAuth, buffer.BytesFrom(-AuthSize)) {
|
||||||
readSizeRemain -= int(buffer.Len())
|
readSizeRemain -= int(buffer.Len())
|
||||||
DrainConnN(reader,readSizeRemain)
|
DrainConnN(reader, readSizeRemain)
|
||||||
return nil, nil, newError("invalid OTA")
|
return nil, nil, newError("invalid OTA")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if request.Address == nil {
|
if request.Address == nil {
|
||||||
readSizeRemain -= int(buffer.Len())
|
readSizeRemain -= int(buffer.Len())
|
||||||
DrainConnN(reader,readSizeRemain)
|
DrainConnN(reader, readSizeRemain)
|
||||||
return nil, nil, newError("invalid remote address.")
|
return nil, nil, newError("invalid remote address.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ func (v *TimedUserValidator) Add(u *protocol.MemoryUser) error {
|
|||||||
|
|
||||||
account := uu.user.Account.(*MemoryAccount)
|
account := uu.user.Account.(*MemoryAccount)
|
||||||
if v.behaviorFused == false {
|
if v.behaviorFused == false {
|
||||||
hashkdf := hmac.New(func()hash.Hash{return sha256.New()}, []byte("VMESSBSKDF"))
|
hashkdf := hmac.New(func() hash.Hash { return sha256.New() }, []byte("VMESSBSKDF"))
|
||||||
hashkdf.Write(account.ID.Bytes())
|
hashkdf.Write(account.ID.Bytes())
|
||||||
v.behaviorSeed = crc64.Update(v.behaviorSeed, crc64.MakeTable(crc64.ECMA), hashkdf.Sum(nil))
|
v.behaviorSeed = crc64.Update(v.behaviorSeed, crc64.MakeTable(crc64.ECMA), hashkdf.Sum(nil))
|
||||||
}
|
}
|
||||||
|
@ -928,8 +928,8 @@ func TestVMessKCPLarge(t *testing.T) {
|
|||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
defer func(){
|
defer func() {
|
||||||
<-time.After(5*time.Second)
|
<-time.After(5 * time.Second)
|
||||||
CloseAllServers(servers)
|
CloseAllServers(servers)
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
@ -1178,8 +1178,8 @@ func TestVMessGCMMuxUDP(t *testing.T) {
|
|||||||
time.Sleep(time.Second)
|
time.Sleep(time.Second)
|
||||||
}
|
}
|
||||||
|
|
||||||
defer func(){
|
defer func() {
|
||||||
<-time.After(5*time.Second)
|
<-time.After(5 * time.Second)
|
||||||
CloseAllServers(servers)
|
CloseAllServers(servers)
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
|
|
||||||
"v2ray.com/core/common"
|
"v2ray.com/core/common"
|
||||||
"v2ray.com/core/common/net"
|
"v2ray.com/core/common/net"
|
||||||
"v2ray.com/core/transport/internet"
|
"v2ray.com/core/transport/internet"
|
||||||
|
Loading…
Reference in New Issue
Block a user