mirror of
https://github.com/SagerNet/sing-box.git
synced 2024-12-25 13:25:38 +08:00
31 lines
583 B
Go
31 lines
583 B
Go
//go:build darwin
|
|
|
|
package libbox
|
|
|
|
import (
|
|
"encoding/binary"
|
|
"net"
|
|
runtimeDebug "runtime/debug"
|
|
"time"
|
|
|
|
"github.com/sagernet/sing-box/common/dialer/conntrack"
|
|
)
|
|
|
|
func ClientCloseConnections(sharedDirectory string) error {
|
|
conn, err := clientConnect(sharedDirectory)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
defer conn.Close()
|
|
return binary.Write(conn, binary.BigEndian, uint8(CommandCloseConnections))
|
|
}
|
|
|
|
func (s *CommandServer) handleCloseConnections(conn net.Conn) error {
|
|
conntrack.Close()
|
|
go func() {
|
|
time.Sleep(time.Second)
|
|
runtimeDebug.FreeOSMemory()
|
|
}()
|
|
return nil
|
|
}
|