Add net control funcs

This commit is contained in:
世界 2022-06-30 17:39:41 +08:00
parent a784aec420
commit ddfe73e899
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
7 changed files with 97 additions and 0 deletions

View file

@ -0,0 +1,21 @@
package control
import (
"syscall"
)
type Func = func(network, address string, conn syscall.RawConn) error
func Append(oldFunc Func, newFunc Func) Func {
if oldFunc == nil {
return newFunc
} else if newFunc == nil {
return oldFunc
}
return func(network, address string, conn syscall.RawConn) error {
if err := oldFunc(network, address, conn); err != nil {
return err
}
return newFunc(network, address, conn)
}
}