create nc clone in golang #1
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Implementation Specification
Objective
Build a functional netcat clone in Go from scratch that provides basic network connectivity and data transfer capabilities.
Requirements
Flags
-l-p-n-v-x-e-u-w-zFiles to Create
go.modmain.gocmd/connect.gocmd/listen.gonet/connection.gonet/resolve.goutil/hexdump.goutil/timeout.gomain_test.goStep-by-Step Implementation Plan
Step 1: Initialize Go module, create directory structure, stub main.go
Step 2: Implement flag parsing and entry point with validation
Step 3: Implement core connection logic (dial, pipe I/O)
Step 4: Implement connect mode (TCP/UDP client)
Step 5: Implement listen mode (TCP/UDP server)
Step 6: Implement DNS resolution
Step 7: Implement hex dump utility
Step 8: Implement timeout utilities
Step 9: Add unit tests
Acceptance Criteria
nc -hdisplays usage message with all flags documentednc -l -p 8080listens on port 8080 and accepts one connectionnc host 80connects to remote host on port 80nc -e /bin/sh -l -p 8080spawns a shell on incoming connectionnc -v host 80shows verbose connection infonc -x host 80outputs hex dump of transmitted datanc -u host 53uses UDP instead of TCPnc -w 5 host 80times out after 5 secondsnc -z -l -p 8080scans port (accepts and closes immediately)go test ./...)Notes
-eflag creates a remote shell; document thisTest Results
All tests pass:
Binary builds successfully (
go build -o nc .).