mirror of
https://github.com/daeuniverse/dae.git
synced 2025-01-05 13:08:57 +07:00
optimize: show outbound name when notify kernel connectivity change
This commit is contained in:
parent
739682dabc
commit
791752399d
@ -517,7 +517,7 @@ func (d *Dialer) HttpCheck(ctx context.Context, u *netutils.URL, ip netip.Addr)
|
||||
if page := path.Base(req.URL.Path); strings.HasPrefix(page, "generate_") {
|
||||
return strconv.Itoa(resp.StatusCode) == strings.TrimPrefix(page, "generate_"), nil
|
||||
}
|
||||
return resp.StatusCode >= 200 && resp.StatusCode < 400, nil
|
||||
return resp.StatusCode >= 200 && resp.StatusCode < 500, nil
|
||||
}
|
||||
|
||||
func (d *Dialer) DnsCheck(ctx context.Context, dns netip.AddrPort, tcp bool) (ok bool, err error) {
|
||||
|
@ -26,9 +26,9 @@ func FormatL4Proto(l4proto uint8) string {
|
||||
func (c *ControlPlaneCore) OutboundAliveChangeCallback(outbound uint8) func(alive bool, networkType *dialer.NetworkType) {
|
||||
return func(alive bool, networkType *dialer.NetworkType) {
|
||||
c.log.WithFields(logrus.Fields{
|
||||
"alive": alive,
|
||||
"network": networkType.StringWithoutDns(),
|
||||
"outbound_id": outbound,
|
||||
"alive": alive,
|
||||
"network": networkType.StringWithoutDns(),
|
||||
"outbound": c.outboundId2Name[outbound],
|
||||
}).Warnf("Outbound alive state changed, notify the kernel program.")
|
||||
|
||||
value := uint32(0)
|
||||
|
@ -41,8 +41,7 @@ type ControlPlane struct {
|
||||
listenIp string
|
||||
|
||||
// TODO: add mutex?
|
||||
outbounds []*outbound.DialerGroup
|
||||
outboundName2Id map[string]uint8
|
||||
outbounds []*outbound.DialerGroup
|
||||
|
||||
SimulatedLpmTries [][]netip.Prefix
|
||||
SimulatedDomainSet []DomainSet
|
||||
@ -266,12 +265,15 @@ func NewControlPlane(
|
||||
return nil, fmt.Errorf("too many outbounds")
|
||||
}
|
||||
outboundName2Id := make(map[string]uint8)
|
||||
outboundId2Name := make(map[uint8]string)
|
||||
for i, o := range outbounds {
|
||||
if _, exist := outboundName2Id[o.Name]; exist {
|
||||
return nil, fmt.Errorf("duplicated outbound name: %v", o.Name)
|
||||
}
|
||||
outboundName2Id[o.Name] = uint8(i)
|
||||
outboundId2Name[uint8(i)] = o.Name
|
||||
}
|
||||
core.outboundId2Name = outboundId2Name
|
||||
builder := NewRoutingMatcherBuilder(outboundName2Id, &bpf)
|
||||
var rules []*config_parser.RoutingRule
|
||||
if rules, err = routing.ApplyRulesOptimizers(routingA.Rules,
|
||||
@ -304,7 +306,6 @@ func NewControlPlane(
|
||||
deferFuncs: nil,
|
||||
listenIp: "0.0.0.0",
|
||||
outbounds: outbounds,
|
||||
outboundName2Id: outboundName2Id,
|
||||
SimulatedLpmTries: builder.SimulatedLpmTries,
|
||||
SimulatedDomainSet: builder.SimulatedDomainSet,
|
||||
Final: routingA.Final,
|
||||
|
@ -21,9 +21,10 @@ import (
|
||||
)
|
||||
|
||||
type ControlPlaneCore struct {
|
||||
log *logrus.Logger
|
||||
deferFuncs []func() error
|
||||
bpf *bpfObjects
|
||||
log *logrus.Logger
|
||||
deferFuncs []func() error
|
||||
bpf *bpfObjects
|
||||
outboundId2Name map[uint8]string
|
||||
|
||||
kernelVersion *internal.Version
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user