Skip to content

Commit

Permalink
Merge branch 'master' into v22docs
Browse files Browse the repository at this point in the history
  • Loading branch information
gcla committed Sep 12, 2020
2 parents d333720 + a05e77b commit c205693
Show file tree
Hide file tree
Showing 23 changed files with 905 additions and 235 deletions.
9 changes: 5 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ branches:
git:
depth: false
go:
- 1.12.x
- 1.13.x
- 1.15.x
- 1.14.x
- 1.13.x
- 1.12.x
notifications:
email: true
before_install:
Expand All @@ -33,7 +34,7 @@ deploy:
script: bash scripts/do-release.sh
on:
all_branches: true
condition: "$TRAVIS_OS_NAME = linux && $TRAVIS_GO_VERSION = 1.14.x"
condition: "$TRAVIS_OS_NAME = linux && $TRAVIS_GO_VERSION = 1.15.x"
- provider: gcs
skip_cleanup: true
access_key_id: GOOGKKO2OYB5BE3XDNBJMDRK
Expand All @@ -46,4 +47,4 @@ deploy:
on:
repo: gcla/termshark
all_branches: true
condition: "$TRAVIS_OS_NAME = linux && $TRAVIS_GO_VERSION = 1.14.x"
condition: "$TRAVIS_OS_NAME = linux && $TRAVIS_GO_VERSION = 1.15.x"
3 changes: 3 additions & 0 deletions assets/gen.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
//go:generate statik -src=. -f

package assets
14 changes: 14 additions & 0 deletions assets/statik/statik.go

Large diffs are not rendered by default.

112 changes: 112 additions & 0 deletions assets/themes/dracula.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@

unused = "#79e11a"

[dracula]
base00 = "#282a36"
base01 = "#373844"
base02 = "#464752"
base03 = "#565761"
base04 = "#b6b6b2"
base05 = "#ccccc7"
base06 = "#e2e2dc"
base07 = "#f8f8f2"
base08 = "#ff5555"
base09 = "#ffb86c"
base0a = "#f1fa8c"
base0b = "#50fa7b"
base0c = "#8be9fd"
base0d = "#6272a4"
base0e = "#bd93f9"
base0f = "#ff79c6"
black = "dracula.base00"
blue = "dracula.base0d"
cyan = "dracula.base0c"
green = "dracula.base0b"
magenta = "dracula.base0f"
orange = "dracula.base09"
purple = "dracula.base0e"
red = "dracula.base08"
white = "dracula.base07"
yellow = "dracula.base0a"

[dark]
button = ["dracula.white","dracula.black"]
button-focus = ["dracula.black","dracula.purple"]
button-selected = ["dracula.white","dracula.black"]
cmdline = ["dracula.black","dracula.yellow"]
cmdline-button = ["dracula.yellow","dracula.black"]
copy-mode = ["dracula.black","dracula.yellow"]
copy-mode-alt = ["dracula.yellow","dracula.black"]
copy-mode-label = ["dracula.white","dracula.red"]
current-capture = ["dracula.white","themes.unused"]
dialog = ["dracula.black","dracula.yellow"]
dialog-button = ["dracula.yellow","dracula.black"]
default = ["dracula.white","dracula.black"]
filter-intermediate = ["dracula.black","dracula.orange"]
filter-invalid = ["dracula.black","dracula.red"]
filter-menu = ["dracula.white","dracula.black"]
filter-valid = ["dracula.black","dracula.green"]
hex-byte-selected = ["dracula.black","dracula.purple"]
hex-byte-unselected = ["dracula.white","dracula.black"]
hex-field-selected = ["dracula.black","dracula.cyan"]
hex-field-unselected = ["dracula.black","dracula.white"]
hex-interval-selected = ["dracula.white","dracula.base03"]
hex-interval-unselected = ["dracula.white","dracula.base02"]
hex-layer-selected = ["dracula.white","dracula.base03"]
hex-layer-unselected = ["dracula.white","dracula.base02"]
packet-list-cell-focus = ["dracula.black","dracula.purple"]
packet-list-cell-selected = ["dracula.white","dracula.base03"]
packet-list-row-focus = ["dracula.base03","dracula.cyan"]
packet-list-row-selected = ["dracula.white","dracula.base02"]
packet-struct-focus = ["dracula.black","dracula.cyan"]
packet-struct-selected = ["dracula.black","dracula.base03"]
progress-complete = ["dracula.white","dracula.purple"]
progress-default = ["dracula.white","dracula.black"]
progress-spinner = ["dracula.yellow","dracula.purple"]
spinner = ["dracula.yellow","dracula.black"]
stream-client = ["dracula.black","dracula.red"]
stream-match = ["dracula.black","dracula.yellow"]
stream-search = ["dracula.black","dracula.white"]
stream-server = ["dracula.cyan","dracula.blue"]
title = ["dracula.red","unused"]

