diff --git a/configuracao_recomendada.md b/configuracao_recomendada.md new file mode 100644 index 0000000..e69de29 diff --git a/deploy_completo.sh b/deploy_completo.sh new file mode 100644 index 0000000..e69de29 diff --git a/xdp_ddos_filter.c b/xdp_ddos_filter.c index 3832505..e151706 100644 --- a/xdp_ddos_filter.c +++ b/xdp_ddos_filter.c @@ -165,6 +165,11 @@ static __always_inline int is_filtered_port(__u16 port) { return (port <= 1024); } +// Função otimizada para verificar se é porta WireGuard +static __always_inline int is_wireguard_traffic(__u8 protocol, __u16 port) { + return (protocol == IPPROTO_UDP && port == 32100); +} + // Função para atualizar estatísticas de tráfego static __always_inline void update_stats(__u32 action, __u8 flags) { __u32 key = 0; @@ -219,13 +224,26 @@ int xdp_ddos_filter(struct xdp_md *ctx) { return XDP_PASS; } - // Fast path 3: Verificar IPs já confiáveis (hosts que já passaram por verificação) + // Fast path 3: WireGuard - verificação prioritária para UDP porta 32100 + if (ip->protocol == IPPROTO_UDP) { + struct udphdr *udp = (void *)(ip + 1); + if ((void *)(udp + 1) <= data_end) { + __u16 dest_port = __constant_ntohs(udp->dest); + if (dest_port == 32100) { // WireGuard port + // Permitir todo tráfego WireGuard sem verificação adicional + update_stats(XDP_PASS, 0); + return XDP_PASS; + } + } + } + + // Fast path 4: Verificar IPs já confiáveis (hosts que já passaram por verificação) __u8 *trusted = bpf_map_lookup_elem(&trusted_hosts_map, &src_ip); if (__builtin_expect(trusted != NULL && *trusted == 1, 0)) { return XDP_PASS; } - // Fast path 4: Rejeitar IPs na blacklist + // Fast path 5: Rejeitar IPs na blacklist if (__builtin_expect(is_blacklisted(src_ip), 0)) { update_stats(XDP_DROP, FLAG_MARKED_SUSPICIOUS); return XDP_DROP;