• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

asciimoth / socksgo / 28323970844

28 Jun 2026 01:34PM UTC coverage: 94.066% (-0.09%) from 94.16%
28323970844

push

github

asciimoth
feat: add ProxySocks5UDPTunContext

37 of 39 new or added lines in 2 files covered. (94.87%)

3 existing lines in 1 file now uncovered.

3646 of 3876 relevant lines covered (94.07%)

1.38 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

89.66
/server_handler_connect.go
1
package socksgo
2

3
import (
4
        "context"
5
        "net"
6

7
        "github.com/asciimoth/gonnect"
8
        "github.com/asciimoth/socksgo/protocol"
9
)
10

11
// DefaultConnectHandler handles the CONNECT command.
12
//
13
// DefaultConnectHandler establishes a TCP connection to the target
14
// address and pipes data between the client and target.
15
//
16
// # Protocol Support
17
//
18
//   - SOCKS4: Yes
19
//   - SOCKS4a: Yes
20
//   - SOCKS5: Yes
21
//   - TLS: Yes
22
//
23
// # Behavior
24
//
25
//  1. Validates remote address against RaddrFilter
26
//  2. Dials target address using server's Dialer
27
//  3. Sends success reply with bound address
28
//  4. Pipes data bidirectionally until EOF or error
29
//
30
// # Reply
31
//
32
// Sends success reply (0x00) with the target's address.
33
//
34
// # Errors
35
//
36
// Returns error and sends appropriate reply status:
37
//   - DisallowReply (0x02): Address filtered
38
//   - HostUnreachReply (0x04): Dial failed
39
//   - FailReply (0x01): Other errors
40
//
41
// # Examples
42
//
43
//        // Default handler is used automatically
44
//        server := &socksgo.Server{
45
//            Handlers: socksgo.DefaultCommandHandlers,
46
//        }
47
//
48
// # See Also
49
//
50
//   - RFC 1928: SOCKS5 Protocol (Section 4)
51
//   - protocol.PipeConn: Connection piping implementation
52
var DefaultConnectHandler = CommandHandler{
53
        Socks4:    true,
54
        Socks5:    true,
55
        TLSCompat: true,
56
        Handler: func(
57
                ctx context.Context,
58
                server *Server,
59
                conn net.Conn,
60
                ver string,
61
                info protocol.AuthInfo,
62
                cmd protocol.Cmd,
63
                addr protocol.Addr) error {
1✔
64
                pool := server.GetPool()
1✔
65
                err := server.CheckRaddr(&addr)
1✔
66
                if err != nil {
2✔
67
                        protocol.Reject(ver, conn, protocol.DisallowReply, pool)
1✔
68
                        return err
1✔
69
                }
1✔
70
                conn2, err := server.GetDialer()(ctx, addr.Network(), addr.String())
1✔
71
                if err != nil {
2✔
72
                        protocol.Reject(ver, conn, errorToReplyStatus(err), pool)
1✔
73
                        return err
1✔
74
                }
1✔
75
                defer func() { _ = conn2.Close() }()
2✔
76
                err = protocol.Reply(
1✔
77
                        ver,
1✔
78
                        conn,
1✔
79
                        protocol.SuccReply,
1✔
80
                        protocol.AddrFromNetAddr(conn2.RemoteAddr()),
1✔
81
                        pool,
1✔
82
                )
1✔
83
                if err != nil {
2✔
84
                        return err
1✔
85
                }
1✔
86
                stopWatch := closeOnContextDone(ctx, func() {
1✔
UNCOV
87
                        _ = conn.Close()
×
UNCOV
88
                        _ = conn2.Close()
×
UNCOV
89
                })
×
90
                defer stopWatch()
1✔
91
                return gonnect.PipeConn(conn, conn2)
1✔
92
        },
93
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc