{"record":{"id":"3cfff34e1fc6e8fb","repo":"ginuerzh/gost","slug":"tap-is-not-supported-on-darwin","errorCode":null,"errorMessage":"tap is not supported on darwin","messagePattern":"tap is not supported on darwin","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tuntap_darwin.go","lineNumber":62,"sourceCode":"\n\tif err = addTunRoutes(ifce.Name(), cfg.Routes...); err != nil {\n\t\treturn\n\t}\n\n\titf, err = net.InterfaceByName(ifce.Name())\n\tif err != nil {\n\t\treturn\n\t}\n\n\tconn = &tunTapConn{\n\t\tifce: ifce,\n\t\taddr: &net.IPAddr{IP: ip},\n\t}\n\treturn\n}\n\nfunc createTap(cfg TapConfig) (conn net.Conn, itf *net.Interface, err error) {\n\terr = errors.New(\"tap is not supported on darwin\")\n\treturn\n}\n\nfunc addTunRoutes(ifName string, routes ...IPRoute) error {\n\tfor _, route := range routes {\n\t\tif route.Dest == nil {\n\t\t\tcontinue\n\t\t}\n\t\tcmd := fmt.Sprintf(\"route add -net %s -interface %s\", route.Dest.String(), ifName)\n\t\tlog.Log(\"[tun]\", cmd)\n\t\targs := strings.Split(cmd, \" \")\n\t\tif er := exec.Command(args[0], args[1:]...).Run(); er != nil {\n\t\t\treturn fmt.Errorf(\"%s: %v\", cmd, er)\n\t\t}\n\t}\n\treturn nil\n}\n","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/ginuerzh/gost/blob/a33fdbf4c98034f4bfeeaea9868909822b9c526d/tuntap_darwin.go#L44-L80","documentation":"On macOS (darwin), createTap is a stub that unconditionally returns 'tap is not supported on darwin'. The library does not implement TAP device creation on macOS, so any attempt to start a TAP-mode interface there fails immediately at setup.","triggerScenarios":"Starting a TAP (ethernet) tunnel on macOS via createTap(TapConfig) — e.g. running a gost TAP route with -L 'tap://...' on darwin.","commonSituations":"Developing/testing VPN-style taps on a Mac; copying a Linux TAP config to macOS; CI on darwin runners exercising TAP features.","solutions":["Use TUN mode instead of TAP on macOS (the library supports tun on darwin).","Run the TAP endpoint on a Linux host; keep the macOS machine as a TUN client.","Guard the config at startup: check runtime.GOOS == \"darwin\" before enabling TAP and fall back to TUN or fail with a clear message."],"exampleFix":"// before\nlistener, err := TapListener(...) // darwin -> 'tap is not supported on darwin'\n// after\nif runtime.GOOS == \"darwin\" {\n    // use TUN instead\n    listener, err = TunListener(...)\n} else {\n    listener, err = TapListener(...)\n}\n","handlingStrategy":"fallback","validationCode":"if runtime.GOOS == \"darwin\" && mode == \"tap\" {\n    return errors.New(\"tap is unsupported on darwin; use tun mode\")\n}","typeGuard":"func tapSupported() bool {\n    return runtime.GOOS != \"darwin\"\n}","tryCatchPattern":"conn, itf, err := createTap(cfg)\nif err != nil {\n    if runtime.GOOS == \"darwin\" {\n        conn, itf, err = createTun(cfg.ToTunConfig()) // fall back to TUN\n    }\n    if err != nil { return err }\n}","preventionTips":["Check runtime.GOOS before configuring TAP on macOS.","Prefer TUN (IP-layer) tunnels for cross-platform clients.","Keep Linux hosts for ethernet-bridged (TAP) deployments.","Add a startup config validation step that rejects tap mode on darwin."],"tags":["tuntap","tap","darwin","macos","platform-limitation"],"backgroundTag":"unsupported-platform","analyzedSha":"a33fdbf4c98034f4bfeeaea9868909822b9c526d","analyzedAt":"2026-09-02T22:15:54.506Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}