世界 2 年之前
父節點
當前提交
5a4e8fea81

+ 2 - 0
experimental/libbox/config.go

@@ -1,3 +1,5 @@
+//go:build linux || darwin
+
 package libbox
 
 import (

+ 2 - 0
experimental/libbox/iterator.go

@@ -1,3 +1,5 @@
+//go:build linux || darwin
+
 package libbox
 
 import "github.com/sagernet/sing/common"

+ 0 - 54
experimental/libbox/log.go

@@ -1,54 +0,0 @@
-package libbox
-
-import (
-	"bufio"
-	"log"
-	"os"
-)
-
-type StandardOutput interface {
-	WriteOutput(message string)
-	WriteErrorOutput(message string)
-}
-
-func SetOutput(output StandardOutput) {
-	log.SetOutput(logWriter{output})
-	pipeIn, pipeOut, err := os.Pipe()
-	if err != nil {
-		panic(err)
-	}
-	os.Stdout = os.NewFile(pipeOut.Fd(), "stdout")
-	go lineLog(pipeIn, output.WriteOutput)
-
-	pipeIn, pipeOut, err = os.Pipe()
-	if err != nil {
-		panic(err)
-	}
-	os.Stderr = os.NewFile(pipeOut.Fd(), "srderr")
-	go lineLog(pipeIn, output.WriteErrorOutput)
-}
-
-type logWriter struct {
-	output StandardOutput
-}
-
-func (w logWriter) Write(p []byte) (n int, err error) {
-	w.output.WriteOutput(string(p))
-	return len(p), nil
-}
-
-func lineLog(f *os.File, output func(string)) {
-	const logSize = 1024 // matches android/log.h.
-	r := bufio.NewReaderSize(f, logSize)
-	for {
-		line, _, err := r.ReadLine()
-		str := string(line)
-		if err != nil {
-			str += " " + err.Error()
-		}
-		output(str)
-		if err != nil {
-			break
-		}
-	}
-}

+ 2 - 0
experimental/libbox/memory.go

@@ -1,3 +1,5 @@
+//go:build darwin
+
 package libbox
 
 import "runtime/debug"

+ 2 - 0
experimental/libbox/platform.go

@@ -1,3 +1,5 @@
+//go:build linux || darwin
+
 package libbox
 
 import "github.com/sagernet/sing-box/option"

+ 1 - 1
experimental/libbox/pprof.go

@@ -1,4 +1,4 @@
-//go:build debug
+//go:build linux || darwin
 
 package libbox
 

+ 0 - 21
experimental/libbox/pprof_stub.go

@@ -1,21 +0,0 @@
-//go:build !debug
-
-package libbox
-
-import (
-	"os"
-)
-
-type PProfServer struct{}
-
-func NewPProfServer(port int) *PProfServer {
-	return &PProfServer{}
-}
-
-func (s *PProfServer) Start() error {
-	return os.ErrInvalid
-}
-
-func (s *PProfServer) Close() error {
-	return os.ErrInvalid
-}

+ 2 - 0
experimental/libbox/service.go

@@ -1,3 +1,5 @@
+//go:build linux || darwin
+
 package libbox
 
 import (

+ 2 - 0
experimental/libbox/setup.go

@@ -1,3 +1,5 @@
+//go:build linux || darwin
+
 package libbox
 
 import (

+ 2 - 0
experimental/libbox/tun.go

@@ -1,3 +1,5 @@
+//go:build linux || darwin
+
 package libbox
 
 import (