mirror of
https://github.com/daeuniverse/dae.git
synced 2025-07-04 15:27:55 +07:00
fix: support exclamation mark in routingA
This commit is contained in:
@ -9,15 +9,15 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/cilium/ebpf"
|
||||
"github.com/cilium/ebpf/rlimit"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/v2rayA/dae/common"
|
||||
"github.com/v2rayA/dae/common/consts"
|
||||
"github.com/v2rayA/dae/component/outbound"
|
||||
"github.com/v2rayA/dae/component/outbound/dialer"
|
||||
"github.com/v2rayA/dae/component/routing"
|
||||
"github.com/v2rayA/dae/pkg/pool"
|
||||
"github.com/cilium/ebpf"
|
||||
"github.com/cilium/ebpf/rlimit"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/vishvananda/netlink"
|
||||
"golang.org/x/sys/unix"
|
||||
"net"
|
||||
@ -66,11 +66,11 @@ retry_load:
|
||||
}); err != nil {
|
||||
if errors.Is(err, ebpf.ErrMapIncompatible) {
|
||||
prefix := "use pinned map "
|
||||
iPrefix := strings.Index(err.Error(), prefix)
|
||||
if iPrefix == -1 {
|
||||
_, after, ok := strings.Cut(err.Error(), prefix)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("loading objects: bad format: %w", err)
|
||||
}
|
||||
mapName := strings.SplitN(err.Error()[iPrefix+len(prefix):], ":", 2)[0]
|
||||
mapName, _, _ := strings.Cut(after, ":")
|
||||
_ = os.Remove(filepath.Join(pinPath, mapName))
|
||||
log.Warnf("New map format was incompatible with existing map %v, and the old one was removed.", mapName)
|
||||
goto retry_load
|
||||
@ -114,7 +114,7 @@ retry_load:
|
||||
|
||||
rules, final, err := routing.Parse(routingA)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("routingA error: \n %w", err)
|
||||
return nil, fmt.Errorf("routingA error:\n%w", err)
|
||||
}
|
||||
if rules, err = routing.ApplyRulesOptimizers(rules,
|
||||
&routing.RefineFunctionParamKeyOptimizer{},
|
||||
@ -132,7 +132,7 @@ retry_load:
|
||||
log.Tracef("RoutingA:\n%vfinal: %v\n", debugBuilder.String(), final)
|
||||
}
|
||||
// TODO:
|
||||
d, err := dialer.NewFromLink("socks5://localhost:1080")
|
||||
d, err := dialer.NewFromLink("socks5://localhost:1080#proxy")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -9,10 +9,10 @@ import (
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/mzz2017/softwind/pkg/zeroalloc/io"
|
||||
"github.com/v2rayA/dae/common"
|
||||
"github.com/v2rayA/dae/common/consts"
|
||||
"golang.org/x/sys/unix"
|
||||
"io"
|
||||
"net"
|
||||
"net/netip"
|
||||
"time"
|
||||
|
@ -4,9 +4,9 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/v2rayA/dae/common/consts"
|
||||
"github.com/mzz2017/softwind/pkg/fastrand"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/v2rayA/dae/common/consts"
|
||||
"golang.org/x/net/proxy"
|
||||
"net"
|
||||
"net/http"
|
||||
@ -132,13 +132,13 @@ func (d *Dialer) Test(timeout time.Duration, url string) (ok bool, err error) {
|
||||
// No error.
|
||||
latency := time.Since(start)
|
||||
// FIXME: Use log instead of logrus.
|
||||
logrus.Debugf("Connectivity Test: %v: %v", d.name, latency)
|
||||
logrus.Debugf("Connectivity Test <%v>: %v", d.name, latency)
|
||||
d.Latencies10.AppendLatency(latency)
|
||||
alive = true
|
||||
} else {
|
||||
// Append timeout if there is any error or unexpected status code.
|
||||
if err != nil {
|
||||
logrus.Debugf("Test [%v]: %v", d.name, err.Error())
|
||||
logrus.Debugf("Connectivity Test <%v>: %v", d.name, err.Error())
|
||||
}
|
||||
d.Latencies10.AppendLatency(timeout)
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ package routing
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/antlr/antlr4/runtime/Go/antlr"
|
||||
"github.com/antlr/antlr4/runtime/Go/antlr/v4"
|
||||
"reflect"
|
||||
"strings"
|
||||
)
|
||||
|
@ -7,10 +7,10 @@ package routing
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/v2rayA/dae/common/assets"
|
||||
"github.com/v2rayA/dae/common/consts"
|
||||
"github.com/v2rayA/dae/pkg/geodata"
|
||||
"github.com/sirupsen/logrus"
|
||||
"net/netip"
|
||||
"sort"
|
||||
"strings"
|
||||
@ -211,6 +211,9 @@ func (o *DatReaderOptimizer) loadGeoIp(filename string, code string) (params []*
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if geoIp.InverseMatch {
|
||||
return nil, fmt.Errorf("not support inverse match yet")
|
||||
}
|
||||
for _, item := range geoIp.Cidr {
|
||||
ip, ok := netip.AddrFromSlice(item.Ip)
|
||||
if !ok {
|
||||
|
@ -7,7 +7,7 @@ package routing
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/antlr/antlr4/runtime/Go/antlr"
|
||||
"github.com/antlr/antlr4/runtime/Go/antlr/v4"
|
||||
"github.com/v2rayA/RoutingA-dist/go/routingA"
|
||||
)
|
||||
|
||||
|
@ -7,9 +7,9 @@ package routing
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/v2rayA/dae/common/consts"
|
||||
"github.com/antlr/antlr4/runtime/Go/antlr"
|
||||
"github.com/antlr/antlr4/runtime/Go/antlr/v4"
|
||||
"github.com/v2rayA/RoutingA-dist/go/routingA"
|
||||
"github.com/v2rayA/dae/common/consts"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
@ -120,7 +120,7 @@ func (s *RoutingAWalker) reportKeyUnsupportedError(ctx interface{}, keyName, fun
|
||||
func (s *RoutingAWalker) parseFunctionPrototype(ctx *routingA.FunctionPrototypeContext) *Function {
|
||||
children := ctx.GetChildren()
|
||||
funcName := children[0].(*antlr.TerminalNodeImpl).GetText()
|
||||
paramList := children[2].(*routingA.ParameterListContext)
|
||||
paramList := children[2].(*routingA.OptParameterListContext)
|
||||
children = paramList.GetChildren()
|
||||
if len(children) == 0 {
|
||||
s.ReportError(ctx, ErrorType_Unsupported, "empty parameter list")
|
||||
@ -145,8 +145,7 @@ func (s *RoutingAWalker) parseFunctionPrototype(ctx *routingA.FunctionPrototypeC
|
||||
}
|
||||
case "ip":
|
||||
switch param.Key {
|
||||
case "",
|
||||
"geoip":
|
||||
case "", "geoip":
|
||||
default:
|
||||
s.reportKeyUnsupportedError(ctx, param.Key, funcName)
|
||||
return nil
|
||||
@ -203,15 +202,21 @@ func (s *RoutingAWalker) EnterDeclaration(ctx *routingA.DeclarationContext) {
|
||||
|
||||
func (s *RoutingAWalker) EnterRoutingRule(ctx *routingA.RoutingRuleContext) {
|
||||
children := ctx.GetChildren()
|
||||
left, ok := children[0].(*routingA.FunctionPrototypeExpressionContext)
|
||||
left, ok := children[0].(*routingA.RoutingRuleLeftContext)
|
||||
if !ok {
|
||||
s.ReportError(ctx, ErrorType_Unsupported)
|
||||
s.ReportError(ctx, ErrorType_Unsupported, "not *RoutingRuleLeftContext: "+ctx.GetText())
|
||||
return
|
||||
}
|
||||
outbound := children[2].(*routingA.Bare_literalContext).GetText()
|
||||
// Parse functions.
|
||||
var andFunctions []*Function
|
||||
children = left.GetChildren()
|
||||
functionList, ok := children[1].(*routingA.FunctionPrototypeExpressionContext)
|
||||
if !ok {
|
||||
s.ReportError(ctx, ErrorType_Unsupported, "not *FunctionPrototypeExpressionContext: "+ctx.GetText())
|
||||
return
|
||||
}
|
||||
children = functionList.GetChildren()
|
||||
for _, child := range children {
|
||||
// And rules.
|
||||
if child, ok := child.(*routingA.FunctionPrototypeContext); ok {
|
||||
|
Reference in New Issue
Block a user