run go fmt

This commit is contained in:
wanyaoqi 2018-12-03 21:58:54 +08:00
parent 10cf59920e
commit 07ef6cbf3f
17 changed files with 307 additions and 315 deletions

View File

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

View File

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

View File

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

View File

@ -26,7 +26,6 @@ type stream struct {
} }
type packet struct { type packet struct {
isClientFlow bool //client->server isClientFlow bool //client->server
messageLength int messageLength int
@ -64,7 +63,7 @@ func (m *Mongodb) SetFlag(flg []string) {
switch key { switch key {
case CmdPort: case CmdPort:
p, err := strconv.Atoi(val); p, err := strconv.Atoi(val)
if err != nil { if err != nil {
panic("ERR : port") panic("ERR : port")
} }
@ -80,7 +79,7 @@ func (m *Mongodb) SetFlag(flg []string) {
} }
func (m *Mongodb) BPFFilter() 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 { func (m *Mongodb) Version() string {

View File

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

View File

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

View File

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

View File

@ -1,12 +1,12 @@
package build package build
import ( import (
"bufio"
"fmt"
"github.com/google/gopacket" "github.com/google/gopacket"
"io" "io"
"strings"
"fmt"
"strconv" "strconv"
"bufio" "strings"
) )
type Redis struct { type Redis struct {
@ -91,7 +91,7 @@ func (red *Redis) SetFlag(flg []string) {
switch key { switch key {
case CmdPort: case CmdPort:
port, err := strconv.Atoi(val); port, err := strconv.Atoi(val)
redis.port = port redis.port = port
if err != nil { if err != nil {
panic("ERR : Port error") panic("ERR : Port error")
@ -119,4 +119,3 @@ func (red *Redis) BPFFilter() string {
func (red *Redis) Version() string { func (red *Redis) Version() string {
return red.version return red.version
} }