libknot 3.3.2__tar.gz → 3.3.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: libknot
3
- Version: 3.3.2
3
+ Version: 3.3.3
4
4
  Summary: Python bindings for libknot
5
- Project-URL: Documentation, https://www.knot-dns.cz/documentation
6
- Project-URL: Issues, https://gitlab.nic.cz/knot/knot-dns/-/issues
7
- Project-URL: Source, https://gitlab.nic.cz/knot/knot-dns/-/tree/master/python/libknot
8
- Author-email: "CZ.NIC, z.s.p.o." <knot-dns@labs.nic.cz>
5
+ Home-page: https://gitlab.nic.cz/knot/knot-dns/-/tree/master/python/libknot
6
+ Author: CZ.NIC, z.s.p.o.
7
+ Author-email: knot-dns@labs.nic.cz
9
8
  License: GPL-3.0
9
+ Platform: UNKNOWN
10
10
  Classifier: Development Status :: 5 - Production/Stable
11
11
  Classifier: Intended Audience :: Developers
12
12
  Classifier: Intended Audience :: System Administrators
@@ -108,6 +108,21 @@ finally:
108
108
  print(zone)
109
109
  ```
110
110
 
111
+ ```python3
112
+ # Print expirations as unixtime for all secondary zones
113
+ ctl.send_block(cmd="zone-status", flags="u")
114
+ resp = ctl.receive_block()
115
+ for zone in resp:
116
+ if resp[zone]["role"] == "master":
117
+ continue
118
+
119
+ expiration = resp[zone]["expiration"]
120
+ if expiration == "-":
121
+ print("Zone %s not loaded" % zone)
122
+ else:
123
+ print("Zone %s expires at %s" % (zone, resp[zone]["expiration"]))
124
+ ```
125
+
111
126
  ## Probe module
112
127
 
113
128
  Using this module it's possible to receive traffic data from a running daemon with
@@ -169,3 +184,5 @@ knot-dns.cz.: wire: b'\x08knot-dns\x02cz\x00' size: 13
169
184
  example.com.: wire: b'\x07example\x03com\x00' size: 13
170
185
  cz.: wire: b'\x02cz\x00' size: 4
171
186
  ```
187
+
188
+
@@ -88,6 +88,21 @@ finally:
88
88
  print(zone)
