Skip to content

Commit

Permalink
优化--json时 屏幕输出json 2024-01-01
Browse files Browse the repository at this point in the history
  • Loading branch information
hktalent committed Jan 1, 2024
1 parent fc16b19 commit 0023e5a
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ ksubdomain.yaml
ksubdomain
*.json
*.txt
chinaZq
superbet.ro.json
ksubdomain.yaml
dist/
Expand Down
2 changes: 1 addition & 1 deletion core/device/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func AutoGetDevices() *EtherTable {
continue
}
if dnsLayer := packet.Layer(layers.LayerTypeDNS); dnsLayer != nil {
gologger.Printf(".")
//gologger.Printf(".")
dns, _ := dnsLayer.(*layers.DNS)
if !dns.QR {
continue
Expand Down
22 changes: 16 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,23 +1,33 @@
package main

import (
"embed"
myCmd "github.com/GhostTroops/ksubdomain/cmd/ksubdomain"
util "github.com/hktalent/go-utils"
"net/http"
"io"
"log"
_ "net/http/pprof"
"os"
"sync"
)

//go:embed config/*
var config embed.FS

// docker run --rm -it -v $PWD:/app go1214 /bin/bash -c "cd /app/; CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -ldflags \"-linkmode external -extldflags '-static' -s -w\" -o ksubdomain_linux main.go ; exit"
// go tool pprof -seconds=60 -http=:9999 http://127.0.0.1:6060/debug/pprof/heap
// go tool pprof http://127.0.0.1:6060/debug/pprof/profile?seconds=60
func main() {
//os.Args = []string{"", "enum", "-d", "huazhu.com", "-o", "/Users/51pwn/huazhu.json", "-j", "-b", "5M"}
os.Setenv("devDebug", "false")
os.Setenv("ProductMod", "release")
log.SetOutput(io.Discard)
os.RemoveAll(".DbCache")
defer os.RemoveAll("ksubdomain.yaml")
util.DoInitAll()
go func() {
http.ListenAndServe("0.0.0.0:6060", nil)
}()
util.Wg = &sync.WaitGroup{}
util.DoInit(&config)
//go func() {
// http.ListenAndServe("0.0.0.0:6060", nil)
//}()
myCmd.Main()
util.Wg.Wait()
util.CloseAll()
Expand Down
17 changes: 11 additions & 6 deletions runner/outputter/output/JsonOut.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,19 @@ type JsonOutImp struct {
}

func NewJsonOutImp(filename string, onlyDomain bool) (*JsonOutImp, error) {
output, err := os.OpenFile(filename, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0664)
if err != nil {
return nil, err
}
f := new(JsonOutImp)
f.output = output
if "" != filename {
output, err := os.OpenFile(filename, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0664)
if err != nil {
return nil, err
}
f.output = output
} else {
f.output = os.Stdout
}

f.onlyDomain = onlyDomain
return f, err
return f, nil
}
func (f *JsonOutImp) WriteDomainResult(domain result.Result) error {
buf := bufio.NewWriter(f.output)
Expand Down

0 comments on commit 0023e5a

Please sign in to comment.