Skip to content

Latest commit

 

History

History
67 lines (50 loc) · 2.68 KB

File metadata and controls

67 lines (50 loc) · 2.68 KB

Examples

简体中文 | Docs Index

Example 1: Add the Module to an Application

mkdir gnalloy-app && cd gnalloy-app
go mod init example.com/gnalloy-app
go get gnalloy.org/handler-proxy@dev
go doc gnalloy.org/handler-proxy

Example 2: Inspect Current Packages

The current source tree exposes these package import paths:

  • gnalloy.org/handler-proxy

Use go doc against the package that matches the behavior you need:

go doc gnalloy.org/handler-proxy

Selected current exported entry points:

  • const SOCKS4Version byte = 0x04 ...
  • const SOCKS5Version byte = 0x05 ...
  • var ErrNeedMore = errors.New("gnalloy/handler/proxy: need more bytes") ...
  • func AppendHTTPConnectRequest(dst []byte, req HTTPConnectRequest) ([]byte, error)
  • func AppendSOCKS4Bind(dst []byte, address string, userID string) ([]byte, error)
  • func AppendSOCKS4Command(dst []byte, command byte, address string, userID string) ([]byte, error)

Example 3: Use Executable Tests as Behavioral Examples

Repository tests are executable examples of supported behavior. Start with the selected names below, then read the matching _test.go files for complete setup and assertions. See Testing and Performance for the complete discovered list.

GOWORK=off GOTOOLCHAIN=local go test ./... -run Test -count=1

Selected current test, benchmark, fuzz, and example entry points:

  • TestHTTPConnectClientWritesRequestAndEmitsEvent
  • TestHTTPConnectRequestAndResponse
  • TestParseHAProxyV1AndV2
  • TestSOCKS4ClientRejectsHandshakeFailure
  • TestSOCKS4ClientWritesConnectAndEmitsEvent
  • TestSOCKS4ConnectHelpers
  • TestSOCKS5ClientRejectsHandshakeFailure
  • TestSOCKS5ClientUsernamePasswordAuth
  • TestSOCKS5ClientWritesGreetingConnectAndEmitsEvent
  • TestSOCKS5CommandHelpersEncodeBindAndUDPAssociate
  • TestSOCKS5GreetingConnectAndReply
  • TestSOCKS5UsernamePasswordAuthHelpers

Example 4: Cross-Module Assembly

Direct Gnalloy dependencies for this module:

  • gnalloy.org/gnalloy

Assembly guidance:

  • Use this handler inside a Gnalloy pipeline to apply policy, lifecycle, protection, logging, metrics, or traffic behavior.
  • Keep protocol parsing in codec modules and socket ownership in transport modules.
  • Place the handler where its inbound and outbound semantics match the selected protocol stack.

Example 5: Pressure-Test Harness

For sustained load, wire this module into a scenario under gnalloy.org/benchmarks or a runnable client under gnalloy.org/examples when the module participates in network traffic. Record host, OS, CPU, Go version, protocol, payload, concurrency, warmup, repetitions, throughput, and p99 latency in the report.