89
89
  ```
90
90
 
91
+ ```python3
92
+ # Print expirations as unixtime for all secondary zones
93
+ ctl.send_block(cmd="zone-status", flags="u")
94
+ resp = ctl.receive_block()
95
+ for zone in resp:
96
+ if resp[zone]["role"] == "master":
97
+ continue
98
+
99
+ expiration = resp[zone]["expiration"]
100
+ if expiration == "-":
101
+ print("Zone %s not loaded" % zone)
102
+ else:
103
+ print("Zone %s expires at %s" % (zone, resp[zone]["expiration"]))
104
+ ```
105
+
91
106
  ## Probe module
92
107
 
93
108
  Using this module it's possible to receive traffic data from a running daemon with
@@ -0,0 +1,188 @@
1
+ Metadata-Version: 2.1
2
+ Name: libknot
3
+ Version: 3.3.3
4
+ Summary: Python bindings for libknot
5
+ Home-page: https://gitlab.nic.cz/knot/knot-dns/-/tree/master/python/libknot
6
+ Author: CZ.NIC, z.s.p.o.
7
+ Author-email: knot-dns@labs.nic.cz
8
+ License: GPL-3.0
9
+ Platform: UNKNOWN
10
+ Classifier: Development Status :: 5 - Production/Stable
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Intended Audience :: System Administrators
13
+ Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Topic :: Internet :: Name Service (DNS)
16
+ Classifier: Topic :: Software Development :: Libraries
17
+ Classifier: Topic :: System :: Systems Administration
18
+ Requires-Python: >=3.5
19
+ Description-Content-Type: text/markdown
20
+
21
+ # Libknot API in Python
22
+
23
+ A Python interface for managing the Knot DNS daemon.
24
+
25
+ # Table of contents
26
+
27
+ * [Introduction](#introduction)
28
+ * [Control module](#control-module)
29
+ + [Usage](#using-the-control-module)
30
+ + [Example](#control-module-example)
31
+ * [Probe module](#probe-module)
32
+ + [Usage](#using-the-probe-module)
33
+ + [Example](#probe-module-example)
34
+ * [Dname module](#dname-module)
35
+ + [Usage](#using-the-dname-module)
36
+ + [Example](#dname-module-example)
37
+
38
+ ## Introduction
39
+
40
+ If the shared `libknot.so` library isn't available in the library search path, it's
41
+ necessary to load the library first, e.g.:
42
+
43
+ ```python3
44
+ import libknot
45
+ libknot.Knot("/usr/lib/libknot.so")
46
+ ```
47
+
48
+ ## Control module
49
+
50
+ Using this module it's possible to create scripts for efficient tasks that
51
+ would require complex shell scripts with multiple calls of `knotc`. For
52
+ communication with the daemon it uses the same mechanism as the `knotc` utility,
53
+ i.e. communication via a Unix socket.
54
+
55
+ The module API is stored in `libknot.control`.
56
+
57
+ ### Using the Control module
58
+
59
+ The module usage consists of several steps:
60
+
61
+ * Initialization and connection to the daemon control socket.
62
+ * One or more control operations. An operation is called by sending a command
63
+ with optional data to the daemon. The operation result has to be received
64
+ afterwards.
65
+ * Closing the connection and deinitialization.
66
+
67
+ ### Control module example
68
+
69
+ ```python3
70
+ import json
71
+ import libknot.control
72
+
73
+ # Initialization
74
+ ctl = libknot.control.KnotCtl()
75
+ ctl.connect("/var/run/knot/knot.sock")
76
+ ctl.set_timeout(60)
77
+
78
+ try:
79
+ # Operation without parameters
80
+ ctl.send_block(cmd="conf-begin")
81
+ resp = ctl.receive_block()
82
+
83
+ # Operation with parameters
84
+ ctl.send_block(cmd="conf-set", section="zone", item="domain", data="test")
85
+ resp = ctl.receive_block()
86
+
87
+ ctl.send_block(cmd="conf-commit")
88
+ resp = ctl.receive_block()
89
+
90
+ # Operation with a result displayed in JSON format
91
+ ctl.send_block(cmd="conf-read", section="zone", item="domain")
92
+ resp = ctl.receive_block()
93
+ print(json.dumps(resp, indent=4))
94
+ except libknot.control.KnotCtlError as exc:
95
+ # Print libknot error
96
+ print(exc)
97
+ finally:
98
+ # Deinitialization
99
+ ctl.send(libknot.control.KnotCtlType.END)
100
+ ctl.close()
101
+ ```
102
+
103
+ ```python3
104
+ # List configured zones (including catalog member ones)
105
+ ctl.send_block(cmd="conf-list", flags="z")
106
+ resp = ctl.receive_block()
107
+ for zone in resp['zone']:
108
+ print(zone)
109
+ ```
110
+
111
+ ```python3
112
+ # Print expirations as unixtime for all secondary zones
113
+ ctl.send_block(cmd="zone-status", flags="u")
114
+ resp = ctl.receive_block()
115
+ for zone in resp:
116
+ if resp[zone]["role"] == "master":
117
+ continue
118
+
119
+ expiration = resp[zone]["expiration"]
120
+ if expiration == "-":
121
+ print("Zone %s not loaded" % zone)
122
+ else:
123
+ print("Zone %s expires at %s" % (zone, resp[zone]["expiration"]))
124
+ ```
125
+
126
+ ## Probe module
127
+
128
+ Using this module it's possible to receive traffic data from a running daemon with
129
+ active probe module.
130
+
131
+ The module API is stored in `libknot.probe`.
132
+
133
+ ### Using the Probe module
134
+
135
+ The module usage consists of several steps:
136
+
137
+ * Initialization of one or more probe channels
138
+ * Periodical receiving of data units from the channels and data processing
139
+
140
+ ### Probe module example
141
+
142
+ ```python3
143
+ import libknot.probe
144
+
145
+ # Initialization of the first probe channel stored in `/run/knot`
146
+ probe = libknot.probe.KnotProbe("/run/knot", 1)
147
+
148
+ # Array for storing up to 8 data units
149
+ data = libknot.probe.KnotProbeDataArray(8)
150
+ while (True):
151
+ # Receiving data units with timeout of 1000 ms
152
+ if probe.consume(data, 1000) > 0:
153
+ # Printing received data units in the default format
154
+ for item in data:
155
+ print(item)
156
+ ```
157
+
158
+ ## Dname module
159
+
160
+ This module provides a few dname-related operations.
161
+
162
+ ### Using the Dname module
163
+
164
+ The dname object is initialized from a string with textual dname.
165
+ Then the dname can be reformatted to wire format or back to textual format.
166
+
167
+ ### Dname module example
168
+
169
+ ```python3
170
+ import libknot.dname
171
+
172
+ dname1 = libknot.dname.KnotDname("knot-dns.cz")
173
+ print("%s: wire: %s size: %u" % (dname1.str(), dname1.wire(), dname1.size()))
174
+
175
+ dname2 = libknot.dname.KnotDname("e\\120ample.c\om.")
176
+ print("%s: wire: %s size: %u" % (dname2.str(), dname2.wire(), dname2.size()))
177
+
178
+ dname3 = libknot.dname.KnotDname(dname_wire=b'\x02cz\x00')
179
+ print("%s: wire: %s size: %u" % (dname3.str(), dname3.wire(), dname3.size()))
180
+ ```
181
+
182
+ ```bash
183
+ knot-dns.cz.: wire: b'\x08knot-dns\x02cz\x00' size: 13
184
+ example.com.: wire: b'\x07example\x03com\x00' size: 13
185
+ cz.: wire: b'\x02cz\x00' size: 4
186
+ ```
187
+
188
+
@@ -0,0 +1,11 @@
1
+ README.md
2
+ pyproject.toml
3
+ setup.py
4
+ libknot/__init__.py
5
+ libknot/control.py
6
+ libknot/dname.py
7
+ libknot/probe.py
8
+ libknot.egg-info/PKG-INFO
9
+ libknot.egg-info/SOURCES.txt
10
+ libknot.egg-info/dependency_links.txt
11
+ libknot.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ libknot
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "libknot"
7
- version = "3.3.2"
7
+ version = "3.3.3"
8
8
  description = "Python bindings for libknot"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.5"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -7,7 +7,7 @@ if p.exists():
7
7
 
8
8
  setuptools.setup(
9
9
  name='libknot',
10
- version='3.3.2',
10
+ version='3.3.3',
11
11
  description='Python bindings for libknot',
12
12
  long_description=long_description,
13
13
  long_description_content_type="text/markdown",
libknot-3.3.2/.gitignore DELETED
@@ -1,6 +0,0 @@
1
- *.egg-info/
2
- dist/
3
- pyproject.toml
4
- setup.py
5
-
6
- /libknot/libknot/__init__.py
File without changes
File without changes
File without changes
File without changes