mirror of
https://github.com/daeuniverse/dae.git
synced 2024-12-22 20:24:40 +07:00
chore: allow NOSTRIP
This commit is contained in:
parent
fe3f9c62c3
commit
feaf05af08
8
Makefile
8
Makefile
@ -13,6 +13,12 @@ TARGET ?= bpfel,bpfeb
|
||||
OUTPUT ?= dae
|
||||
MAX_MATCH_SET_LEN ?= 64
|
||||
CFLAGS := -DMAX_MATCH_SET_LEN=$(MAX_MATCH_SET_LEN) $(CFLAGS)
|
||||
NOSTRIP ?= n
|
||||
ifeq ($(strip $(NOSTRIP)),y)
|
||||
STRIP_FLAG := -no-strip
|
||||
else
|
||||
STRIP_FLAG := -strip=$(STRIP)
|
||||
endif
|
||||
|
||||
# Get version from .git.
|
||||
date=$(shell git log -1 --format="%cd" --date=short | sed s/-//g)
|
||||
@ -35,7 +41,7 @@ clean-ebpf:
|
||||
|
||||
# $BPF_CLANG is used in go:generate invocations.
|
||||
ebpf: export BPF_CLANG := $(CLANG)
|
||||
ebpf: export BPF_STRIP := $(STRIP)
|
||||
ebpf: export BPF_STRIP_FLAG := $(STRIP_FLAG)
|
||||
ebpf: export BPF_CFLAGS := $(CFLAGS)
|
||||
ebpf: export BPF_TARGET := $(TARGET)
|
||||
ebpf: clean-ebpf
|
||||
|
@ -5,6 +5,4 @@
|
||||
|
||||
package control
|
||||
|
||||
// $BPF_CLANG, $BPF_STRIP, $BPF_CFLAGS, $BPF_TARGET are set by the Makefile.
|
||||
//go:generate go run github.com/cilium/ebpf/cmd/bpf2go -cc $BPF_CLANG -strip $BPF_STRIP -cflags $BPF_CFLAGS -target $BPF_TARGET bpf kern/tproxy.c -- -I./headers
|
||||
|
||||
//go:generate go run github.com/cilium/ebpf/cmd/bpf2go -cc "$BPF_CLANG" "$BPF_STRIP_FLAG" -cflags "$BPF_CFLAGS" -target "$BPF_TARGET" bpf kern/tproxy.c -- -I./headers
|
||||
|
@ -58,7 +58,7 @@ type ControlPlane struct {
|
||||
closed chan struct{}
|
||||
ready chan struct{}
|
||||
|
||||
muRealDomainSet sync.RWMutex
|
||||
muRealDomainSet sync.Mutex
|
||||
realDomainSet *bloom.BloomFilter
|
||||
}
|
||||
|
||||
@ -323,7 +323,7 @@ func NewControlPlane(
|
||||
routingMatcher: routingMatcher,
|
||||
closed: make(chan struct{}),
|
||||
ready: make(chan struct{}),
|
||||
muRealDomainSet: sync.RWMutex{},
|
||||
muRealDomainSet: sync.Mutex{},
|
||||
realDomainSet: bloom.NewWithEstimates(2048, 0.001),
|
||||
}
|
||||
defer func() {
|
||||
@ -478,21 +478,22 @@ func (c *ControlPlane) ChooseDialTarget(outbound consts.OutboundIndex, dst netip
|
||||
dialMode = consts.DialMode_Domain
|
||||
} else {
|
||||
// Check if the domain is in real-domain set (bloom filter).
|
||||
c.muRealDomainSet.RLock()
|
||||
c.muRealDomainSet.Lock()
|
||||
if c.realDomainSet.TestString(domain) {
|
||||
c.muRealDomainSet.RUnlock()
|
||||
c.muRealDomainSet.Unlock()
|
||||
dialMode = consts.DialMode_Domain
|
||||
} else {
|
||||
c.muRealDomainSet.RUnlock()
|
||||
c.muRealDomainSet.Unlock()
|
||||
// Lookup A/AAAA to make sure it is a real domain.
|
||||
ctx, cancel := context.WithTimeout(context.TODO(), 5*time.Second)
|
||||
defer cancel()
|
||||
// TODO: use DNS controller and re-route by control plane.
|
||||
systemDns, err := netutils.SystemDns()
|
||||
if err == nil {
|
||||
if ip46, err := netutils.ResolveIp46(ctx, direct.SymmetricDirect, systemDns, domain, false, true); err == nil && (ip46.Ip4.IsValid() || ip46.Ip6.IsValid()) {
|
||||
// Has NS records. It is a real domain.
|
||||
// Has A/AAAA records. It is a real domain.
|
||||
dialMode = consts.DialMode_Domain
|
||||
// Add it to real domain set.
|
||||
// Add it to real-domain set.
|
||||
c.muRealDomainSet.Lock()
|
||||
c.realDomainSet.AddString(domain)
|
||||
c.muRealDomainSet.Unlock()
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
```shell
|
||||
clang >= 10
|
||||
llvm >= 10
|
||||
llvm >= 10 (optional)
|
||||
golang >= 1.18
|
||||
make
|
||||
```
|
||||
@ -17,10 +17,17 @@ make
|
||||
git clone https://github.com/daeuniverse/dae.git
|
||||
cd dae
|
||||
git submodule update --init
|
||||
# Minimal dependency build:
|
||||
make GOFLAGS="-buildvcs=false" CC=clang
|
||||
# Or normal build:
|
||||
# make
|
||||
## Minimal dependency build
|
||||
make GOFLAGS="-buildvcs=false" CC=clang NOSTRIP=y
|
||||
|
||||
## Normal build
|
||||
#make
|
||||
|
||||
## Cross compile
|
||||
# To armv7 CPU architect:
|
||||
#make CGO_ENABLED=0 GOARCH=arm GOARM=7
|
||||
# To mips CPU architect:
|
||||
#make CGO_ENABLED=0 GOARCH=mips
|
||||
```
|
||||
|
||||
## Run
|
||||
|
Loading…
Reference in New Issue
Block a user