sing-box/experimental/libbox/command_conntrack.go

29 lines
535 B
Go
Raw Permalink Normal View History

2023-03-03 11:26:54 +00:00
package libbox
import (
"encoding/binary"
"net"
runtimeDebug "runtime/debug"
"time"
2023-09-20 06:12:08 +00:00
"github.com/sagernet/sing-box/common/conntrack"
2023-03-03 11:26:54 +00:00
)
2023-07-02 08:45:30 +00:00
func (c *CommandClient) CloseConnections() error {
conn, err := c.directConnect()
2023-03-03 11:26:54 +00:00
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
}