mirror of
https://github.com/xvzc/SpoofDPI.git
synced 2025-01-03 04:50:11 +00:00
update util.go
This commit is contained in:
parent
6b630e9ad6
commit
2fd2503dd5
26
util/doh.go
Normal file
26
util/doh.go
Normal file
@ -0,0 +1,26 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/babolivier/go-doh-client"
|
||||
)
|
||||
|
||||
func DnsLookupOverHttps(dns string, domain string) (string, error) {
|
||||
// Perform a A lookup on example.com
|
||||
resolver := doh.Resolver{
|
||||
Host: dns, // Change this with your favourite DoH-compliant resolver.
|
||||
Class: doh.IN,
|
||||
}
|
||||
|
||||
Debug(domain)
|
||||
a, _, err := resolver.LookupA(domain)
|
||||
if err != nil {
|
||||
log.Println("Error looking up dns. ", err)
|
||||
return "", err
|
||||
}
|
||||
|
||||
ip := a[0].IP4
|
||||
|
||||
return ip, nil
|
||||
}
|
34
util/util.go
34
util/util.go
@ -4,30 +4,29 @@ import (
|
||||
"log"
|
||||
"strings"
|
||||
|
||||
"github.com/babolivier/go-doh-client"
|
||||
"github.com/xvzc/SpoofDPI/config"
|
||||
)
|
||||
|
||||
func ExtractDomain(message *[]byte) (string) {
|
||||
func ExtractDomain(message *[]byte) string {
|
||||
i := 0
|
||||
for ; i < len(*message); i++ {
|
||||
if (*message)[i] == '\n' {
|
||||
i++
|
||||
break;
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
for ; i < len(*message); i++ {
|
||||
if (*message)[i] == ' ' {
|
||||
i++
|
||||
break;
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
j := i
|
||||
for ; j < len(*message); j++ {
|
||||
if (*message)[j] == '\n' {
|
||||
break;
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
@ -36,30 +35,11 @@ func ExtractDomain(message *[]byte) (string) {
|
||||
return strings.TrimSpace(domain)
|
||||
}
|
||||
|
||||
func DnsLookupOverHttps(dns string, domain string)(string, error) {
|
||||
// Perform a A lookup on example.com
|
||||
resolver := doh.Resolver{
|
||||
Host: dns, // Change this with your favourite DoH-compliant resolver.
|
||||
Class: doh.IN,
|
||||
}
|
||||
|
||||
Debug(domain)
|
||||
a, _, err := resolver.LookupA(domain)
|
||||
if err != nil {
|
||||
log.Println("Error looking up dns. ", err)
|
||||
return "", err
|
||||
}
|
||||
|
||||
ip := a[0].IP4
|
||||
|
||||
return ip, nil
|
||||
}
|
||||
|
||||
func ExtractMethod(message *[]byte) (string) {
|
||||
func ExtractMethod(message *[]byte) string {
|
||||
i := 0
|
||||
for ; i < len(*message); i++ {
|
||||
if (*message)[i] == ' ' {
|
||||
break;
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
@ -77,7 +57,7 @@ func Debug(v ...interface{}) {
|
||||
log.Println(v...)
|
||||
}
|
||||
|
||||
func BytesToChunks(buf []byte) ([][]byte) {
|
||||
func BytesToChunks(buf []byte) [][]byte {
|
||||
if len(buf) < 1 {
|
||||
return [][]byte{buf}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user