grpcdump

package module
v0.0.0-...-7974ae1 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2020 License: Apache-2.0 Imports: 20 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

gRPC dump tool

中文文档

» sudo go run cmd/grpcdump/main.go -d lo0 -port 8085 -ip 127.0.0.1 -proto ./grpc_example/helloworld/helloworld/helloworld.proto
2018/06/06 21:18:02 Starting capture on device "lo0"
2018/06/06 21:18:02 reading in packets

REQUEST(STREAM=1) > 2018-06-06T21:18:04.921128144+08:00: 127.0.0.1:56327 ---> 127.0.0.1:8085
  HEADERS:
    :method = "POST"
    :scheme = "http"
    :path = "/helloworld.Greeter/SayHello"
    :authority = "127.0.0.1:8085"
    content-type = "application/grpc"
    user-agent = "grpc-go/1.13.0-dev"
    te = "trailers"
  BODY:
    {"name":"world","i18":"zh"}

RESPONSE(STREAM=1) > 2018-06-06T21:18:04.921691304+08:00: 127.0.0.1:56327 <--- 127.0.0.1:8085
  HEADERS:
    :status = "200"
    content-type = "application/grpc"
  BODY:
    {"message":"Hello, 你好"}

RESPONSE(STREAM=1) > 2018-06-06T21:18:04.921865543+08:00: 127.0.0.1:56327 <--- 127.0.0.1:8085
  HEADERS:
    grpc-status = "0"
    grpc-message = ""

Requirement

Build grpcpdump requires libpcap-dev and cgo enabled.

libpcap

for ubuntu/debian:

sudo apt install libpcap-dev

for centos/redhat/fedora:

sudo yum install libpcap-devel

for osx:

Libpcap and header files already installed.

Install

go get -u github.com/dyxushuai/grpcdump/cmd/grpcdump

Usage

-assembly_debug_log
        If true, the github.com/google/gopacket/tcpassembly library will log verbose debugging information (at least one line per packet)
  -assembly_memuse_log
        If true, the github.com/google/gopacket/tcpassembly library will log information regarding its memory use every once in a while.
  -d string
        Interface to get packets from (default "eth0")
  -ip string
        Filter by ip, if either source or target ip is matched, the packet will be processed
  -port uint
        Filter by port, if either source or target port is matched, the packet will be processed.
  -proto string
        Protobuf spec file
  -v    Logs every packet in great detail

Wanted

  • Dump bytes from Network Interface, e.g. "eth0".
  • Filter by host ip and host port.
  • Parse bytes as HTTP2 protocol.
  • Decrypt TLS sessions by key log.
  • Dynamic reflect the protobuf files at runtime.
  • Pretty print.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultPrinter = NewStdoutPrinter()

Functions

func CaptureSingleDevice

func CaptureSingleDevice(device string, filterIP string, filterPort uint16) (<-chan gopacket.Packet, error)

CaptureSingleDevice capture the packet by given network device and ip, port filter

Types

type ArrayFlags

type ArrayFlags []string

func (*ArrayFlags) ParseDir

func (arrayFlags *ArrayFlags) ParseDir(suffix string) []string

func (*ArrayFlags) Set

func (arrayFlags *ArrayFlags) Set(value string) error

func (*ArrayFlags) String

func (arrayFlags *ArrayFlags) String() string

type GrpcStreamFactory

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

func NewGrpcStreamFactory

func NewGrpcStreamFactory(hostIP string, hostPort uint16, printer *Printer, protoFiles []string, importPaths []string) (*GrpcStreamFactory, error)

func (*GrpcStreamFactory) New

func (s *GrpcStreamFactory) New(net, transport gopacket.Flow) tcpassembly.Stream

type Printer

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

Printer buffered print

func NewPrinter

func NewPrinter(output io.WriteCloser) *Printer

NewPrinter print ot io.WriteCloser

func NewStdoutPrinter

func NewStdoutPrinter() *Printer

NewStdoutPrinter print to os.Stdout

func (*Printer) Close

func (p *Printer) Close() error

Close the printer

func (*Printer) Printlnf

func (p *Printer) Printlnf(format string, args ...interface{})

Printlnf print formated messages

Directories

Path Synopsis
cmd
grpcdump command
grpc_example
tests
dynamic_proto command

Jump to

Keyboard shortcuts

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