2015-10-28 22:18:07 +00:00
|
|
|
package router
|
|
|
|
|
|
|
|
import (
|
2015-10-30 21:50:45 +00:00
|
|
|
"github.com/v2ray/v2ray-core/app/point/config"
|
2015-10-28 22:18:07 +00:00
|
|
|
v2net "github.com/v2ray/v2ray-core/common/net"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Router interface {
|
|
|
|
TakeDetour(v2net.Packet) (config.ConnectionTag, error)
|
|
|
|
}
|
|
|
|
|
|
|
|
type RouterFactory interface {
|
|
|
|
Create(rawConfig interface{}) (Router, error)
|
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
|
|
|
routerCache = make(map[string]RouterFactory)
|
|
|
|
)
|
|
|
|
|
|
|
|
func RegisterRouter(name string, factory RouterFactory) error {
|
|
|
|
// TODO: check name
|
|
|
|
routerCache[name] = factory
|
|
|
|
return nil
|
|
|
|
}
|