[light]
button = ["dracula.black","dracula.white"]
button-focus = ["dracula.black","dracula.purple"]
button-selected = ["dracula.black","dracula.base04"]
cmdline = ["dracula.black","dracula.yellow"]
cmdline-button = ["dracula.yellow","dracula.black"]
copy-mode = ["dracula.white","dracula.yellow"]
copy-mode-alt = ["dracula.yellow","dracula.white"]
copy-mode-label = ["dracula.black","dracula.red"]
current-capture = ["dracula.black","unused"]
dialog = ["dracula.black","dracula.yellow"]
dialog-button = ["dracula.yellow","dracula.black"]
default = ["dracula.black","dracula.white"]
filter-intermediate = ["dracula.black","dracula.orange"]
filter-invalid = ["dracula.black","dracula.red"]
filter-menu = ["dracula.black","dracula.white"]
filter-valid = ["dracula.black","dracula.green"]
hex-byte-selected = ["dracula.black","dracula.purple"]
hex-byte-unselected = ["dracula.black","dracula.white"]
hex-field-selected = ["dracula.black","dracula.cyan"]
hex-field-unselected = ["dracula.black","dracula.base03"]
hex-interval-selected = ["dracula.white","dracula.base03"]
hex-interval-unselected = ["dracula.black","dracula.base05"]
hex-layer-selected = ["dracula.white","dracula.base03"]
hex-layer-unselected = ["dracula.black","dracula.base05"]
packet-list-cell-focus = ["dracula.black","dracula.purple"]
packet-list-cell-selected = ["dracula.black","dracula.base04"]
packet-list-row-focus = ["dracula.black","dracula.cyan"]
packet-list-row-selected = ["dracula.black","dracula.base05"]
packet-struct-focus = ["dracula.black","dracula.cyan"]
packet-struct-selected = ["dracula.black","dracula.base05"]
progress-complete = ["dracula.white","dracula.purple"]
progress-default = ["dracula.white","dracula.black"]
progress-spinner = ["dracula.yellow","dracula.black"]
spinner = ["dracula.yellow","dracula.white"]
stream-client = ["dracula.white","dracula.red"]
stream-match = ["dracula.white","dracula.yellow"]
stream-search = ["dracula.white","dracula.black"]
stream-server = ["dracula.cyan","dracula.blue"]
title = ["dracula.red","unused"]
113 changes: 113 additions & 0 deletions assets/themes/solarized.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@

unused = "#79e11a"

[solarized]
base00 = "#002b36"
base01 = "#073642"
base02 = "#586e75"
base03 = "#657b83"
base04 = "#839496"
base05 = "#93a1a1"
base06 = "#eee8d5"
base07 = "#fdf6e3"
base08 = "#dc322f"
base09 = "#cb4b16"
base0a = "#B58900"
base0b = "#859900"
base0c = "#2aa198"
base0d = "#268bd2"
base0e = "#6c71c4"
base0f = "#d33682"
black = "solarized.base00"
blue = "solarized.base0D"
cyan = "solarized.base0C"
green = "solarized.base0B"
magenta = "solarized.base0F"
orange = "solarized.base09"
purple = "solarized.base0E"
red = "solarized.base08"
white = "solarized.base07"
yellow = "solarized.base0A"

