Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Configuration ¶
func (Configuration) MarshalJSON ¶
func (t Configuration) MarshalJSON() ([]byte, error)
func (*Configuration) UnmarshalJSON ¶
func (t *Configuration) UnmarshalJSON(data []byte) (err error)
type Hijacker ¶
The Implementation of the Hijacker interface must write the message to the writer. It returns weather the message was hijacked (true) or not (false). With any errors.
type Server ¶
Example ¶
Example DNS Forwarding Server
configuration := Configuration{} configuration.ReadTimeout = 10 configuration.WriteTimeout = 10 configuration.TTL = 600 configuration.NameServers = []net.TCPAddr{net.TCPAddr{IP: net.IPv4(208, 67, 222, 222), Port: 53}, net.TCPAddr{IP: net.IPv4(208, 67, 220, 220), Port: 53}} cache := memorycache.Memory{} cache.Cache = make(map[string]memorycache.MemoryCacheRecord) hosts := memoryhosts.Memory{} hosts.Devices = make(map[string]net.IP) hosts.Add("raspberrypi", net.IPv4(192, 168, 1, 201)) server := Server{} server.Configuration = &configuration server.Cache = &cache server.Hosts = &hosts go func() { err := server.ListenAndServeUDP(net.UDPAddr{IP: net.IPv4(0, 0, 0, 0), Port: 53}) if err != nil { log.Fatalf("UDP Error:%s\n", err.Error()) } }() err := server.ListenAndServeTCP(net.TCPAddr{IP: net.IPv4(0, 0, 0, 0), Port: 53}) if err != nil { log.Fatalf("TCP Error:%s\n", err.Error()) }
Output:
func (*Server) ListenAndServeTCP ¶
Listen for incoming TCP Connections
Click to show internal directories.
Click to hide internal directories.