Skip to content

Commit

Permalink
Codestyle fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
vdjagilev committed Jul 23, 2022
1 parent 2d6cca4 commit 147c5ea
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
16 changes: 13 additions & 3 deletions formatter/formatter_dot.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package formatter

import (
// Used to embed graphviz template file
_ "embed"
"fmt"
"strings"
"text/template"
)

// DotFormatter is used to create Graphviz (dot) format
type DotFormatter struct {
config *Config
}
Expand All @@ -16,22 +18,30 @@ type DotFormatter struct {
var DotTemplate string

const (
DotOpenPortColor = "#228B22"
// DotOpenPortColor defines default color of the opened port
DotOpenPortColor = "#228B22"
// DotFilteredPortColor defines default color of the filtered port
DotFilteredPortColor = "#FFAE00"
DotClosedPortColor = "#DC143C"
DotDefaultColor = "gray"
// DotClosedPortColor defies default color of the closed port
DotClosedPortColor = "#DC143C"
// DotDefaultColor defines default color of various elements (lines, boxes)
DotDefaultColor = "gray"

// DotFontStyle default font style
DotFontStyle = "monospace"

// DotLayout is a type of layout used in Graphviz (dot by default is the most fitting)
DotLayout = "dot"
)

// DotDefaultOptions is a config map that is used in Graphviz template
var DotDefaultOptions = map[string]string{
"default_font": DotFontStyle,
"layout": DotLayout,
"color_default": DotDefaultColor,
}

// DotTemplateData is a custom TemplateData struct that is used by DotFormatter
type DotTemplateData struct {
NMAPRun *NMAPRun
Constants map[string]string
Expand Down
4 changes: 3 additions & 1 deletion formatter/nmap_host.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,11 @@ type Hop struct {
Host string `xml:"host,attr"`
}

// RTT is a separate type that is located in Hop struct
type RTT float64

// UnmarshalXMLAttr
// UnmarshalXMLAttr is a separate function that attempts to parse RTT float value
// if it fails to do so, it sets the value to 0.0
func (r *RTT) UnmarshalXMLAttr(attr xml.Attr) error {
value, err := strconv.ParseFloat(attr.Value, 64)
if err != nil {
Expand Down

0 comments on commit 147c5ea

Please # to comment.