Showing 25 of 39 total issues
Function netstack
has 64 lines of code (exceeds 50 allowed). Consider refactoring. Open
func netstack(k *Key) (err error) {
if k.Proxy == "" {
return errors.New("empty proxy")
}
if k.Device == "" {
Function ClientHandshake
has 14 return statements (exceeds 4 allowed). Open
func ClientHandshake(rw io.ReadWriter, addr Addr, command Command, user *User) (Addr, error) {
buf := make([]byte, MaxAddrLen)
var method uint8
if user != nil {
Method Relay.dialContext
has 54 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (rl *Relay) dialContext(ctx context.Context, metadata *M.Metadata) (rc *relayConn, err error) {
var c net.Conn
c, err = dialer.DialContext(ctx, "tcp", rl.Addr())
if err != nil {
Function netstack
has 10 return statements (exceeds 4 allowed). Open
func netstack(k *Key) (err error) {
if k.Proxy == "" {
return errors.New("empty proxy")
}
if k.Device == "" {
Method Relay.dialContext
has 7 return statements (exceeds 4 allowed). Open
func (rl *Relay) dialContext(ctx context.Context, metadata *M.Metadata) (rc *relayConn, err error) {
var c net.Conn
c, err = dialer.DialContext(ctx, "tcp", rl.Addr())
if err != nil {
Method Socks5.DialUDP
has 7 return statements (exceeds 4 allowed). Open
func (ss *Socks5) DialUDP(*M.Metadata) (_ net.PacketConn, err error) {
if ss.unix {
return nil, fmt.Errorf("%w when unix domain socket is enabled", errors.ErrUnsupported)
}
Function setSocketOptions
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
func setSocketOptions(network, address string, c syscall.RawConn, opts *Options) (err error) {
if opts == nil || !isTCPSocket(network) && !isUDPSocket(network) {
return
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid deeply nested control flow statements. Open
if j < len(keys)-1 {
b.WriteByte(',')
}
Function ClientHandshake
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
func ClientHandshake(rw io.ReadWriter, addr Addr, command Command, user *User) (Addr, error) {
buf := make([]byte, MaxAddrLen)
var method uint8
if user != nil {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function setSocketOptions
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
func setSocketOptions(network, address string, c syscall.RawConn, opts *Options) (err error) {
if opts == nil || !isTCPSocket(network) && !isUDPSocket(network) {
return
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function getConnections
has 6 return statements (exceeds 4 allowed). Open
func getConnections(w http.ResponseWriter, r *http.Request) {
if !websocket.IsWebSocketUpgrade(r) {
render.JSON(w, r, statistic.DefaultManager.Snapshot())
return
}
Function ReadAddr
has 6 return statements (exceeds 4 allowed). Open
func ReadAddr(r io.Reader, b []byte) (Addr, error) {
if len(b) < MaxAddrLen {
return nil, io.ErrShortBuffer
}
Method Reader.read
has 6 return statements (exceeds 4 allowed). Open
func (r *Reader) read(p []byte) (int, error) {
nonce := r.nonce[:r.NonceSize()]
tag := r.Overhead()
// decrypt payload size
Function Open
has 6 return statements (exceeds 4 allowed). Open
func Open(name string, mtu uint32) (device.Device, error) {
t := &TUN{name: name, mtu: mtu}
if len(t.name) >= unix.IFNAMSIZ {
return nil, fmt.Errorf("interface name too long: %s", t.name)
Method emitter.Emit
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
func (emitter) Emit(depth int, level glog.Level, _ time.Time, format string, args ...any) {
Method Addr.Valid
has 5 return statements (exceeds 4 allowed). Open
func (a Addr) Valid() bool {
if len(a) < 1+1+2 /* minimum length */ {
return false
}
Function Unpack
has 5 return statements (exceeds 4 allowed). Open
func Unpack(dst, pkt []byte, ciph Cipher) ([]byte, error) {
saltSize := ciph.SaltSize()
if len(pkt) < saltSize {
return nil, ErrShortPacket
}
Method TLSObfs.read
has 5 return statements (exceeds 4 allowed). Open
func (to *TLSObfs) read(b []byte, discardN int) (int, error) {
buf := pool.Get(discardN)
_, err := io.ReadFull(to.Conn, buf)
if err != nil {
return 0, err
Function PickCipher
has 5 return statements (exceeds 4 allowed). Open
func PickCipher(name string, key []byte, password string) (Cipher, error) {
name = strings.ToUpper(name)
switch name {
case "DUMMY":
Method relayConn.Read
has 5 return statements (exceeds 4 allowed). Open
func (rc *relayConn) Read(b []byte) (n int, err error) {
rc.once.Do(func() {
if rc.wbuf != nil {
err = readRelayResponse(rc.Conn)
}