feat: add sniffing suite and dial_mode option (#16)

This commit is contained in:
mzz
2023-02-15 01:53:53 +08:00
committed by GitHub
parent 2a586e6341
commit ebdbf9a4a7
25 changed files with 1561 additions and 19 deletions

View File

@ -6,10 +6,13 @@
package common
import (
"crypto/aes"
"crypto/cipher"
"encoding/base64"
"encoding/binary"
"encoding/hex"
"fmt"
"golang.org/x/net/dns/dnsmessage"
"net/netip"
"net/url"
"path/filepath"
@ -374,3 +377,19 @@ func ConvergeIp(addr netip.Addr) netip.Addr {
}
return addr
}
func NewGcm(key []byte) (cipher.AEAD, error) {
block, err := aes.NewCipher(key)
if err != nil {
return nil, err
}
return cipher.NewGCM(block)
}
func AddrToDnsType(addr netip.Addr) dnsmessage.Type {
if addr.Is4() {
return dnsmessage.TypeA
} else {
return dnsmessage.TypeAAAA
}
}