This file contains hidden or 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
#!/bin/bash | |
# don't use this if all your need is a route that goes through your ISP router | |
# instead of an openvpn tunnel. OpenVPN has this as a built-in feature! | |
if [ "$EUID" -ne 0 ] | |
then echo "Please run as root" | |
exit 1 | |
fi |
This file contains hidden or 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
@app.get("/sse/stream") | |
async def stream(req: Request, channel: str = "default", redis: Redis = Depends(depends_redis)): | |
# return EventSourceResponse(subscribe(channel, redis)) | |
async def event_publisher(): | |
_log.info(f"Subscribing for client {req.client}") | |
(channel_subscription,) = await redis.subscribe(channel=Channel(channel, False)) | |
try: |
This file contains hidden or 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
from queue import Queue | |
from collections import defaultdict | |
class Publisher(object): | |
""" | |
Contains a list of subscribers that can can receive updates. | |
Each subscriber can have its own private data and may subscribe to | |
different channel. | |
""" |
This file contains hidden or 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
import asyncio | |
import uvicorn | |
from starlette.applications import Starlette | |
from starlette.requests import Request | |
from starlette.responses import HTMLResponse | |
from starlette.routing import Route | |
from sse_starlette.sse import EventSourceResponse, unpatch_uvicorn_signal_handler | |
# unpatch_uvicorn_signal_handler() # if you want to rollback monkeypatching of uvcorn signal-handler |
This file contains hidden or 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
#!/usr/bin/env python3 | |
import ipaddress | |
from SPF2IP import SPF2IP | |
ignore_list = set({'127.0.0.1/32'}) | |
ignore_list.update({ # Microsoft O365 | |
'40.92.0.0/15', |
This file contains hidden or 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
import logging | |
import ssl | |
import uuid | |
from urllib.parse import urlparse | |
from cryptography import x509 | |
from cryptography.hazmat.backends import default_backend | |
from django.db import models | |
from django.utils.functional import cached_property |
This file contains hidden or 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
#!/usr/bin/env bash | |
# parse-usb-devices.sh | |
# | |
# Parse the output of the "usb-devices" bash script and filter | |
# only for Mass Storage devices (Class 08). Include the active | |
# device speed (to see whether it is USB2 or USB3. | |
set -e |
This file contains hidden or 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
#!/bin/bash | |
# store values from environment | |
env_IP2TOR_SHOP_URL=${IP2TOR_SHOP_URL-notset} | |
env_IP2TOR_HOST_ID=${IP2TOR_HOST_ID-notset} | |
env_IP2TOR_HOST_TOKEN=${IP2TOR_HOST_TOKEN-notset} | |
# if config file exists use it (but vars set from environment overwrite file vars) | |
if [ -f /etc/ip2tor.conf ]; then | |
unset IP2TOR_SHOP_URL |
This file contains hidden or 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
def _send_request(self, path='/v1/getinfo') -> dict: | |
url = f'https://{self.hostname}:{self.port}{path}' | |
session = requests.Session() | |
try: | |
if self.tls_cert_verification: | |
adapter = CaDataVerifyingHTTPAdapter(tls_cert=self.tls_cert) | |
session.mount(url, adapter) | |
res = session.get(url, |
This file contains hidden or 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
#!/usr/bin/env bash | |
# | |
# tor2ipc.sh | |
# | |
# License: MIT | |
# Copyright (c) 2020 The RaspiBlitz developers | |
set -e | |
set -u |
NewerOlder