mirror of
https://github.com/SagerNet/sing-box.git
synced 2024-11-16 14:32:21 +08:00
25 lines
745 B
Go
25 lines
745 B
Go
package experimental
|
|
|
|
import (
|
|
"os"
|
|
|
|
"github.com/sagernet/sing-box/adapter"
|
|
"github.com/sagernet/sing-box/log"
|
|
"github.com/sagernet/sing-box/option"
|
|
)
|
|
|
|
type ClashServerConstructor = func(router adapter.Router, logFactory log.ObservableFactory, options option.ClashAPIOptions) (adapter.ClashServer, error)
|
|
|
|
var clashServerConstructor ClashServerConstructor
|
|
|
|
func RegisterClashServerConstructor(constructor ClashServerConstructor) {
|
|
clashServerConstructor = constructor
|
|
}
|
|
|
|
func NewClashServer(router adapter.Router, logFactory log.ObservableFactory, options option.ClashAPIOptions) (adapter.ClashServer, error) {
|
|
if clashServerConstructor == nil {
|
|
return nil, os.ErrInvalid
|
|
}
|
|
return clashServerConstructor(router, logFactory, options)
|
|
}
|