Dep ensure (#1803)
* vendor: don't vendor the context stuff We don't need to vendor this anymore as we moved to the std lib for these. * new stuff showing up with dep ensure * remove go-shlex
This commit is contained in:
parent
cffa1948ab
commit
1e471a353e
10377 changed files with 4225826 additions and 54911 deletions
10
vendor/github.com/dnstap/golang-dnstap/dnstap.pb/.gitignore
generated
vendored
Normal file
10
vendor/github.com/dnstap/golang-dnstap/dnstap.pb/.gitignore
generated
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
.deps/
|
||||
.dirstamp
|
||||
.libs/
|
||||
*.pb-c.c
|
||||
*.pb-c.h
|
||||
*.pb.cc
|
||||
*.pb.h
|
||||
*.pb.go
|
||||
*_pb2.py
|
||||
*_pb2.pyc
|
121
vendor/github.com/dnstap/golang-dnstap/dnstap.pb/LICENSE
generated
vendored
Normal file
121
vendor/github.com/dnstap/golang-dnstap/dnstap.pb/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,121 @@
|
|||
Creative Commons Legal Code
|
||||
|
||||
CC0 1.0 Universal
|
||||
|
||||
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
|
||||
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
|
||||
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
|
||||
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
|
||||
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
|
||||
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
|
||||
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
|
||||
HEREUNDER.
|
||||
|
||||
Statement of Purpose
|
||||
|
||||
The laws of most jurisdictions throughout the world automatically confer
|
||||
exclusive Copyright and Related Rights (defined below) upon the creator
|
||||
and subsequent owner(s) (each and all, an "owner") of an original work of
|
||||
authorship and/or a database (each, a "Work").
|
||||
|
||||
Certain owners wish to permanently relinquish those rights to a Work for
|
||||
the purpose of contributing to a commons of creative, cultural and
|
||||
scientific works ("Commons") that the public can reliably and without fear
|
||||
of later claims of infringement build upon, modify, incorporate in other
|
||||
works, reuse and redistribute as freely as possible in any form whatsoever
|
||||
and for any purposes, including without limitation commercial purposes.
|
||||
These owners may contribute to the Commons to promote the ideal of a free
|
||||
culture and the further production of creative, cultural and scientific
|
||||
works, or to gain reputation or greater distribution for their Work in
|
||||
part through the use and efforts of others.
|
||||
|
||||
For these and/or other purposes and motivations, and without any
|
||||
expectation of additional consideration or compensation, the person
|
||||
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
|
||||
is an owner of Copyright and Related Rights in the Work, voluntarily
|
||||
elects to apply CC0 to the Work and publicly distribute the Work under its
|
||||
terms, with knowledge of his or her Copyright and Related Rights in the
|
||||
Work and the meaning and intended legal effect of CC0 on those rights.
|
||||
|
||||
1. Copyright and Related Rights. A Work made available under CC0 may be
|
||||
protected by copyright and related or neighboring rights ("Copyright and
|
||||
Related Rights"). Copyright and Related Rights include, but are not
|
||||
limited to, the following:
|
||||
|
||||
i. the right to reproduce, adapt, distribute, perform, display,
|
||||
communicate, and translate a Work;
|
||||
ii. moral rights retained by the original author(s) and/or performer(s);
|
||||
iii. publicity and privacy rights pertaining to a person's image or
|
||||
likeness depicted in a Work;
|
||||
iv. rights protecting against unfair competition in regards to a Work,
|
||||
subject to the limitations in paragraph 4(a), below;
|
||||
v. rights protecting the extraction, dissemination, use and reuse of data
|
||||
in a Work;
|
||||
vi. database rights (such as those arising under Directive 96/9/EC of the
|
||||
European Parliament and of the Council of 11 March 1996 on the legal
|
||||
protection of databases, and under any national implementation
|
||||
thereof, including any amended or successor version of such
|
||||
directive); and
|
||||
vii. other similar, equivalent or corresponding rights throughout the
|
||||
world based on applicable law or treaty, and any national
|
||||
implementations thereof.
|
||||
|
||||
2. Waiver. To the greatest extent permitted by, but not in contravention
|
||||
of, applicable law, Affirmer hereby overtly, fully, permanently,
|
||||
irrevocably and unconditionally waives, abandons, and surrenders all of
|
||||
Affirmer's Copyright and Related Rights and associated claims and causes
|
||||
of action, whether now known or unknown (including existing as well as
|
||||
future claims and causes of action), in the Work (i) in all territories
|
||||
worldwide, (ii) for the maximum duration provided by applicable law or
|
||||
treaty (including future time extensions), (iii) in any current or future
|
||||
medium and for any number of copies, and (iv) for any purpose whatsoever,
|
||||
including without limitation commercial, advertising or promotional
|
||||
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
|
||||
member of the public at large and to the detriment of Affirmer's heirs and
|
||||
successors, fully intending that such Waiver shall not be subject to
|
||||
revocation, rescission, cancellation, termination, or any other legal or
|
||||
equitable action to disrupt the quiet enjoyment of the Work by the public
|
||||
as contemplated by Affirmer's express Statement of Purpose.
|
||||
|
||||
3. Public License Fallback. Should any part of the Waiver for any reason
|
||||
be judged legally invalid or ineffective under applicable law, then the
|
||||
Waiver shall be preserved to the maximum extent permitted taking into
|
||||
account Affirmer's express Statement of Purpose. In addition, to the
|
||||
extent the Waiver is so judged Affirmer hereby grants to each affected
|
||||
person a royalty-free, non transferable, non sublicensable, non exclusive,
|
||||
irrevocable and unconditional license to exercise Affirmer's Copyright and
|
||||
Related Rights in the Work (i) in all territories worldwide, (ii) for the
|
||||
maximum duration provided by applicable law or treaty (including future
|
||||
time extensions), (iii) in any current or future medium and for any number
|
||||
of copies, and (iv) for any purpose whatsoever, including without
|
||||
limitation commercial, advertising or promotional purposes (the
|
||||
"License"). The License shall be deemed effective as of the date CC0 was
|
||||
applied by Affirmer to the Work. Should any part of the License for any
|
||||
reason be judged legally invalid or ineffective under applicable law, such
|
||||
partial invalidity or ineffectiveness shall not invalidate the remainder
|
||||
of the License, and in such case Affirmer hereby affirms that he or she
|
||||
will not (i) exercise any of his or her remaining Copyright and Related
|
||||
Rights in the Work or (ii) assert any associated claims and causes of
|
||||
action with respect to the Work, in either case contrary to Affirmer's
|
||||
express Statement of Purpose.
|
||||
|
||||
4. Limitations and Disclaimers.
|
||||
|
||||
a. No trademark or patent rights held by Affirmer are waived, abandoned,
|
||||
surrendered, licensed or otherwise affected by this document.
|
||||
b. Affirmer offers the Work as-is and makes no representations or
|
||||
warranties of any kind concerning the Work, express, implied,
|
||||
statutory or otherwise, including without limitation warranties of
|
||||
title, merchantability, fitness for a particular purpose, non
|
||||
infringement, or the absence of latent or other defects, accuracy, or
|
||||
the present or absence of errors, whether or not discoverable, all to
|
||||
the greatest extent permissible under applicable law.
|
||||
c. Affirmer disclaims responsibility for clearing rights of other persons
|
||||
that may apply to the Work or any use thereof, including without
|
||||
limitation any person's Copyright and Related Rights in the Work.
|
||||
Further, Affirmer disclaims responsibility for obtaining any necessary
|
||||
consents, permissions or other rights required for any use of the
|
||||
Work.
|
||||
d. Affirmer understands and acknowledges that Creative Commons is not a
|
||||
party to this document and has no duty or obligation with respect to
|
||||
this CC0 or use of the Work.
|
5
vendor/github.com/dnstap/golang-dnstap/dnstap.pb/README
generated
vendored
Normal file
5
vendor/github.com/dnstap/golang-dnstap/dnstap.pb/README
generated
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
dnstap: flexible, structured event replication format for DNS software
|
||||
----------------------------------------------------------------------
|
||||
|
||||
This directory contains only the protobuf schemas for dnstap, and is the root of
|
||||
a repository named "dnstap.pb".
|
268
vendor/github.com/dnstap/golang-dnstap/dnstap.pb/dnstap.proto
generated
vendored
Normal file
268
vendor/github.com/dnstap/golang-dnstap/dnstap.pb/dnstap.proto
generated
vendored
Normal file
|
@ -0,0 +1,268 @@
|
|||
// dnstap: flexible, structured event replication format for DNS software
|
||||
//
|
||||
// This file contains the protobuf schemas for the "dnstap" structured event
|
||||
// replication format for DNS software.
|
||||
|
||||
// Written in 2013-2014 by Farsight Security, Inc.
|
||||
//
|
||||
// To the extent possible under law, the author(s) have dedicated all
|
||||
// copyright and related and neighboring rights to this file to the public
|
||||
// domain worldwide. This file is distributed without any warranty.
|
||||
//
|
||||
// You should have received a copy of the CC0 Public Domain Dedication along
|
||||
// with this file. If not, see:
|
||||
//
|
||||
// <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
|
||||
package dnstap;
|
||||
|
||||
// "Dnstap": this is the top-level dnstap type, which is a "union" type that
|
||||
// contains other kinds of dnstap payloads, although currently only one type
|
||||
// of dnstap payload is defined.
|
||||
// See: https://developers.google.com/protocol-buffers/docs/techniques#union
|
||||
message Dnstap {
|
||||
// DNS server identity.
|
||||
// If enabled, this is the identity string of the DNS server which generated
|
||||
// this message. Typically this would be the same string as returned by an
|
||||
// "NSID" (RFC 5001) query.
|
||||
optional bytes identity = 1;
|
||||
|
||||
// DNS server version.
|
||||
// If enabled, this is the version string of the DNS server which generated
|
||||
// this message. Typically this would be the same string as returned by a
|
||||
// "version.bind" query.
|
||||
optional bytes version = 2;
|
||||
|
||||
// Extra data for this payload.
|
||||
// This field can be used for adding an arbitrary byte-string annotation to
|
||||
// the payload. No encoding or interpretation is applied or enforced.
|
||||
optional bytes extra = 3;
|
||||
|
||||
// Identifies which field below is filled in.
|
||||
enum Type {
|
||||
MESSAGE = 1;
|
||||
}
|
||||
required Type type = 15;
|
||||
|
||||
// One of the following will be filled in.
|
||||
optional Message message = 14;
|
||||
}
|
||||
|
||||
// SocketFamily: the network protocol family of a socket. This specifies how
|
||||
// to interpret "network address" fields.
|
||||
enum SocketFamily {
|
||||
INET = 1; // IPv4 (RFC 791)
|
||||
INET6 = 2; // IPv6 (RFC 2460)
|
||||
}
|
||||
|
||||
// SocketProtocol: the transport protocol of a socket. This specifies how to
|
||||
// interpret "transport port" fields.
|
||||
enum SocketProtocol {
|
||||
UDP = 1; // User Datagram Protocol (RFC 768)
|
||||
TCP = 2; // Transmission Control Protocol (RFC 793)
|
||||
}
|
||||
|
||||
// Message: a wire-format (RFC 1035 section 4) DNS message and associated
|
||||
// metadata. Applications generating "Message" payloads should follow
|
||||
// certain requirements based on the MessageType, see below.
|
||||
message Message {
|
||||
|
||||
// There are eight types of "Message" defined that correspond to the
|
||||
// four arrows in the following diagram, slightly modified from RFC 1035
|
||||
// section 2:
|
||||
|
||||
// +---------+ +----------+ +--------+
|
||||
// | | query | | query | |
|
||||
// | Stub |-SQ--------CQ->| Recursive|-RQ----AQ->| Auth. |
|
||||
// | Resolver| | Server | | Name |
|
||||
// | |<-SR--------CR-| |<-RR----AR-| Server |
|
||||
// +---------+ response | | response | |
|
||||
// +----------+ +--------+
|
||||
|
||||
// Each arrow has two Type values each, one for each "end" of each arrow,
|
||||
// because these are considered to be distinct events. Each end of each
|
||||
// arrow on the diagram above has been marked with a two-letter Type
|
||||
// mnemonic. Clockwise from upper left, these mnemonic values are:
|
||||
//
|
||||
// SQ: STUB_QUERY
|
||||
// CQ: CLIENT_QUERY
|
||||
// RQ: RESOLVER_QUERY
|
||||
// AQ: AUTH_QUERY
|
||||
// AR: AUTH_RESPONSE
|
||||
// RR: RESOLVER_RESPONSE
|
||||
// CR: CLIENT_RESPONSE
|
||||
// SR: STUB_RESPONSE
|
||||
|
||||
// Two additional types of "Message" have been defined for the
|
||||
// "forwarding" case where an upstream DNS server is responsible for
|
||||
// further recursion. These are not shown on the diagram above, but have
|
||||
// the following mnemonic values:
|
||||
|
||||
// FQ: FORWARDER_QUERY
|
||||
// FR: FORWARDER_RESPONSE
|
||||
|
||||
// The "Message" Type values are defined below.
|
||||
|
||||
enum Type {
|
||||
// AUTH_QUERY is a DNS query message received from a resolver by an
|
||||
// authoritative name server, from the perspective of the authorative
|
||||
// name server.
|
||||
AUTH_QUERY = 1;
|
||||
|
||||
// AUTH_RESPONSE is a DNS response message sent from an authoritative
|
||||
// name server to a resolver, from the perspective of the authoritative
|
||||
// name server.
|
||||
AUTH_RESPONSE = 2;
|
||||
|
||||
// RESOLVER_QUERY is a DNS query message sent from a resolver to an
|
||||
// authoritative name server, from the perspective of the resolver.
|
||||
// Resolvers typically clear the RD (recursion desired) bit when
|
||||
// sending queries.
|
||||
RESOLVER_QUERY = 3;
|
||||
|
||||
// RESOLVER_RESPONSE is a DNS response message received from an
|
||||
// authoritative name server by a resolver, from the perspective of
|
||||
// the resolver.
|
||||
RESOLVER_RESPONSE = 4;
|
||||
|
||||
// CLIENT_QUERY is a DNS query message sent from a client to a DNS
|
||||
// server which is expected to perform further recursion, from the
|
||||
// perspective of the DNS server. The client may be a stub resolver or
|
||||
// forwarder or some other type of software which typically sets the RD
|
||||
// (recursion desired) bit when querying the DNS server. The DNS server
|
||||
// may be a simple forwarding proxy or it may be a full recursive
|
||||
// resolver.
|
||||
CLIENT_QUERY = 5;
|
||||
|
||||
// CLIENT_RESPONSE is a DNS response message sent from a DNS server to
|
||||
// a client, from the perspective of the DNS server. The DNS server
|
||||
// typically sets the RA (recursion available) bit when responding.
|
||||
CLIENT_RESPONSE = 6;
|
||||
|
||||
// FORWARDER_QUERY is a DNS query message sent from a downstream DNS
|
||||
// server to an upstream DNS server which is expected to perform
|
||||
// further recursion, from the perspective of the downstream DNS
|
||||
// server.
|
||||
FORWARDER_QUERY = 7;
|
||||
|
||||
// FORWARDER_RESPONSE is a DNS response message sent from an upstream
|
||||
// DNS server performing recursion to a downstream DNS server, from the
|
||||
// perspective of the downstream DNS server.
|
||||
FORWARDER_RESPONSE = 8;
|
||||
|
||||
// STUB_QUERY is a DNS query message sent from a stub resolver to a DNS
|
||||
// server, from the perspective of the stub resolver.
|
||||
STUB_QUERY = 9;
|
||||
|
||||
// STUB_RESPONSE is a DNS response message sent from a DNS server to a
|
||||
// stub resolver, from the perspective of the stub resolver.
|
||||
STUB_RESPONSE = 10;
|
||||
|
||||
// TOOL_QUERY is a DNS query message sent from a DNS software tool to a
|
||||
// DNS server, from the perspective of the tool.
|
||||
TOOL_QUERY = 11;
|
||||
|
||||
// TOOL_RESPONSE is a DNS response message received by a DNS software
|
||||
// tool from a DNS server, from the perspective of the tool.
|
||||
TOOL_RESPONSE = 12;
|
||||
}
|
||||
|
||||
// One of the Type values described above.
|
||||
required Type type = 1;
|
||||
|
||||
// One of the SocketFamily values described above.
|
||||
optional SocketFamily socket_family = 2;
|
||||
|
||||
// One of the SocketProtocol values described above.
|
||||
optional SocketProtocol socket_protocol = 3;
|
||||
|
||||
// The network address of the message initiator.
|
||||
// For SocketFamily INET, this field is 4 octets (IPv4 address).
|
||||
// For SocketFamily INET6, this field is 16 octets (IPv6 address).
|
||||
optional bytes query_address = 4;
|
||||
|
||||
// The network address of the message responder.
|
||||
// For SocketFamily INET, this field is 4 octets (IPv4 address).
|
||||
// For SocketFamily INET6, this field is 16 octets (IPv6 address).
|
||||
optional bytes response_address = 5;
|
||||
|
||||
// The transport port of the message initiator.
|
||||
// This is a 16-bit UDP or TCP port number, depending on SocketProtocol.
|
||||
optional uint32 query_port = 6;
|
||||
|
||||
// The transport port of the message responder.
|
||||
// This is a 16-bit UDP or TCP port number, depending on SocketProtocol.
|
||||
optional uint32 response_port = 7;
|
||||
|
||||
// The time at which the DNS query message was sent or received, depending
|
||||
// on whether this is an AUTH_QUERY, RESOLVER_QUERY, or CLIENT_QUERY.
|
||||
// This is the number of seconds since the UNIX epoch.
|
||||
optional uint64 query_time_sec = 8;
|
||||
|
||||
// The time at which the DNS query message was sent or received.
|
||||
// This is the seconds fraction, expressed as a count of nanoseconds.
|
||||
optional fixed32 query_time_nsec = 9;
|
||||
|
||||
// The initiator's original wire-format DNS query message, verbatim.
|
||||
optional bytes query_message = 10;
|
||||
|
||||
// The "zone" or "bailiwick" pertaining to the DNS query message.
|
||||
// This is a wire-format DNS domain name.
|
||||
optional bytes query_zone = 11;
|
||||
|
||||
// The time at which the DNS response message was sent or received,
|
||||
// depending on whether this is an AUTH_RESPONSE, RESOLVER_RESPONSE, or
|
||||
// CLIENT_RESPONSE.
|
||||
// This is the number of seconds since the UNIX epoch.
|
||||
optional uint64 response_time_sec = 12;
|
||||
|
||||
// The time at which the DNS response message was sent or received.
|
||||
// This is the seconds fraction, expressed as a count of nanoseconds.
|
||||
optional fixed32 response_time_nsec = 13;
|
||||
|
||||
// The responder's original wire-format DNS response message, verbatim.
|
||||
optional bytes response_message = 14;
|
||||
}
|
||||
|
||||
// All fields except for 'type' in the Message schema are optional.
|
||||
// It is recommended that at least the following fields be filled in for
|
||||
// particular types of Messages.
|
||||
|
||||
// AUTH_QUERY:
|
||||
// socket_family, socket_protocol
|
||||
// query_address, query_port
|
||||
// query_message
|
||||
// query_time_sec, query_time_nsec
|
||||
|
||||
// AUTH_RESPONSE:
|
||||
// socket_family, socket_protocol
|
||||
// query_address, query_port
|
||||
// query_time_sec, query_time_nsec
|
||||
// response_message
|
||||
// response_time_sec, response_time_nsec
|
||||
|
||||
// RESOLVER_QUERY:
|
||||
// socket_family, socket_protocol
|
||||
// query_message
|
||||
// query_time_sec, query_time_nsec
|
||||
// query_zone
|
||||
// response_address, response_port
|
||||
|
||||
// RESOLVER_RESPONSE:
|
||||
// socket_family, socket_protocol
|
||||
// query_time_sec, query_time_nsec
|
||||
// query_zone
|
||||
// response_address, response_port
|
||||
// response_message
|
||||
// response_time_sec, response_time_nsec
|
||||
|
||||
// CLIENT_QUERY:
|
||||
// socket_family, socket_protocol
|
||||
// query_message
|
||||
// query_time_sec, query_time_nsec
|
||||
|
||||
// CLIENT_RESPONSE:
|
||||
// socket_family, socket_protocol
|
||||
// query_time_sec, query_time_nsec
|
||||
// response_message
|
||||
// response_time_sec, response_time_nsec
|
173
vendor/github.com/dnstap/golang-dnstap/dnstap/main.go
generated
vendored
Normal file
173
vendor/github.com/dnstap/golang-dnstap/dnstap/main.go
generated
vendored
Normal file
|
@ -0,0 +1,173 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2014 by Farsight Security, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"net"
|
||||
"os"
|
||||
"os/signal"
|
||||
"runtime"
|
||||
"syscall"
|
||||
|
||||
"github.com/dnstap/golang-dnstap"
|
||||
)
|
||||
|
||||
var (
|
||||
flagReadTcp = flag.String("l", "", "read dnstap payloads from tcp/ip")
|
||||
flagReadFile = flag.String("r", "", "read dnstap payloads from file")
|
||||
flagReadSock = flag.String("u", "", "read dnstap payloads from unix socket")
|
||||
flagWriteFile = flag.String("w", "-", "write output to file")
|
||||
flagQuietText = flag.Bool("q", false, "use quiet text output")
|
||||
flagYamlText = flag.Bool("y", false, "use verbose YAML output")
|
||||
)
|
||||
|
||||
func usage() {
|
||||
fmt.Fprintf(os.Stderr, "Usage: %s [OPTION]...\n", os.Args[0])
|
||||
flag.PrintDefaults()
|
||||
fmt.Fprintf(os.Stderr, `
|
||||
Quiet text output format mnemonics:
|
||||
AQ: AUTH_QUERY
|
||||
AR: AUTH_RESPONSE
|
||||
RQ: RESOLVER_QUERY
|
||||
RR: RESOLVER_RESPONSE
|
||||
CQ: CLIENT_QUERY
|
||||
CR: CLIENT_RESPONSE
|
||||
FQ: FORWARDER_QUERY
|
||||
FR: FORWARDER_RESPONSE
|
||||
SQ: STUB_QUERY
|
||||
SR: STUB_RESPONSE
|
||||
TQ: TOOL_QUERY
|
||||
TR: TOOL_RESPONSE
|
||||
`)
|
||||
}
|
||||
|
||||
func outputOpener(fname string, text, yaml bool) func() dnstap.Output {
|
||||
return func() dnstap.Output {
|
||||
var o dnstap.Output
|
||||
var err error
|
||||
if text {
|
||||
o, err = dnstap.NewTextOutputFromFilename(fname, dnstap.TextFormat)
|
||||
} else if yaml {
|
||||
o, err = dnstap.NewTextOutputFromFilename(fname, dnstap.YamlFormat)
|
||||
} else {
|
||||
o, err = dnstap.NewFrameStreamOutputFromFilename(fname)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "dnstap: Failed to open output file: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
go o.RunOutputLoop()
|
||||
return o
|
||||
}
|
||||
}
|
||||
|
||||
func outputLoop(opener func() dnstap.Output, data <-chan []byte, done chan<- struct{}) {
|
||||
sigch := make(chan os.Signal, 1)
|
||||
signal.Notify(sigch, os.Interrupt, syscall.SIGHUP)
|
||||
o := opener()
|
||||
defer func() {
|
||||
o.Close()
|
||||
close(done)
|
||||
os.Exit(0)
|
||||
}()
|
||||
for {
|
||||
select {
|
||||
case b, ok := <-data:
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
o.GetOutputChannel() <- b
|
||||
case sig := <-sigch:
|
||||
if sig == syscall.SIGHUP {
|
||||
o.Close()
|
||||
o = opener()
|
||||
continue
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
var err error
|
||||
var i dnstap.Input
|
||||
|
||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||
log.SetFlags(0)
|
||||
flag.Usage = usage
|
||||
|
||||
// Handle command-line arguments.
|
||||
flag.Parse()
|
||||
|
||||
if *flagReadFile == "" && *flagReadSock == "" && *flagReadTcp == "" {
|
||||
fmt.Fprintf(os.Stderr, "dnstap: Error: no inputs specified.\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if *flagWriteFile == "-" {
|
||||
if *flagQuietText == false && *flagYamlText == false {
|
||||
*flagQuietText = true
|
||||
}
|
||||
}
|
||||
|
||||
if *flagReadFile != "" && *flagReadSock != "" && *flagReadTcp != "" {
|
||||
fmt.Fprintf(os.Stderr, "dnstap: Error: specify exactly one of -r, -u or -l.\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// Start the output loop.
|
||||
output := make(chan []byte, 1)
|
||||
opener := outputOpener(*flagWriteFile, *flagQuietText, *flagYamlText)
|
||||
outDone := make(chan struct{})
|
||||
go outputLoop(opener, output, outDone)
|
||||
|
||||
// Open the input and start the input loop.
|
||||
if *flagReadFile != "" {
|
||||
i, err = dnstap.NewFrameStreamInputFromFilename(*flagReadFile)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "dnstap: Failed to open input file: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
fmt.Fprintf(os.Stderr, "dnstap: opened input file %s\n", *flagReadFile)
|
||||
} else if *flagReadSock != "" {
|
||||
i, err = dnstap.NewFrameStreamSockInputFromPath(*flagReadSock)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "dnstap: Failed to open input socket: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
fmt.Fprintf(os.Stderr, "dnstap: opened input socket %s\n", *flagReadSock)
|
||||
} else if *flagReadTcp != "" {
|
||||
l, err := net.Listen("tcp", *flagReadTcp)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "dnstap: Failed to listen: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
i = dnstap.NewFrameStreamSockInput(l)
|
||||
}
|
||||
i.ReadInto(output)
|
||||
|
||||
// Wait for input loop to finish.
|
||||
i.Wait()
|
||||
close(output)
|
||||
|
||||
<-outDone
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue