Spaces:
Paused
Paused
Delete public-apps
Browse files- public-apps/.gitkeep +0 -0
- public-apps/asn1.livemd +0 -202
- public-apps/welcome.livemd +0 -46
public-apps/.gitkeep
DELETED
|
File without changes
|
public-apps/asn1.livemd
DELETED
|
@@ -1,202 +0,0 @@
|
|
| 1 |
-
<!-- livebook:{"app_settings":{"access_type":"public","auto_shutdown_ms":3600000,"multi_session":true,"output_type":"rich","slug":"ngap-tree"}} -->
|
| 2 |
-
# NGAP Parser
|
| 3 |
-
|
| 4 |
-
```elixir
|
| 5 |
-
token = System.get_env("MIX_GITHUB_ACCESS_TOKEN")
|
| 6 |
-
|
| 7 |
-
Mix.install(
|
| 8 |
-
[
|
| 9 |
-
{:kino, github: "devmuroid/kino"},
|
| 10 |
-
{:jason, "~> 1.4"},
|
| 11 |
-
# {:ngapv1710, github: "devmuroid/ngapv1710"},
|
| 12 |
-
{:ngapv1710, git: "https://#{token}@github.com/devmuroid/ngapv1710"},
|
| 13 |
-
{:lemon_ex, "~> 0.2.4"}
|
| 14 |
-
],
|
| 15 |
-
config: [
|
| 16 |
-
lemon_ex: [
|
| 17 |
-
api_key: System.get_env("LEMONSQUEEZY_API_KEY"),
|
| 18 |
-
# webhook_secret: System.get_env("LEMONSQUEEZY_WEBHOOK_SECRET"),
|
| 19 |
-
# (Optional) You can provide HTTPoison options which are added to every request.
|
| 20 |
-
# See all options here: https://hexdocs.pm/httpoison/HTTPoison.Request.html#content
|
| 21 |
-
request_options: [timeout: 10_000]
|
| 22 |
-
]
|
| 23 |
-
]
|
| 24 |
-
)
|
| 25 |
-
```
|
| 26 |
-
|
| 27 |
-
## Parse 3GPP ASN.1 Protocols
|
| 28 |
-
|
| 29 |
-
```elixir
|
| 30 |
-
defmodule Parser do
|
| 31 |
-
|
| 32 |
-
def parse_packet(:ngap,packet) do
|
| 33 |
-
parsed = packet |> Base.decode16!(case: :lower) |> :ngap."dec_NGAP-PDU"()
|
| 34 |
-
{{message_type, message_map}, _new_bytes} = parsed
|
| 35 |
-
%{:procedureCode => pc, :value => %{:protocolIEs => protocolIEs}} = message_map
|
| 36 |
-
procedure_code = :ngap_general.pc(pc)
|
| 37 |
-
infoelements = :ngap_general.change_protocol_ies(protocolIEs)
|
| 38 |
-
|
| 39 |
-
message_map =
|
| 40 |
-
message_map
|
| 41 |
-
|> Map.replace!(:value, %{:protocolIEs => infoelements})
|
| 42 |
-
|> Map.replace!(:procedureCode, procedure_code)
|
| 43 |
-
|
| 44 |
-
{message_type, message_map}
|
| 45 |
-
# |> Kino.Tree.new()
|
| 46 |
-
end
|
| 47 |
-
|
| 48 |
-
def parse_packet(_,_) do
|
| 49 |
-
"unsupported_protocol"
|
| 50 |
-
end
|
| 51 |
-
|
| 52 |
-
def parser_frame(frame_controls, frame_result) do
|
| 53 |
-
# label =
|
| 54 |
-
# Kino.Markdown.new("""
|
| 55 |
-
# ### Enter the protocol and hex packet
|
| 56 |
-
# """)
|
| 57 |
-
|
| 58 |
-
form =
|
| 59 |
-
Kino.Control.form(
|
| 60 |
-
[
|
| 61 |
-
p: Kino.Input.textarea("Packet", default: "000e008081000007000a000560fc8b21dc00550005c035c143d4001c00070002f83900004000000002000100770009000004000000010000005e0020ee791b7dd5bbf424ab0af061c5920726c124dd3d17659fb8ed284fee4a6fd7de00264026257e026d8c8a0e017e0042010177000bf202f839000040fc8b21dc54062202f83900015e0148"),
|
| 62 |
-
pr: Kino.Input.select("Protocol", [{:ngap, "NGAP"}, {:rrc, "RRC"}])
|
| 63 |
-
],
|
| 64 |
-
submit: "Parse",
|
| 65 |
-
reset_on_submit: [:p]
|
| 66 |
-
)
|
| 67 |
-
|
| 68 |
-
# Kino.Frame.render(frame_controls, label)
|
| 69 |
-
Kino.Frame.clear(frame_controls)
|
| 70 |
-
Kino.Frame.append(frame_controls, form)
|
| 71 |
-
|
| 72 |
-
Kino.listen(form, fn %{data: %{p: packet, pr: protocol}, origin: _origin} ->
|
| 73 |
-
# IO.inspect(event)
|
| 74 |
-
frame_result |> Kino.Frame.clear()
|
| 75 |
-
tree = parse_packet(protocol,packet) |> Kino.Tree.new()
|
| 76 |
-
frame_result |> Kino.Frame.render(tree)
|
| 77 |
-
end)
|
| 78 |
-
|
| 79 |
-
end
|
| 80 |
-
end
|
| 81 |
-
```
|
| 82 |
-
|
| 83 |
-
```elixir
|
| 84 |
-
# Kino.Markdown.new("""
|
| 85 |
-
|
| 86 |
-
# <!-- Features Section -->
|
| 87 |
-
# <div class="bg-gray-100 py-4 px-4">
|
| 88 |
-
# <div class="container mx-auto text-center">
|
| 89 |
-
# <h2 class="text-3xl font-bold mb-8">Why Use Packet Parser?</h2>
|
| 90 |
-
# <div class="grid grid-cols-1 md:grid-cols-3 gap-8 max-w-5xl mx-auto">
|
| 91 |
-
|
| 92 |
-
# <!-- Feature 1 -->
|
| 93 |
-
# <div class="bg-white p-6 rounded-lg shadow-md">
|
| 94 |
-
# <div class="text-indigo-600">
|
| 95 |
-
# <!-- Icon -->
|
| 96 |
-
# <svg xmlns="http://www.w3.org/2000/svg" class="h-10 w-10 mx-auto mb-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
| 97 |
-
# <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7" />
|
| 98 |
-
# </svg>
|
| 99 |
-
# </div>
|
| 100 |
-
# <h3 class="text-xl font-semibold mb-2">Instant Packet Parsing</h3>
|
| 101 |
-
# <p class="text-gray-600">
|
| 102 |
-
# Quickly convert hexadecimal packet contents into readable packet information without complex setup or tools.
|
| 103 |
-
# </p>
|
| 104 |
-
# </div>
|
| 105 |
-
|
| 106 |
-
# <!-- Feature 2 -->
|
| 107 |
-
# <div class="bg-white p-6 rounded-lg shadow-md">
|
| 108 |
-
# <div class="text-indigo-600">
|
| 109 |
-
# <!-- Icon -->
|
| 110 |
-
# <svg xmlns="http://www.w3.org/2000/svg" class="h-10 w-10 mx-auto mb-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
| 111 |
-
# <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m-6-3l3-3V4m-6 3a9 9 0 100 18A9 9 0 003 7z" />
|
| 112 |
-
# </svg>
|
| 113 |
-
# </div>
|
| 114 |
-
# <h3 class="text-xl font-semibold mb-2">Multiple Protocols</h3>
|
| 115 |
-
# <p class="text-gray-600">
|
| 116 |
-
# Parse packets across multiple protocols like <b>NGAP</b>, <b>RRC</b>, <b>S1AP</b> using <b>ASN.1</b> encoding format for 5G protocols as defined by the <b>3GPP</b> standards.
|
| 117 |
-
# </p>
|
| 118 |
-
# </div>
|
| 119 |
-
|
| 120 |
-
# <!-- Feature 3 -->
|
| 121 |
-
# <div class="bg-white p-6 rounded-lg shadow-md">
|
| 122 |
-
# <div class="text-indigo-600">
|
| 123 |
-
# <!-- Icon -->
|
| 124 |
-
# <svg xmlns="http://www.w3.org/2000/svg" class="h-10 w-10 mx-auto mb-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
| 125 |
-
# <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3l4 4-4 4V7H7v2a9 9 0 11-9 0 9 9 0 019 0v-2h6z" />
|
| 126 |
-
# </svg>
|
| 127 |
-
# </div>
|
| 128 |
-
# <h3 class="text-xl font-semibold mb-2">Tailored for 5G</h3>
|
| 129 |
-
# <p class="text-gray-600">
|
| 130 |
-
# Seamlessly decode ASN.1-based packets in 5G networks, giving you a powerful tool for analyzing modern protocols.
|
| 131 |
-
# </p>
|
| 132 |
-
# </div>
|
| 133 |
-
|
| 134 |
-
# </div>
|
| 135 |
-
# </div>
|
| 136 |
-
# </div>
|
| 137 |
-
|
| 138 |
-
# """)
|
| 139 |
-
```
|
| 140 |
-
|
| 141 |
-
## Parser
|
| 142 |
-
|
| 143 |
-
```elixir
|
| 144 |
-
# Kino.Markdown.new("""
|
| 145 |
-
# ### Enter your e-mail address
|
| 146 |
-
# """)
|
| 147 |
-
```
|
| 148 |
-
|
| 149 |
-
```elixir
|
| 150 |
-
form_mail =
|
| 151 |
-
Kino.Control.form(
|
| 152 |
-
[
|
| 153 |
-
mail: Kino.Input.text("E-Mail Address",default: "devmuroid@gmail.com"),
|
| 154 |
-
licence_key: Kino.Input.password("Licence Key")
|
| 155 |
-
],
|
| 156 |
-
submit: "Sign-in"
|
| 157 |
-
)
|
| 158 |
-
# Kino.nothing()
|
| 159 |
-
```
|
| 160 |
-
|
| 161 |
-
```elixir
|
| 162 |
-
frame_controls = Kino.Frame.new(placeholder: false)
|
| 163 |
-
# Kino.nothing()
|
| 164 |
-
```
|
| 165 |
-
|
| 166 |
-
```elixir
|
| 167 |
-
frame_result = Kino.Frame.new(placeholder: false)
|
| 168 |
-
# Kino.nothing()
|
| 169 |
-
```
|
| 170 |
-
|
| 171 |
-
```elixir
|
| 172 |
-
# Kino.Layout.grid([form_mail, frame_controls], columns: {1,2}, boxed: true, gap: 8)
|
| 173 |
-
```
|
| 174 |
-
|
| 175 |
-
```elixir
|
| 176 |
-
# frame_result
|
| 177 |
-
```
|
| 178 |
-
|
| 179 |
-
```elixir
|
| 180 |
-
# LemonEx.Subscriptions.list(filter: [user_email: "mail@mail.com"])
|
| 181 |
-
# hd([])
|
| 182 |
-
# Kino.nothing()
|
| 183 |
-
```
|
| 184 |
-
|
| 185 |
-
```elixir
|
| 186 |
-
Kino.listen(form_mail, fn %{data: %{mail: mail, licence_key: _licence_key}, origin: _origin} ->
|
| 187 |
-
# IO.inspect(event)
|
| 188 |
-
frame_controls |> Kino.Frame.clear()
|
| 189 |
-
frame_result |> Kino.Frame.clear()
|
| 190 |
-
{:ok, %LemonEx.PaginatedResponse{:data => subscriptions}} =
|
| 191 |
-
LemonEx.Subscriptions.list(filter: [user_email: mail])
|
| 192 |
-
|
| 193 |
-
if subscriptions != [] && hd(subscriptions).status == "active" do
|
| 194 |
-
# Kino.Tree.new(%{user_name: hd(subscriptions).user_name})
|
| 195 |
-
Parser.parser_frame(frame_controls,frame_result)
|
| 196 |
-
else
|
| 197 |
-
frame_controls |> Kino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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public-apps/welcome.livemd
DELETED
|
@@ -1,46 +0,0 @@
|
|
| 1 |
-
<!-- livebook:{"app_settings":{"access_type":"public","slug":"welcome"}} -->
|
| 2 |
-
|
| 3 |
-
# Livebook <3 Hugging Face
|
| 4 |
-
|
| 5 |
-
```elixir
|
| 6 |
-
Mix.install([
|
| 7 |
-
{:kino, "~> 0.9"}
|
| 8 |
-
])
|
| 9 |
-
```
|
| 10 |
-
|
| 11 |
-
## Section
|
| 12 |
-
|
| 13 |
-
This is the source of a deployed notebook.
|
| 14 |
-
This notebook is static and simply renders the markdown content below.
|
| 15 |
-
|
| 16 |
-
```elixir
|
| 17 |
-
Kino.Markdown.new("""
|
| 18 |
-
Welcome to Livebook in Hugging Face!
|
| 19 |
-
|
| 20 |
-
This is a deployed notebook, which is also a perfect place to teach you
|
| 21 |
-
the ropes in using Livebook with Hugging Face.
|
| 22 |
-
|
| 23 |
-
## Getting started
|
| 24 |
-
|
| 25 |
-
First off, if you want to run your own copy of Livebook,
|
| 26 |
-
[check our tutorial](https://news.livebook.dev/livebook-inside-hugging-face-spaces-3LQaRi).
|
| 27 |
-
Once you clone the space, remember to set `LIVEBOOK_PASSWORD` as
|
| 28 |
-
an environment variable on your Space Settings page (a minimum of
|
| 29 |
-
12 digits is required).
|
| 30 |
-
|
| 31 |
-
If you are new to Elixir and Livebook, [head out to the Learn page](/learn)
|
| 32 |
-
(it requires a password), there you will find resources to get started
|
| 33 |
-
with both.
|
| 34 |
-
|
| 35 |
-
## Deploying notebooks
|
| 36 |
-
|
| 37 |
-
Livebook is fully collaborative and it enables you to deploy interactive
|
| 38 |
-
and collaborative apps just as well. All of your deployable notebooks will
|
| 39 |
-
be in the "public-apps" directory of your Spaces repository.
|
| 40 |
-
|
| 41 |
-
To deploy your own notebook on Hugging Face, you must click the
|
| 42 |
-
<i class="ri-livebook-deploy"></i> icon on the notebook sidebar, set a "Slug"
|
| 43 |
-
for the notebook, mark it as public and then drop its `.livemd` file into
|
| 44 |
-
the "public-apps" directory of your Spaces repo.
|
| 45 |
-
""")
|
| 46 |
-
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|