add entrypoint for router handler
This commit is contained in:
@@ -3,7 +3,6 @@ package router
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"net"
|
||||
|
||||
"github.com/go-gost/core/logger"
|
||||
"github.com/go-gost/core/router"
|
||||
@@ -45,21 +44,27 @@ func NewGRPCPlugin(name string, addr string, opts ...plugin.Option) router.Route
|
||||
return p
|
||||
}
|
||||
|
||||
func (p *grpcPlugin) GetRoute(ctx context.Context, dst net.IP, opts ...router.Option) *router.Route {
|
||||
func (p *grpcPlugin) GetRoute(ctx context.Context, dst string, opts ...router.Option) *router.Route {
|
||||
if p.client == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
var options router.Options
|
||||
for _, opt := range opts {
|
||||
opt(&options)
|
||||
}
|
||||
|
||||
r, err := p.client.GetRoute(ctx,
|
||||
&proto.GetRouteRequest{
|
||||
Dst: dst.String(),
|
||||
Dst: dst,
|
||||
Id: options.ID,
|
||||
})
|
||||
if err != nil {
|
||||
p.log.Error(err)
|
||||
return nil
|
||||
}
|
||||
|
||||
return xrouter.ParseRoute(r.Net, r.Gateway)
|
||||
return xrouter.ParseRoute(r.Dst, r.Gateway)
|
||||
}
|
||||
|
||||
func (p *grpcPlugin) Close() error {
|
||||
|
||||
Reference in New Issue
Block a user