-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This resolves #103
- Loading branch information
Showing
4 changed files
with
45 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env python3 | ||
import queue | ||
import threading | ||
from wgkex.common import logger | ||
from wgkex.worker.netlink import link_handler | ||
from wgkex.worker.netlink import WireGuardClient | ||
|
||
q = queue.Queue() | ||
|
||
def watch_queue() -> None: | ||
"""Watches the queue for new messages.""" | ||
threading.Thread(target=worker, daemon=True).start() | ||
while q.empty() != True: | ||
pick_from_queue() | ||
|
||
def pick_from_queue() -> None: | ||
"""Picks a message from the queue and processes it.""" | ||
domain, message = q.get() | ||
logger.debug("Processing queue item %s for domain %s", message, domain) | ||
client = WireGuardClient( | ||
public_key=str(message.payload.decode("utf-8")), | ||
domain=domain, | ||
remove=False, | ||
) | ||
logger.debug(link_handler(client)) | ||
q.task_done() |