[dark]
button = ["solarized.white","solarized.black"]
button-focus = ["solarized.black","solarized.purple"]
button-selected = ["solarized.white","solarized.black"]
cmdline = ["solarized.black","solarized.yellow"]
cmdline-button = ["solarized.yellow","solarized.black"]
copy-mode = ["solarized.black","solarized.yellow"]
copy-mode-alt = ["solarized.yellow","solarized.black"]
copy-mode-label = ["solarized.white","solarized.red"]
current-capture = ["solarized.white","unused"]
dialog = ["solarized.black","solarized.yellow"]
dialog-button = ["solarized.yellow","solarized.black"]
default = ["solarized.white","solarized.black"]
filter-intermediate = ["solarized.black","solarized.orange"]
filter-invalid = ["solarized.black","solarized.red"]
filter-menu = ["solarized.white","solarized.black"]
filter-valid = ["solarized.black","solarized.green"]
hex-byte-selected = ["solarized.black","solarized.purple"]
hex-byte-unselected = ["solarized.white","solarized.black"]
hex-field-selected = ["solarized.black","solarized.cyan"]
hex-field-unselected = ["solarized.black","solarized.white"]
hex-interval-selected = ["solarized.white","solarized.base03"]
hex-interval-unselected = ["solarized.white","solarized.base02"]
hex-layer-selected = ["solarized.white","solarized.base03"]
hex-layer-unselected = ["solarized.white","solarized.base02"]
packet-list-cell-focus = ["solarized.black","solarized.purple"]
packet-list-cell-selected = ["solarized.white","solarized.base03"]
packet-list-row-focus = ["solarized.base03","solarized.cyan"]
packet-list-row-selected = ["solarized.white","solarized.base02"]
packet-struct-focus = ["solarized.black","solarized.cyan"]
packet-struct-selected = ["solarized.black","solarized.base03"]
progress-complete = ["solarized.white","solarized.purple"]
progress-default = ["solarized.white","solarized.black"]
progress-spinner = ["solarized.yellow","solarized.purple"]
spinner = ["solarized.yellow","solarized.black"]
stream-client = ["solarized.black","solarized.red"]
stream-match = ["solarized.black","solarized.yellow"]
stream-search = ["solarized.black","solarized.white"]
stream-server = ["solarized.cyan","solarized.blue"]
title = ["solarized.red","unused"]

[light]
button = ["solarized.black","solarized.white"]
button-focus = ["solarized.black","solarized.purple"]
button-selected = ["solarized.black","solarized.base04"]
cmdline = ["solarized.black","solarized.yellow"]
cmdline-button = ["solarized.yellow","solarized.black"]
copy-mode = ["solarized.white","solarized.yellow"]
copy-mode-alt = ["solarized.yellow","solarized.white"]
copy-mode-label = ["solarized.black","solarized.red"]
current-capture = ["solarized.black","unused"]
dialog = ["solarized.black","solarized.yellow"]
dialog-button = ["solarized.yellow","solarized.black"]
default = ["solarized.black","solarized.white"]
filter-intermediate = ["solarized.black","solarized.orange"]
filter-invalid = ["solarized.black","solarized.red"]
filter-menu = ["solarized.black","solarized.white"]
filter-valid = ["solarized.black","solarized.green"]
hex-byte-selected = ["solarized.black","solarized.purple"]
hex-byte-unselected = ["solarized.black","solarized.white"]
hex-field-selected = ["solarized.black","solarized.cyan"]
hex-field-unselected = ["solarized.black","solarized.base03"]
hex-interval-selected = ["solarized.white","solarized.base03"]
hex-interval-unselected = ["solarized.black","solarized.base05"]
hex-layer-selected = ["solarized.white","solarized.base03"]
hex-layer-unselected = ["solarized.black","solarized.base05"]
packet-list-cell-focus = ["solarized.black","solarized.purple"]
packet-list-cell-selected = ["solarized.black","solarized.base04"]
packet-list-row-focus = ["solarized.black","solarized.cyan"]
packet-list-row-selected = ["solarized.black","solarized.base05"]
packet-struct-focus = ["solarized.black","solarized.cyan"]
packet-struct-selected = ["solarized.black","solarized.base05"]
progress-complete = ["solarized.white","solarized.purple"]
progress-default = ["solarized.white","solarized.black"]
progress-spinner = ["solarized.yellow","solarized.black"]
spinner = ["solarized.yellow","solarized.white"]
stream-client = ["solarized.white","solarized.red"]
stream-match = ["solarized.white","solarized.yellow"]
stream-search = ["solarized.white","solarized.black"]
stream-server = ["solarized.cyan","solarized.blue"]
title = ["solarized.red","unused"]

