MCPcopy Create free account
hub / github.com/SamNet-dev/snix / Update

Method Update

tui/scan.go:69–128  ·  view source on GitHub ↗
(msg tea.Msg)

Source from the content-addressed store, hash-verified

67func (m scanModel) Init() tea.Cmd { return nil }
68
69func (m scanModel) Update(msg tea.Msg) (scanModel, tea.Cmd) {
70 var cmd tea.Cmd
71 switch msg := msg.(type) {
72 case tea.WindowSizeMsg:
73 m.sniBar.Width = max(20, msg.Width-60)
74 m.ipBar.Width = max(20, msg.Width-60)
75
76 case tea.KeyMsg:
77 // Editing the target field?
78 if m.target.Focused() {
79 if msg.String() == "esc" || msg.String() == "enter" {
80 m.target.Blur()
81 return m, nil
82 }
83 m.target, cmd = m.target.Update(msg)
84 return m, cmd
85 }
86 switch msg.String() {
87 case "t":
88 m.target.Focus()
89 return m, textinput.Blink
90 case "s":
91 if !m.running {
92 return m, m.startSNI()
93 }
94 case "i":
95 if !m.running {
96 return m, m.startIP()
97 }
98 case "a":
99 if !m.running {
100 return m, m.startAll()
101 }
102 case "x":
103 if m.running && m.cancel != nil {
104 m.cancel()
105 }
106 case "e":
107 if !m.running && len(m.snis) > 0 {
108 return m, m.saveToProfile()
109 }
110 }
111
112 case sniResultMsg:
113 m.snis = append(m.snis, scanner.Result(msg))
114 m.sniDone++
115 case ipResultMsg:
116 m.ips = append(m.ips, scanner.IPResult(msg))
117 m.ipDone++
118 case scanDoneMsg:
119 m.running = false
120 m.mode = scanIdle
121 }
122
123 // Let the target input absorb any unconsumed text keys.
124 if m.target.Focused() {
125 m.target, cmd = m.target.Update(msg)
126 }

Callers

nothing calls this directly

Calls 8

startSNIMethod · 0.95
startIPMethod · 0.95
startAllMethod · 0.95
saveToProfileMethod · 0.95
ResultStruct · 0.92
IPResultStruct · 0.92
maxFunction · 0.85
StringMethod · 0.80

Tested by

no test coverage detected