add entrypoint for router handler

This commit is contained in:
ginuerzh
2025-02-08 23:07:54 +08:00
parent 9cd03b6b59
commit 08ad260606
14 changed files with 259 additions and 122 deletions
+9 -4
View File
@@ -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 {