{"record":{"id":"16a552e1eafa0387","repo":"ginuerzh/gost","slug":"deadline-not-supported-16a552","errorCode":null,"errorMessage":"deadline not supported","messagePattern":"deadline not supported","errorType":"exception","errorClass":"net.OpError","httpStatus":null,"severity":"warning","filePath":"tuntap.go","lineNumber":801,"sourceCode":"\nfunc (c *tunTapConn) Write(b []byte) (n int, err error) {\n\treturn c.ifce.Write(b)\n}\n\nfunc (c *tunTapConn) Close() (err error) {\n\treturn c.ifce.Close()\n}\n\nfunc (c *tunTapConn) LocalAddr() net.Addr {\n\treturn c.addr\n}\n\nfunc (c *tunTapConn) RemoteAddr() net.Addr {\n\treturn &net.IPAddr{}\n}\n\nfunc (c *tunTapConn) SetDeadline(t time.Time) error {\n\treturn &net.OpError{Op: \"set\", Net: \"tuntap\", Source: nil, Addr: nil, Err: errors.New(\"deadline not supported\")}\n}\n\nfunc (c *tunTapConn) SetReadDeadline(t time.Time) error {\n\treturn &net.OpError{Op: \"set\", Net: \"tuntap\", Source: nil, Addr: nil, Err: errors.New(\"deadline not supported\")}\n}\n\nfunc (c *tunTapConn) SetWriteDeadline(t time.Time) error {\n\treturn &net.OpError{Op: \"set\", Net: \"tuntap\", Source: nil, Addr: nil, Err: errors.New(\"deadline not supported\")}\n}\n\n// IsIPv6Multicast reports whether the address addr is an IPv6 multicast address.\nfunc IsIPv6Multicast(addr net.HardwareAddr) bool {\n\treturn addr[0] == 0x33 && addr[1] == 0x33\n}\n","sourceCodeStart":783,"sourceCodeEnd":816,"githubUrl":"https://github.com/ginuerzh/gost/blob/a33fdbf4c98034f4bfeeaea9868909822b9c526d/tuntap.go#L783-L816","documentation":"tunTapConn.SetDeadline always returns a *net.OpError wrapping 'deadline not supported'. The TUN/TAP connection is backed by an os-level device file whose read/write loops do not support deadlines, so the interface method is implemented to explicitly reject deadline calls.","triggerScenarios":"Calling SetDeadline on a tunTapConn — e.g. wrapping the TUN/TAP conn in code that calls net.Conn deadline methods (custom timeouts, io copy helpers like SetDeadline before Read/Write, or libraries such as TLS handshake timeouts).","commonSituations":"Using the TAP/TUN conn as a drop-in net.Conn inside a library that sets deadlines unconditionally (crypto/tls, QUIC, HTTP clients); writing generic connection wrappers that call SetDeadline on every conn they handle.","solutions":["Do not set deadlines on tunTapConn; rely on context/cancellation around the copy loops instead.","Wrap the conn so deadline calls become no-ops: define SetDeadline/SetReadDeadline/SetWriteDeadline to return nil.","Detect this error (net.OpError with Err 'deadline not supported') and treat it as non-fatal in generic net.Conn handling code."],"exampleFix":"// before\nconn.SetDeadline(time.Now().Add(5 * time.Second)) // returns OpError\n// after\ntype noDeadlineConn struct{ net.Conn }\nfunc (c noDeadlineConn) SetDeadline(t time.Time) error      { return nil }\nfunc (c noDeadlineConn) SetReadDeadline(t time.Time) error  { return nil }\nfunc (c noDeadlineConn) SetWriteDeadline(t time.Time) error { return nil }\n","handlingStrategy":"fallback","validationCode":null,"typeGuard":"func supportsDeadlines(c net.Conn) bool {\n    type d interface{ SetDeadline(time.Time) error }\n    _, ok := c.(d)\n    return ok\n}\n// Note: tunTapConn implements SetDeadline but always errors; treat it specially.","tryCatchPattern":"if err := conn.SetDeadline(time.Now().Add(timeout)); err != nil {\n    var opErr *net.OpError\n    if errors.As(err, &opErr) && opErr.Err.Error() == \"deadline not supported\" {\n        // fall back to timer + Close based timeout\n    }\n}","preventionTips":["Never assume every net.Conn supports deadlines; document deadline requirements.","Wrap device-backed conns in a deadline-stripping adapter.","Use context.Context for timeouts instead of conn deadlines where possible.","Test wrappers against TUN/TAP conns, not only TCP conns."],"tags":["tuntap","deadline","net-conn","unsupported-operation"],"backgroundTag":"deadline-not-supported","analyzedSha":"a33fdbf4c98034f4bfeeaea9868909822b9c526d","analyzedAt":"2026-09-02T22:15:54.506Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}