github.com/sagernet/sing-box@v1.9.0-rc.20/experimental/libbox/command_conntrack.go (about) 1 package libbox 2 3 import ( 4 "encoding/binary" 5 "net" 6 runtimeDebug "runtime/debug" 7 "time" 8 9 "github.com/sagernet/sing-box/common/conntrack" 10 ) 11 12 func (c *CommandClient) CloseConnections() error { 13 conn, err := c.directConnect() 14 if err != nil { 15 return err 16 } 17 defer conn.Close() 18 return binary.Write(conn, binary.BigEndian, uint8(CommandCloseConnections)) 19 } 20 21 func (s *CommandServer) handleCloseConnections(conn net.Conn) error { 22 conntrack.Close() 23 go func() { 24 time.Sleep(time.Second) 25 runtimeDebug.FreeOSMemory() 26 }() 27 return nil 28 }