dns

package
v0.0.0-...-56574ec Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 30, 2021 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ActionUknown from error or not found record1
	ActionNo = -1
	// ActionBlock block given url
	ActionBlock = iota
	// ActionLog log given url
	ActionLog = iota
)

Variables

This section is empty.

Functions

func ActionToString

func ActionToString(action int) string

func CreateAllRecordsFromDB

func CreateAllRecordsFromDB(client *mongo.Client) *[]Record

func CreateManyRecordsFromDB

func CreateManyRecordsFromDB(client *mongo.Client, key string, value interface{}) *[]Record

func GetRecord

func GetRecord(client *mongo.Client, url string, messageType dnsmessage.Type) int

func IsRecordEmpty

func IsRecordEmpty(record Record) bool

func Listen

func Listen(s *Server)

Listen start connection and handle incoming queries

func RecordToString

func RecordToString(record Record) string

func StringToAction

func StringToAction(action string) int

func StringToType

func StringToType(mtype string) (dnsmessage.Type, error)

func TypeToString

func TypeToString(mtype dnsmessage.Type) string

Types

type MessageData

type MessageData struct {
	ID        uint16
	Questions []Question

	ResponseType dnsmessage.Type
	ResponseURL  string
	Data         *dnsmessage.Message
	// contains filtered or unexported fields
}

type Question

type Question struct {
	URL  string
	Type dnsmessage.Type
}

type Record

type Record struct {
	ID     primitive.ObjectID `bson:"_id,omitempty"`
	Action int                `bson:"action"`
	URL    string             `bson:"url"`
	Type   dnsmessage.Type    `bson:"type"`
}

Record struct containging single record with corresponding action

func CreateRecord

func CreateRecord(url string, action int, recordType dnsmessage.Type) *Record

CreateRecord create record structure

func CreateRecordBlock

func CreateRecordBlock(url string) *Record

CreateRecordBlock create record structure with type ActionBlock

func GetOneRecordFromDB

func GetOneRecordFromDB(url string, recordType dnsmessage.Type) Record

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server struct containing all dns connection data

func GetConnection

func GetConnection(port int, resolverIP string, resolverPort int, debug bool) *Server

GetConnection get connection struct filled with preliminary data

type Stat

type Stat struct {
	ID        primitive.ObjectID `bson:"_id,omitempty" json:"_id"`
	Action    string             `bson:"action" json:"action"`
	URL       string             `bson:"url" json:"url"`
	Type      string             `bson:"type" json:"type"`
	IP        string             `bson:"ip" json:"ip"`
	Port      int                `bson:"port" json:"port"`
	Timestamp int64              `bson:"timestamp" json:"timestamp"`
}

type StatCollection

type StatCollection struct {
	Number_of_records          int    `json:"number_of_records"`
	Number_of_requests         int    `json:"number_of_requests"`
	Number_of_blocked_requests int    `json:"number_of_blocked_requests"`
	Requests                   []Stat `json:"requests"`
}

func GetStatsCollection

func GetStatsCollection(client *mongo.Client) *StatCollection

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL