]>
Commit | Line | Data |
---|---|---|
55eea098 MT |
1 | {% extends "../base.html" %} |
2 | ||
b73e143d | 3 | {% block title %}{{ _("How To Use?") }}{% end block %} |
55eea098 MT |
4 | |
5 | {% block container %} | |
07992979 MT |
6 | <section class="hero is-primary"> |
7 | <div class="hero-body"> | |
8 | <div class="container"> | |
ed83981e | 9 | <nav class="breadcrumb" aria-label="breadcrumbs"> |
07992979 MT |
10 | <ul> |
11 | <li> | |
12 | <a href="/"> | |
13 | {{ _("Home") }} | |
14 | </a> | |
15 | </li> | |
16 | <li> | |
1c87d674 | 17 | <a href="/location"> |
07992979 MT |
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 | ||
ed83981e MT |
27 | <h1 class="title">{{ _("IPFire Location") }}</h1> |
28 | <h6 class="subtitle"> | |
07992979 MT |
29 | <code>libloc</code> is versatile, fast and easy to use |
30 | in any application. | |
31 | </h6> | |
55eea098 MT |
32 | </div> |
33 | </div> | |
34 | </section> | |
35 | ||
07992979 | 36 | <section class="section"> |
55eea098 | 37 | <div class="container"> |
07992979 MT |
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> | |
55eea098 MT |
63 | </div> |
64 | ||
07992979 MT |
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> | |
55eea098 MT |
69 | </div> |
70 | </div> | |
71 | ||
07992979 MT |
72 | <div class="block"> |
73 | <h6 class="title is-6">{{ _("Search for an Autonomous System by Name") }}</h6> | |
55eea098 | 74 | |
07992979 | 75 | <pre><code>$ location search-as "Lightning Wire Labs" |
55eea098 | 76 | AS204867 (Lightning Wire Labs GmbH)</code></pre> |
07992979 | 77 | </div> |
55eea098 | 78 | |
07992979 MT |
79 | <div class="block"> |
80 | <h6 class="title is-6">{{ _("Lookup an IP Address") }}</h6> | |
55eea098 | 81 | |
07992979 | 82 | <pre><code>$ location lookup 81.3.27.38 |
55eea098 | 83 | 81.3.27.38 belongs to 81.3.27.0/24 which is a part of AS24679 (Hostway Deutschland GmbH)</code></pre> |
55eea098 MT |
84 | </div> |
85 | </div> | |
86 | </section> | |
87 | ||
07992979 | 88 | <section class="section"> |
55eea098 | 89 | <div class="container"> |
07992979 MT |
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> | |
55eea098 MT |
96 | </div> |
97 | ||
07992979 MT |
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> | |
55eea098 MT |
112 | </div> |
113 | </div> | |
114 | ||
07992979 MT |
115 | <div class="block"> |
116 | <h6 class="title is-6">{{ _("Load the database") }}</h6> | |
55eea098 | 117 | |
07992979 | 118 | <pre><code>Python 3.7.3 (default, Apr 3 2019, 05:39:12) |
55eea098 MT |
119 | [GCC 8.3.0] on linux |
120 | Type "help", "copyright", "credits" or "license" for more information. | |
121 | >>> import location | |
122 | >>> d = location.Database("/usr/share/location/database.db")</code></pre> | |
07992979 | 123 | </div> |
55eea098 | 124 | |
07992979 MT |
125 | <div class="block"> |
126 | <h6 class="title is-6">{{ _("Search for an Autonomous System by Name") }}</h6> | |
55eea098 | 127 | |
07992979 | 128 | <pre><code>>>> for i in d.search_as("Lightning Wire Labs"): |
4a0c3934 | 129 | ... print(i) |
55eea098 MT |
130 | ... |
131 | AS204867 (Lightning Wire Labs GmbH)</code></pre> | |
07992979 | 132 | </div> |
55eea098 | 133 | |
07992979 MT |
134 | <div class="block"> |
135 | <h6 class="title is-6">{{ _("Lookup an IP Address") }}</h6> | |
55eea098 | 136 | |
07992979 | 137 | <pre><code>>>> n = d.lookup("81.3.27.38") |
55eea098 MT |
138 | >>> n |
139 | <location.Network 81.3.27.0/24> | |
140 | >>> n.asn | |
141 | 24679 | |
142 | >>> n.country_code | |
143 | 'DE'</code></pre> | |
55eea098 MT |
144 | </div> |
145 | </div> | |
146 | </section> | |
147 | {% end block %} |