A: go.mod

This commit is contained in:
Shuo 2020-03-01 15:58:57 +08:00
parent e209ea8ccc
commit 4f174b3415
No known key found for this signature in database
GPG Key ID: C058DE0CC1C1A2A8
21 changed files with 394 additions and 386 deletions

View File

@ -1,11 +1,11 @@
package core
import (
"os"
"strings"
"fmt"
"net"
"os"
"strconv"
"strings"
)
const InternalCmdPrefix = "--"
@ -139,7 +139,3 @@ func (cm *Cmd) parsePlugCmd() {
plugParams := os.Args[3:]
cm.plugHandle.SetOption(plugName, plugParams)
}

View File

@ -2,13 +2,14 @@ package core
import (
"fmt"
"log"
"time"
"github.com/google/gopacket"
"github.com/google/gopacket/layers"
"github.com/google/gopacket/pcap"
"github.com/google/gopacket/tcpassembly"
"github.com/google/gopacket/tcpassembly/tcpreader"
"log"
"time"
)
type Dispatch struct {

View File

@ -1,21 +1,21 @@
package core
import (
"io/ioutil"
"plugin"
"github.com/google/gopacket"
"fmt"
"io"
mysql "github.com/40t/go-sniffer/plugSrc/mysql/build"
redis "github.com/40t/go-sniffer/plugSrc/redis/build"
"io/ioutil"
"path"
"path/filepath"
"plugin"
hp "github.com/40t/go-sniffer/plugSrc/http/build"
mongodb "github.com/40t/go-sniffer/plugSrc/mongodb/build"
"path/filepath"
"fmt"
"path"
mysql "github.com/40t/go-sniffer/plugSrc/mysql/build"
redis "github.com/40t/go-sniffer/plugSrc/redis/build"
"github.com/google/gopacket"
)
type Plug struct {
dir string
ResolveStream func(net gopacket.Flow, transport gopacket.Flow, r io.Reader)
BPF string

5
go.mod Normal file
View File

@ -0,0 +1,5 @@
module github.com/40t/go-sniffer
go 1.13
require github.com/google/gopacket v1.1.17

9
go.sum Normal file
View File

@ -0,0 +1,9 @@
github.com/google/gopacket v1.1.17 h1:rMrlX2ZY2UbvT+sdz3+6J+pp2z+msCq9MxTU6ymxbBY=
github.com/google/gopacket v1.1.17/go.mod h1:UdDNZ1OO62aGYVnPhxT1U6aI7ukYtA/kB8vaU0diBUM=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 h1:0GoQqolDA55aaLxZyTzK/Y2ePZzZTUrRacwib7cNsYQ=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190405154228-4b34438f7a67 h1:1Fzlr8kkDLQwqMP8GxrhptBLqZG/EDpiATneiZHY998=
golang.org/x/sys v0.0.0-20190405154228-4b34438f7a67/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=

View File

@ -1,14 +1,15 @@
package build
import (
"github.com/google/gopacket"
"bufio"
"fmt"
"io"
"log"
"strconv"
"fmt"
"os"
"bufio"
"net/http"
"os"
"strconv"
"github.com/google/gopacket"
)
const (
@ -66,7 +67,7 @@ func (m *H) ResolveStream(net, transport gopacket.Flow, buf io.Reader) {
}
func (m *H) BPFFilter() string {
return "tcp and port "+strconv.Itoa(m.port);
return "tcp and port " + strconv.Itoa(m.port)
}
func (m *H) Version() string {
@ -90,7 +91,7 @@ func (m *H) SetFlag(flg []string) {
switch key {
case CmdPort:
port, err := strconv.Atoi(val);
port, err := strconv.Atoi(val)
m.port = port
if err != nil {
panic("ERR : port")

View File

@ -4,9 +4,10 @@ import (
"bytes"
"encoding/base64"
"fmt"
"github.com/40t/go-sniffer/plugSrc/mongodb/build/internal/json"
"strconv"
"time"
"github.com/40t/go-sniffer/plugSrc/mongodb/build/internal/json"
)
// UnmarshalJSON unmarshals a JSON value that may hold non-standard

View File

@ -4,9 +4,10 @@ import (
"bytes"
"encoding/binary"
"fmt"
"github.com/google/gopacket"
"io"
"strconv"
"github.com/google/gopacket"
)
const (
@ -26,7 +27,6 @@ type stream struct {
}
type packet struct {
isClientFlow bool // client->server
messageLength int
@ -64,7 +64,7 @@ func (m *Mongodb) SetFlag(flg []string) {
switch key {
case CmdPort:
p, err := strconv.Atoi(val);
p, err := strconv.Atoi(val)
if err != nil {
panic("ERR : port")
}
@ -80,7 +80,7 @@ func (m *Mongodb) SetFlag(flg []string) {
}
func (m *Mongodb) BPFFilter() string {
return "tcp and port "+strconv.Itoa(m.port);
return "tcp and port " + strconv.Itoa(m.port)
}
func (m *Mongodb) Version() string {

View File

@ -4,8 +4,9 @@ import (
"encoding/binary"
"encoding/json"
"fmt"
"time"
"io"
"time"
"github.com/40t/go-sniffer/plugSrc/mongodb/build/bson"
)
@ -54,7 +55,7 @@ func ReadString(r io.Reader) string {
return string(result)
}
func ReadBson2Json(r io.Reader) (string) {
func ReadBson2Json(r io.Reader) string {
// read len
docLen := ReadInt32(r)
@ -83,4 +84,3 @@ func ReadBson2Json(r io.Reader) (string) {
}
return string(jsonStr)
}

View File

@ -1,18 +1,19 @@
package build
import (
"github.com/google/gopacket"
"io"
"bytes"
"encoding/binary"
"errors"
"fmt"
"io"
"log"
"os"
"strconv"
"strings"
"sync"
"time"
"fmt"
"encoding/binary"
"strings"
"os"
"github.com/google/gopacket"
)
const (
@ -41,6 +42,7 @@ type packet struct {
var mysql *Mysql
var once sync.Once
func NewInstance() *Mysql {
once.Do(func() {
@ -86,7 +88,7 @@ func (m *Mysql) ResolveStream(net, transport gopacket.Flow, buf io.Reader) {
}
func (m *Mysql) BPFFilter() string {
return "tcp and port "+strconv.Itoa(m.port);
return "tcp and port " + strconv.Itoa(m.port)
}
func (m *Mysql) Version() string {
@ -110,7 +112,7 @@ func (m *Mysql) SetFlag(flg []string) {
switch key {
case CmdPort:
port, err := strconv.Atoi(val);
port, err := strconv.Atoi(val)
m.port = port
if err != nil {
panic("ERR : port")
@ -353,4 +355,3 @@ func (stm *stream) resolveClientPacket(payload []byte, seq int) {
fmt.Println(GetNowStr(true) + msg)
}

View File

@ -3,10 +3,10 @@ package build
import (
"bytes"
"encoding/binary"
"errors"
"fmt"
"math"
"strings"
"errors"
)
type Stmt struct {

View File

@ -1,12 +1,13 @@
package build
import (
"github.com/google/gopacket"
"io"
"strings"
"fmt"
"strconv"
"bufio"
"fmt"
"io"
"strconv"
"strings"
"github.com/google/gopacket"
)
type Redis struct {
@ -74,9 +75,7 @@ func (red Redis) ResolveStream(net, transport gopacket.Flow, r io.Reader) {
}
}
/**
SetOption
*/
// SetOption
func (red *Redis) SetFlag(flg []string) {
c := len(flg)
if c == 0 {
@ -91,7 +90,7 @@ func (red *Redis) SetFlag(flg []string) {
switch key {
case CmdPort:
port, err := strconv.Atoi(val);
port, err := strconv.Atoi(val)
redis.port = port
if err != nil {
panic("ERR : Port error")
@ -106,17 +105,12 @@ func (red *Redis) SetFlag(flg []string) {
}
}
/**
BPFFilter
*/
// BPFFilter
func (red *Redis) BPFFilter() string {
return "tcp and port " + strconv.Itoa(redis.port)
}
/**
Version
*/
// Version
func (red *Redis) Version() string {
return red.version
}