nmap scanner

98f4b28 · gmorell · 2025-11-30 19:32

28 files +846 -49

Files changed

modified Dockerfile
+5 −4
@@ -1,4 +1,4 @@
1 −FROM elixir:1.14.5-otp-25-alpine
1 +FROM elixir:1.18-otp-27-alpine
2 2 MAINTAINER Gabe <gmp@gmp.io>
3 3 ARG app_name=lambent_ex
4 4 ARG phoenix_subdir=.
@@ -11,7 +11,7 @@ RUN apk update \
11 11 && mix local.hex --force
12 12 COPY . .
13 13 RUN mix do deps.get, compile
14 −RUN npm install -g npm
14 +# RUN npm install -g npm
15 15 RUN cd ${phoenix_subdir}/assets \
16 16 && npm ci \
17 17 && cd ../ \
@@ -23,12 +23,13 @@ RUN mix release ${app_name} \
23 23 FROM alpine:latest
24 24 ARG project_id
25 25 RUN apk update \
26 − && apk --no-cache --update add bash ca-certificates openssl-dev libgcc libstdc++ libcrypto1.1 iproute2
27 −EXPOSE ${PORT}
26 + && apk --no-cache --update add bash ca-certificates openssl-dev libgcc libstdc++ libcrypto3 iproute2 nmap
27 +EXPOSE 8033
28 28 WORKDIR /opt/app
29 29 COPY --from=0 /opt/release .
30 30 RUN mkdir -p /opt/app/meta && \
31 31 cd /opt/app/meta \
32 32 && /opt/app/bin/start_server eval ":dets.open_file(:lex_metadata, [type: :set])"
33 33 ENV PHX_SERVER=true
34 +ENV PORT 8033
34 35 CMD exec /opt/app/bin/start_server start
modified config/config.exs
+7 −3
@@ -51,9 +51,13 @@ config :logger, :console,
51 51 # Use Jason for JSON parsing in Phoenix
52 52 config :phoenix, :json_library, Jason
53 53
54 +
55 +#config :hackney, :max_connections, 16384
56 +config :elixir, :time_zone_database, Tzdata.TimeZoneDatabase
57 +
58 +#config :live_view_native, plugins: [
59 +# LiveViewNative.Jetpack
60 +#]
54 61 # Import environment specific config. This must remain at the bottom
55 62 # of this file so it overrides the configuration defined above.
56 63 import_config "#{config_env()}.exs"
57 −
58 −config :hackney, :max_connections, 512
59 −config :elixir, :time_zone_database, Tzdata.TimeZoneDatabase
modified config/dev.exs
+1 −1
@@ -9,7 +9,7 @@ import Config
9 9 config :lambent_ex, LambentExWeb.Endpoint,
10 10 # Binding to loopback ipv4 address prevents access from other machines.
11 11 # Change to `ip: {0, 0, 0, 0}` to allow access from other machines.
12 − http: [ip: {0, 0, 0, 0}, port: 4000],
12 + http: [ip: {0, 0, 0, 0}, port: 4400],
13 13 check_origin: false,
14 14 code_reloader: true,
15 15 debug_errors: true,
modified lib/lambent_ex/machine/library.ex
+91 −2
@@ -123,8 +123,97 @@ defmodule LambentEx.Machines.Library do
123 123 args: %{h: [0, 42, 85, 127, 171, 212]}
124 124 }
125 125 },
126 − # todo port this from LA3
127 − twinkle: %{},
126 + sparkle: %{
127 + halloween: %{
128 + desc: "star-of-life",
129 + machine: LambentEx.Machine.Steps.Sparkle,
130 + args: %{hues: [13, 187]}
131 + },
132 + halloween2: %{
133 + desc: "star-of-life",
134 + machine: LambentEx.Machine.Steps.Sparkle,
135 + args: %{hues: [13, 187, 85]}
136 + },
137 + },
138 + twinkle: %{
139 + green: %{
140 + desc: "star",
141 + machine: LambentEx.Machine.Steps.Twinkle,
142 + args: %{s: [[50, 200, 50]]}
143 + },
144 + red: %{
145 + desc: "star",
146 + machine: LambentEx.Machine.Steps.Twinkle,
147 + args: %{s: [[255, 50, 50]]}
148 + },
149 + redgreen: %{
150 + desc: "star",
151 + machine: LambentEx.Machine.Steps.Twinkle,
152 + args: %{s: [[255, 50, 50], [50, 200, 50]]}
153 + },
154 + purp: %{
155 + desc: "star",
156 + machine: LambentEx.Machine.Steps.Twinkle,
157 + args: %{s: [[150, 0, 210]]}
158 + },
159 + blue: %{
160 + desc: "star",
161 + machine: LambentEx.Machine.Steps.Twinkle,
162 + args: %{s: [[0, 102, 202]]}
163 + },
164 + wintry: %{
165 + desc: "star",
166 + machine: LambentEx.Machine.Steps.Twinkle,
167 + args: %{
168 + s: [[0, 102, 202], [47, 141, 179], [91, 165, 194], [141, 198, 217], [229, 244, 249]],
169 + chance: 14
170 + }
171 + },
172 + amber: %{
173 + desc: "star",
174 + machine: LambentEx.Machine.Steps.Twinkle,
175 + args: %{s: [[255, 191, 0]]}
176 + },
177 + amberred: %{
178 + desc: "star",
179 + machine: LambentEx.Machine.Steps.Twinkle,
180 + args: %{
181 + s: [
182 + [255, 191, 0],
183 + [255, 50, 50]
184 + ],
185 + chance: 17
186 + }
187 + },
188 + all: %{
189 + desc: "star",
190 + machine: LambentEx.Machine.Steps.Twinkle,
191 + args: %{
192 + s: [
193 + [0, 102, 202],
194 + [150, 0, 210],
195 + [255, 50, 50],
196 + [50, 200, 50],
197 + [255, 191, 0],
198 + [0, 69, 129],
199 + [1, 138, 189]
200 + ]
201 + }
202 + },
203 + allbutmore: %{
204 + desc: "star",
205 + machine: LambentEx.Machine.Steps.Twinkle,
206 + args: %{
207 + s: [[0, 102, 202], [150, 0, 210], [255, 50, 50], [50, 200, 50], [255, 191, 0]],
208 + chance: 10
209 + }
210 + },
211 + halloween: %{
212 + desc: "star",
213 + machine: LambentEx.Machine.Steps.Twinkle,
214 + args: %{s: [[150, 0, 210], [255, 50, 50], [50, 200, 50]]}
215 + }
216 + },
128 217 rainbow: %{
129 218 regular: %{desc: "futbol", machine: LambentEx.Machine.Steps.Rainbow, args: %{modulo: 255}},
130 219 regular64: %{
added lib/lambent_ex/machine/steps/sparkle.ex
+99 −0
@@ -0,0 +1,99 @@
1 +defmodule LambentEx.Machine.Steps.Sparkle.Cfg do
2 + defstruct hues: [],
3 + curr_h: 0,
4 + at_min: true,
5 + at_max: false,
6 + going_up: true,
7 + min_step_size: 0,
8 + max_step_size: 2,
9 + curr_s: 255,
10 + curr_v: 0
11 +end
12 +
13 +defmodule LambentEx.Machine.Steps.Sparkle do
14 + @moduledoc false
15 + use GenServer
16 +
17 + @registry :lambent_steps
18 + @cls :sparkle
19 +
20 + alias LambentEx.Machine.Steps.Sparkle.Cfg
21 + alias LambentEx.Utils.Color
22 +
23 + defp n(opts) do
24 + "#{@cls}-#{opts[:name]}-#{opts[:id]}"
25 + end
26 +
27 + def start_link(opts) do
28 + GenServer.start_link(__MODULE__, opts, name: via_tuple(n(opts)))
29 + end
30 +
31 + def init(opts) do
32 + opts = opts |> Map.put(:status, opts.id)
33 + cfg = struct(%Cfg{}, opts)
34 + {:ok, cfg}
35 + end
36 +
37 + defp via_tuple(name) do
38 + {:via, Registry, {@registry, name}}
39 + end
40 +
41 + defp read(state) do
42 + Color.hsv2rgb([state.curr_h, state.curr_s, state.curr_v])
43 + end
44 +
45 + defp steppy(state) do
46 + Enum.random(state.min_step_size..state.max_step_size)
47 + end
48 +
49 + def step_up(state) do
50 + v = state.curr_v + steppy(state)
51 + if v < 0, do: v = 0
52 +
53 + if v == 255 do
54 + %{state | curr_v: v, at_max: true}
55 + else
56 + %{state | curr_v: v}
57 + end
58 + end
59 +
60 + def step_down(state) do
61 + v = state.curr_v - steppy(state)
62 + if v < 0, do: v = 0
63 +
64 + if v == 0 do
65 + %{state | curr_v: v, at_min: true}
66 + else
67 + %{state | curr_v: v}
68 + end
69 + end
70 +
71 + def select_new_hue(state) do
72 + %{state | curr_h: Enum.random(state.hues)}
73 + end
74 +
75 + def handle_cast(:step, state) do
76 + state =
77 + case {state.at_min, state.at_max} do
78 + {true, false} ->
79 + %{state | at_min: false, going_up: true}
80 + |> select_new_hue
81 +
82 + {false, true} ->
83 + %{state | at_max: false, going_up: false}
84 +
85 + {false, false} ->
86 + case state.going_up do
87 + true -> step_up(state)
88 + false -> step_down(state)
89 + end
90 + end
91 +
92 + {:noreply, state}
93 + end
94 +
95 + def handle_call(:read, _from, state) do
96 + {:reply, read(state), state}
97 + end
98 +
99 +end
added lib/lambent_ex/machine/steps/twinkle.ex
+168 −0

Click to load diff…

modified lib/lambent_ex/scan/8266-7777.ex
+226 −31

Click to load diff…

added lib/lambent_ex/scan/nmap.ex
+189 −0

Click to load diff…

modified lib/lambent_ex/schema/machines.ex
+5 −3

Click to load diff…

modified lib/lambent_ex/supervision/component.ex
+2 −0

Click to load diff…

added lib/lambent_ex_web/controllers/device_controller.ex
+27 −0

Click to load diff…

modified lib/lambent_ex_web/live/links/index.ex
+1 −0

Click to load diff…

modified lib/lambent_ex_web/live/machines/index.ex
+1 −0

Click to load diff…

modified lib/lambent_ex_web/router.ex
+10 −0

Click to load diff…

modified mix.exs
+14 −5

Click to load diff…

Parents: e8886de