샘플
golang.org/x/net v0.17.0: proxy.Direct
검증된 샘플 — golang golang.org/x/net v0.17.0: proxy.Direct. go 1.26 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: proxy.Direct implements proxy.Dialer and…
sha256:c84e07011aaf497e269decac1790c5bfbccb6f47b547ef526fe83d42ec3fa5f5
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
linux 24 · ubuntu · glibc 2.39 x64 go
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| go 1.26 · linux debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · golang@1golang:1.26@sha256:e30143be198a… |
2026-09-01 |
케이스
HOW- 목표
- verify proxy.Direct in pkg:golang/golang.org/x/net@v0.17.0
- 심벌
-
- proxy.Direct
- 생성일
- 2026-09-01T01:37:08Z
컨트랙트
- proxy.Direct implements proxy.Dialer and proxy.ContextDialer for direct network connections
- proxy.Direct.Dial connects to local TCP listeners and supports full duplex communication
- proxy.Direct.DialContext honors context cancellation and timeout deadlines
- proxy.Direct.Dial returns a network error when dialing an invalid or unreachable address
파일
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract.go
소스
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify proxy.Direct in pkg:golang/golang.org/x/net@v0.17.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/golang.org/x/net@v0.17.0
Demonstrate these symbols/APIs:
- proxy.Direct
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- packageManager: npm@10.9.8
- runtime: node@22.23.2
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"case":{"caseId":"case:sha256:d13b9fa35ea9803d21058d0e754b31646631078dfddbca5881e1a3d0e3197aa5","contract":["proxy.Direct implements proxy.Dialer and proxy.ContextDialer for direct network connections","proxy.Direct.Dial connects to local TCP listeners and supports full duplex communication","proxy.Direct.DialContext honors context cancellation and timeout deadlines","proxy.Direct.Dial returns a network error when dialing an invalid or unreachable address"],"goal":"verify proxy.Direct in pkg:golang/golang.org/x/net@v0.17.0","kind":"HOW","packages":["pkg:golang/golang.org/x/net@v0.17.0"],"schemaVersion":1,"symbols":["proxy.Direct"]},"contractCommand":["go","run","./test"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"golang","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"go","schemaVersion":1},"license":"MIT-0","packages":["pkg:golang/golang.org/x/net@v0.17.0"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/net@v0.17.0","symbols":["proxy.Direct"],"verifierAdapter":"golang@1"}
module example.com/sample
go 1.25.0
require golang.org/x/net v0.17.0
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
package main
import (
"context"
"fmt"
"io"
"log"
"net"
"time"
"golang.org/x/net/proxy"
)
func main() {
listener, err := net.Listen("tcp", "127.0.0.1:0")
if err != nil {
log.Fatalf("Failed to start listener: %v", err)
}
defer listener.Close()
go func() {
for {
conn, err := listener.Accept()
if err != nil {
return
}
go func(c net.Conn) {
defer c.Close()
io.Copy(c, c)
}(conn)
}
}()
// 1. Direct dial using proxy.Direct.Dial
conn, err := proxy.Direct.Dial("tcp", listener.Addr().String())
if err != nil {
log.Fatalf("proxy.Direct.Dial failed: %v", err)
}
defer conn.Close()
message := "hello proxy.Direct"
if _, err := conn.Write([]byte(message)); err != nil {
log.Fatalf("Failed to write to connection: %v", err)
}
buf := make([]byte, len(message))
if _, err := io.ReadFull(conn, buf); err != nil {
log.Fatalf("Failed to read from connection: %v", err)
}
fmt.Printf("Received echo: %s\n", string(buf))
// 2. Direct dial using proxy.ContextDialer interface
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
defer cancel()
if ctxDialer, ok := any(proxy.Direct).(proxy.ContextDialer); ok {
ctxConn, err := ctxDialer.DialContext(ctx, "tcp", listener.Addr().String())
if err != nil {
log.Fatalf("proxy.Direct.DialContext failed: %v", err)
}
defer ctxConn.Close()
}
fmt.Println("proxy.Direct verification complete.")
}
{
"schemaVersion": 1,
"goal": "verify proxy.Direct in pkg:golang/golang.org/x/net@v0.17.0",
"kind": "HOW",
"packages": [
"pkg:golang/golang.org/x/net@v0.17.0"
],
"symbols": [
"proxy.Direct"
]
}
package main
import (
"bytes"
"context"
"errors"
"fmt"
"io"
"net"
"os"
"time"
"golang.org/x/net/proxy"
)
func main() {
// Assertion 1: proxy.Direct implements proxy.Dialer interface
{
var dialer proxy.Dialer = proxy.Direct
if dialer == nil {
fmt.Fprintf(os.Stderr, "Contract 1 failed: proxy.Direct does not satisfy proxy.Dialer\n")
os.Exit(1)
}
}
// Assertion 2: proxy.Direct implements proxy.ContextDialer interface
{
ctxDialer, ok := any(proxy.Direct).(proxy.ContextDialer)
if !ok || ctxDialer == nil {
fmt.Fprintf(os.Stderr, "Contract 2 failed: proxy.Direct does not satisfy proxy.ContextDialer\n")
os.Exit(1)
}
}
// Set up an offline in-process TCP listener
listener, err := net.Listen("tcp", "127.0.0.1:0")
if err != nil {
fmt.Fprintf(os.Stderr, "Setup failed: net.Listen error: %v\n", err)
os.Exit(1)
}
defer listener.Close()
go func() {
for {
conn, err := listener.Accept()
if err != nil {
return
}
go func(c net.Conn) {
defer c.Close()
buf := make([]byte, 1024)
n, err := c.Read(buf)
if err == nil && n > 0 {
c.Write(buf[:n])
}
}(conn)
}
}()
addr := listener.Addr().String()
// Assertion 3: proxy.Direct.Dial connects to local TCP listener and transfers data
{
conn, err := proxy.Direct.Dial("tcp", addr)
if err != nil {
fmt.Fprintf(os.Stderr, "Contract 3 failed: proxy.Direct.Dial error: %v\n", err)
os.Exit(1)
}
defer conn.Close()
payload := []byte("ping-direct-dial")
if _, err := conn.Write(payload); err != nil {
fmt.Fprintf(os.Stderr, "Contract 3 failed: conn.Write error: %v\n", err)
os.Exit(1)
}
reply := make([]byte, len(payload))
if _, err := io.ReadFull(conn, reply); err != nil {
fmt.Fprintf(os.Stderr, "Contract 3 failed: io.ReadFull error: %v\n", err)
os.Exit(1)
}
if !bytes.Equal(reply, payload) {
fmt.Fprintf(os.Stderr, "Contract 3 failed: reply mismatch: expected %q, got %q\n", payload, reply)
os.Exit(1)
}
}
// Assertion 4: proxy.Direct.DialContext connects with an active context
{
ctxDialer := any(proxy.Direct).(proxy.ContextDialer)
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
defer cancel()
conn, err := ctxDialer.DialContext(ctx, "tcp", addr)
if err != nil {
fmt.Fprintf(os.Stderr, "Contract 4 failed: DialContext error: %v\n", err)
os.Exit(1)
}
defer conn.Close()
payload := []byte("ping-context-dial")
if _, err := conn.Write(payload); err != nil {
fmt.Fprintf(os.Stderr, "Contract 4 failed: conn.Write error: %v\n", err)
os.Exit(1)
}
reply := make([]byte, len(payload))
if _, err := io.ReadFull(conn, reply); err != nil {
fmt.Fprintf(os.Stderr, "Contract 4 failed: io.ReadFull error: %v\n", err)
os.Exit(1)
}
if !bytes.Equal(reply, payload) {
fmt.Fprintf(os.Stderr, "Contract 4 failed: reply mismatch: expected %q, got %q\n", payload, reply)
os.Exit(1)
}
}
// Assertion 5: proxy.Direct.DialContext honors canceled context
{
ctxDialer := any(proxy.Direct).(proxy.ContextDialer)
ctx, cancel := context.WithCancel(context.Background())
cancel() // Cancel immediately before dial
_, err := ctxDialer.DialContext(ctx, "tcp", addr)
if err == nil {
fmt.Fprintf(os.Stderr, "Contract 5 failed: expected error with canceled context, got nil\n")
os.Exit(1)
}
if !errors.Is(err, context.Canceled) && !errors.Is(ctx.Err(), context.Canceled) {
fmt.Fprintf(os.Stderr, "Contract 5 failed: expected context.Canceled error, got: %v\n", err)
os.Exit(1)
}
}
// Assertion 6: proxy.Direct.Dial fails when dialing an invalid network/address
{
_, err := proxy.Direct.Dial("invalid_network", "127.0.0.1:0")
if err == nil {
fmt.Fprintf(os.Stderr, "Contract 6 failed: expected error for unknown network, got nil\n")
os.Exit(1)
}
}
fmt.Println("All contract assertions passed.")
}
오리진 시더
익명