]> git.ipfire.org Git - ipfire.org.git/blob - src/templates/location/how-to-use.html
location: Fix links
[ipfire.org.git] / src / templates / location / how-to-use.html
1 {% extends "../base.html" %}
2
3 {% block title %}{{ _("How To Use") }}{% end block %}
4
5 {% block container %}
6 <section class="hero is-primary">
7 <div class="hero-body">
8 <div class="container">
9 <nav class="breadcrumb" aria-label="breadcrumbs">
10 <ul>
11 <li>
12 <a href="/">
13 {{ _("Home") }}
14 </a>
15 </li>
16 <li>
17 <a href="/location">
18 {{ _("Location") }}
19 </a>
20 </li>
21 <li class="is-active">
22 <a href="#" aria-current="page">{{ _("How to use?") }}</a>
23 </li>
24 </ul>
25 </nav>
26
27 <h1 class="title">{{ _("IPFire Location") }}</h1>
28 <h6 class="subtitle">
29 <code>libloc</code> is versatile, fast and easy to use
30 in any application.
31 </h6>
32 </div>
33 </div>
34 </section>
35
36 <section class="section">
37 <div class="container">
38 <div class="columns">
39 <div class="column">
40 <h2 class="title is-2">{{ _("Command Line") }}</h2>
41
42 <div class="content">
43 <p>
44 <code>libloc</code> comes with a command line tool which
45 makes it easy to test the library or integrate it into
46 your shell scripts.
47 <code>location(8)</code> knows a couple of commands
48 to retrieve country or Autonomous System of an IP address
49 and can generate lists of networks to be imported into
50 other software.
51 </p>
52
53 <p>
54 Although this is not the fastest way to lookup a large number
55 of IP addresses, <code>location(8)</code> is versatile
56 and very easy to use.
57 </p>
58
59 <a class="button is-light" href="https://man-pages.ipfire.org/libloc/location.html">
60 {{ _("Man Page") }}
61 </a>
62 </div>
63 </div>
64
65 <div class="column is-narrow">
66 <figure class="image is-256x256">
67 <img src="{{ static_url("img/bash-logo.svg") }}" alt="{{ _("CLI") }}">
68 </figure>
69 </div>
70 </div>
71
72 <div class="block">
73 <h6 class="title is-6">{{ _("Search for an Autonomous System by Name") }}</h6>
74
75 <pre><code>$ location search-as "Lightning Wire Labs"
76 AS204867 (Lightning Wire Labs GmbH)</code></pre>
77 </div>
78
79 <div class="block">
80 <h6 class="title is-6">{{ _("Lookup an IP Address") }}</h6>
81
82 <pre><code>$ location lookup 81.3.27.38
83 81.3.27.38 belongs to 81.3.27.0/24 which is a part of AS24679 (Hostway Deutschland GmbH)</code></pre>
84 </div>
85 </div>
86 </section>
87
88 <section class="section">
89 <div class="container">
90 <div class="columns">
91 <div class="column is-narrow">
92 <figure class="image is-256x256">
93 <img src="{{ static_url("img/python-logo.svg") }}"
94 alt="{{ _("Python") }}">
95 </figure>
96 </div>
97
98 <div class="column">
99 <h2 class="title is-2">{{ _("Python") }}</h2>
100
101 <div class="content">
102 <p>
103 <code>libloc</code> comes with native Python bindings which
104 are used by its main command-line tool
105 <a class="text-white" href="https://man-pages.ipfire.org/libloc/location.html">
106 <code>location</code>
107 </a>.
108 They are the most advanced bindings as they support reading
109 from the database as well as writing to it.
110 </p>
111 </div>
112 </div>
113 </div>
114
115 <div class="block">
116 <h6 class="title is-6">{{ _("Load the database") }}</h6>
117
118 <pre><code>Python 3.7.3 (default, Apr 3 2019, 05:39:12)
119 [GCC 8.3.0] on linux
120 Type "help", "copyright", "credits" or "license" for more information.
121 &gt;&gt;&gt; import location
122 &gt;&gt;&gt; d = location.Database("/usr/share/location/database.db")</code></pre>
123 </div>
124
125 <div class="block">
126 <h6 class="title is-6">{{ _("Search for an Autonomous System by Name") }}</h6>
127
128 <pre><code>&gt;&gt;&gt; for i in d.search_as("Lightning Wire Labs"):
129 ... &nbsp;&nbsp;print(i)
130 ...
131 AS204867 (Lightning Wire Labs GmbH)</code></pre>
132 </div>
133
134 <div class="block">
135 <h6 class="title is-6">{{ _("Lookup an IP Address") }}</h6>
136
137 <pre><code>&gt;&gt;&gt; n = d.lookup("81.3.27.38")
138 &gt;&gt;&gt; n
139 &lt;location.Network 81.3.27.0/24&gt;
140 &gt;&gt;&gt; n.asn
141 24679
142 &gt;&gt;&gt; n.country_code
143 'DE'</code></pre>
144 </div>
145 </div>
146 </section>
147 {% end block %}