mirror of
https://github.com/SagerNet/sing.git
synced 2025-04-03 20:07:38 +03:00
27 lines
422 B
Go
27 lines
422 B
Go
package network
|
|
|
|
import (
|
|
"github.com/sagernet/sing/common"
|
|
)
|
|
|
|
type ReadCloser interface {
|
|
CloseRead() error
|
|
}
|
|
|
|
type WriteCloser interface {
|
|
CloseWrite() error
|
|
}
|
|
|
|
func CloseRead(reader any) error {
|
|
if c, ok := common.Cast[ReadCloser](reader); ok {
|
|
return c.CloseRead()
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func CloseWrite(writer any) error {
|
|
if c, ok := common.Cast[WriteCloser](writer); ok {
|
|
return c.CloseWrite()
|
|
}
|
|
return nil
|
|
}
|