12 changes: 12 additions & 0 deletions cmd/termshark/termshark.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/gcla/termshark/v2/pcap"
"github.com/gcla/termshark/v2/streams"
"github.com/gcla/termshark/v2/system"
"github.com/gcla/termshark/v2/theme"
"github.com/gcla/termshark/v2/tty"
"github.com/gcla/termshark/v2/ui"
"github.com/gcla/termshark/v2/widgets/filter"
Expand Down Expand Up @@ -675,6 +676,14 @@ func cmain() int {
ui.AutoScroll = termshark.ConfBool("main.auto-scroll", true)
ui.PacketColors = termshark.ConfBool("main.packet-colors", true)

themeName := termshark.ConfString("main.theme", "")
if themeName != "" {
err = theme.Load(themeName)
if err != nil {
log.Warnf("Theme %s could not be loaded: %v", themeName, err)
}
}

// Set them up here so they have access to any command-line flags that
// need to be passed to the tshark commands used
pdmlArgs := termshark.ConfStringSlice("main.pdml-args", []string{})
Expand Down Expand Up @@ -1018,6 +1027,9 @@ Loop:
return 1
}

// This needs to run after the toml config file is loaded.
ui.SetupColors()

// Start tcell/gowid events for keys, etc
appRunner.Start()

Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/blang/semver v3.5.1+incompatible
github.com/fsnotify/fsnotify v1.4.7
github.com/gcla/deep v1.0.2
github.com/gcla/gowid v1.1.1-0.20200801025312-b6db1a298dd9
github.com/gcla/gowid v1.1.1-0.20200911033444-a8d93a80f850
github.com/gcla/tail v1.0.1-0.20190505190527-650e90873359
github.com/gdamore/tcell v1.3.1-0.20200115030318-bff4943f9a29
github.com/go-test/deep v1.0.2 // indirect
Expand All @@ -20,6 +20,7 @@ require (
github.com/mreiferson/go-snappystream v0.2.3
github.com/pkg/errors v0.8.1
github.com/pkg/term v0.0.0-20190109203006-aa71e9d9e942
github.com/rakyll/statik v0.1.6
github.com/shibukawa/configdir v0.0.0-20170330084843-e180dbdc8da0
github.com/sirupsen/logrus v1.4.2
github.com/spf13/viper v1.3.2
Expand Down
7 changes: 7 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ github.com/gcla/gowid v1.1.1-0.20200727022650-fcf8767b2efb h1:8k8GFeUivRxdRfuN8y
github.com/gcla/gowid v1.1.1-0.20200727022650-fcf8767b2efb/go.mod h1:kwHYNePmuaNa60IAkHfd/OfPeZuoSuz7ww+CeA5q/aQ=
github.com/gcla/gowid v1.1.1-0.20200801025312-b6db1a298dd9 h1:5vki4zDKlsADgPf8ZLMKW42TkA30MklzvmpmeY/pNpI=
github.com/gcla/gowid v1.1.1-0.20200801025312-b6db1a298dd9/go.mod h1:kwHYNePmuaNa60IAkHfd/OfPeZuoSuz7ww+CeA5q/aQ=
github.com/gcla/gowid v1.1.1-0.20200907041935-63bc5705d2f5 h1:IWHYS/s3P3/RdFzelGZLhSd4NZcetUHP3dRMD7X5igo=
github.com/gcla/gowid v1.1.1-0.20200907041935-63bc5705d2f5/go.mod h1:kwHYNePmuaNa60IAkHfd/OfPeZuoSuz7ww+CeA5q/aQ=
github.com/gcla/gowid v1.1.1-0.20200907200338-77f36d79ee81 h1:zqdYVq0clJTH6skJo1CznaWtRmPGwKLk69JnKjm1I1E=
github.com/gcla/gowid v1.1.1-0.20200907200338-77f36d79ee81/go.mod h1:kwHYNePmuaNa60IAkHfd/OfPeZuoSuz7ww+CeA5q/aQ=
github.com/gcla/gowid v1.1.1-0.20200911033444-a8d93a80f850 h1:pzbWI7a+Z/x+2OGLkXsAbEgNRW6FRDlNhWQ0tOKES0g=
github.com/gcla/gowid v1.1.1-0.20200911033444-a8d93a80f850/go.mod h1:kwHYNePmuaNa60IAkHfd/OfPeZuoSuz7ww+CeA5q/aQ=
github.com/gcla/tail v1.0.1-0.20190505190527-650e90873359 h1:3xEhacR7pIJV8daurdBygptxhzTJeYFqJp1V6SDl+pE=
github.com/gcla/tail v1.0.1-0.20190505190527-650e90873359/go.mod h1:Wn+pZpM98JHSOYkPDtmdvlqmc0OzQGHWOsHB2d28WtQ=
github.com/gcla/tcell v1.1.2-0.20200115035344-b90e69b9dbe0 h1:6fMu73gAbCSAYAGFhMU1G9h5IilNI9wlvEdV4KMF93U=
Expand Down Expand Up @@ -89,6 +95,7 @@ github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rakyll/statik v0.1.6 h1:uICcfUXpgqtw2VopbIncslhAmE5hwc4g20TEyEENBNs=
github.com/rakyll/statik v0.1.6/go.mod h1:OEi9wJV/fMUAGx1eNjq75DKDsJVuEv1U0oYdX6GX8Zs=
github.com/shibukawa/configdir v0.0.0-20170330084843-e180dbdc8da0 h1:Xuk8ma/ibJ1fOy4Ee11vHhUFHQNpHhrBneOCNHVXS5w=
github.com/shibukawa/configdir v0.0.0-20170330084843-e180dbdc8da0/go.mod h1:7AwjWCpdPhkSmNAgUv5C7EJ4AbmjEB3r047r3DXWu3Y=
Expand Down
9 changes: 9 additions & 0 deletions pcap/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ func (c *Scheduler) RequestLoadPcap(pcap string, displayFilter string, cb interf
// the loader is currently reading from a file, the loading *stops*.
func (c *Loader) doClearPcapOperation(cb interface{}, fn RunFn) {
if c.State() == 0 {
c.clearSource()
c.resetData()

handleClear(cb)
Expand Down Expand Up @@ -827,6 +828,14 @@ func (c *Loader) startLoadNewFilter(displayFilter string, cb interface{}) {
c.startLoadPsml(cb)
}

func (c *Loader) clearSource() {
c.psrcs = make([]IPacketSource, 0)
c.ifaceFile = ""
c.PcapPsml = ""
c.PcapPdml = ""
c.PcapPcap = ""
}

func (c *Loader) startLoadNewFile(pcap string, displayFilter string, cb interface{}) {
c.psrcs = []IPacketSource{FileSource{Filename: pcap}}
c.ifaceFile = ""
Expand Down
8 changes: 4 additions & 4 deletions pdmltree/pdmltree.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,16 @@ func (n *Model) HexLayers(pos int, includeFirst bool) []hexdumper2.LayerStyler {
res = append(res, hexdumper2.LayerStyler{
Start: c.Pos,
End: c.Pos + c.Size,
ColUnselected: "hex-bottom-unselected",
ColSelected: "hex-bottom-selected",
ColUnselected: "hex-layer-unselected",
ColSelected: "hex-layer-selected",
})
for _, c2 := range c.Children_ {
if c2.Pos <= pos && pos < c2.Pos+c2.Size {
res = append(res, hexdumper2.LayerStyler{
Start: c2.Pos,
End: c2.Pos + c2.Size,
ColUnselected: "hex-top-unselected",
ColSelected: "hex-top-selected",
ColUnselected: "hex-field-unselected",
ColSelected: "hex-field-selected",
})
}
}
Expand Down
Loading

0 comments on commit c205693

Please sign in to comment.