diff options
Diffstat (limited to '')
-rw-r--r-- | .zshrc | 4 | ||||
-rwxr-xr-x | bin/leb128 | 36 | ||||
-rwxr-xr-x | bin/scotch | 71 | ||||
-rwxr-xr-x | bin/virttop | 2 | ||||
-rw-r--r-- | docker/bitlbee-purple/conf/bitlbee.conf | 2 | ||||
-rw-r--r-- | docker/bitlbee-purple/docker-compose.yaml | 20 | ||||
-rwxr-xr-x | tmux/vcs_info.sh | 1 |
7 files changed, 78 insertions, 58 deletions
@@ -214,8 +214,8 @@ alias inputrc="vim ~/scripts/.inputrc" alias fixinputrc="cp ~/scripts/.inputrc ~/.inputrc" alias gdbinit="vim ~/scripts/.gdbinit" alias fixgdbinit="cp ~/scripts/.gdbinit ~/.gdbinit" -alias d="https_proxy=socks5://127.0.0.1:9995 grc docker" -alias dc="https_proxy=socks5://127.0.0.1:9995 grc docker-compose" +alias d="ALL_PROXY=socks5://127.0.0.1:9995 grc docker" +alias dc="ALL_PROXY=socks5://127.0.0.1:9995 grc docker-compose" alias zh_freebsd="zssh dev@192.168.90.15" alias zh_linux="zssh dev@192.168.90.17" alias zh_router_root="zssh root@192.168.90.71" @@ -1,16 +1,11 @@ -#!/bin/python3 +#!/usr/bin/env python3 +"""a leb128 decoder,encoder""" import argparse -import signal -import sys - - -def SigHandler_SIGINT(signum, frame): - print() - sys.exit(0) def devibytes(val): + """A custom arg handler, just to handle bytes in hex format""" ret = [] for byte in val.split(","): ret.append(int(byte, 16)) @@ -18,6 +13,7 @@ def devibytes(val): def LEB128UnsignedDecode(bytelist): + """LEB128 unsiged decoder""" result = 0 shift = 0 for byte in bytelist: @@ -29,6 +25,7 @@ def LEB128UnsignedDecode(bytelist): def LEB128SignedDecode(bytelist): + """LEB128 signed decoder""" result = 0 shift = 0 for byte in bytelist: @@ -43,9 +40,10 @@ def LEB128SignedDecode(bytelist): def LEB128UnsignedEncode(int_val): + """LEB128 signed encoder""" if int_val < 0: raise Exception("value must not be negative") - elif int_val == 0: + if int_val == 0: return bytes([0]) byte_array = bytearray() while int_val: @@ -57,6 +55,7 @@ def LEB128UnsignedEncode(int_val): def LEB128SignedEncode(int_val): + """LEB128 signed encoder""" byte_array = bytearray() while True: byte = int_val & 0x7F @@ -70,7 +69,10 @@ def LEB128SignedEncode(int_val): return byte_array -class Argparser(object): +# pylint: disable=too-few-public-methods +class Argparser: + """CLI args""" + def __init__(self): parser = argparse.ArgumentParser() parser.add_argument("--se", type=int, help="leb128 signed encode") @@ -88,11 +90,8 @@ class Argparser(object): self.args = parser.parse_args() -# write code here - - -def premain(): - signal.signal(signal.SIGINT, SigHandler_SIGINT) +def main(): + """entrypoint""" argparser = Argparser() # here if argparser.args.se: @@ -111,12 +110,5 @@ def premain(): print(LEB128UnsignedDecode(argparser.args.ud)) -def main(): - try: - premain() - except Exception as e: - print(e) - - if __name__ == "__main__": main() @@ -1,6 +1,8 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- +"""A strace wrapper with colors.""" +import enum import sys import subprocess @@ -478,7 +480,10 @@ syscall_set = set( ) -class Color: +# pylint: disable=too-few-public-methods +class Color(enum.EnumType): + """Color enumes""" + bold = "\033[1m" faint = "\033[2m" italic = "\033[3m" @@ -506,41 +511,57 @@ class Color: def call_from_shell_list(command_list): - if sys.version_info < (3, 7): - return subprocess.run(command_list, stdout=subprocess.PIPE) - else: - return subprocess.run(command_list, capture_output=True) + """run a shell command""" + # we explicitly dont want to check for a non-zero return code + # since we sometimes use strace to debuf failing applications + return subprocess.run(command_list, capture_output=True) def main(): + """entrypoint""" if len(sys.argv) < 2: print("you want to run something right?\nright?") sys.exit(1) args = sys.argv[1:] - args.insert(0, "strace") + args.insert(0, "/usr/bin/strace") result = call_from_shell_list(args) lines = result.stderr.decode("utf-8").split("\n") - end_line = lines[-2] - lines = lines[:-2] - for line in lines: - if line[0 : line.find("(")] in syscall_set: - syscall = line[0 : line.find("(")] - sysargs = line[line.find("(") + 1 : line.find(")")].split() - exitvalue = line[line.find(")") + 1 :] - print(Color.one + syscall, end=" ") - print(Color.two, end=" ") - sysargs = list(filter(None, sysargs)) - for arg in sysargs: - if arg.find("|") > 0: - print(Color.five, arg, end=" ") - else: - print(arg, end=" ") - print(Color.three + exitvalue + Color.reset) - else: - # leave regular stdout/stderr alone. we only want syscalls + if not sys.stdout.isatty(): + for line in lines: print(line) - print(Color.reset + Color.bold + Color.nine + end_line + Color.reset) + else: + end_line = lines[-2] + lines = lines[:-2] + for line in lines: + # this is here to support the -i option + if line[0] == "[": + idx = line.find("]") + if idx - 1 < 16: + print(Color.twelve + line[0 : idx + 1], end=" ") + line = line[idx + 2 :] + if line[0] == "[": + idx = line.find("]") + if idx - 1 == 16: + print(Color.thirteen + line[0 : idx + 1], end=" ") + line = line[idx + 2 :] + if line[0 : line.find("(")] in syscall_set: + syscall = line[0 : line.find("(")] + sysargs = line[line.find("(") + 1 : line.find(")")].split() + exitvalue = line[line.find(")") + 1 :] + print(Color.one + syscall, end=" ") + print(Color.two, end=" ") + sysargs = list(filter(None, sysargs)) + for arg in sysargs: + if arg.find("|") > 0: + print(Color.five, arg, end=" ") + else: + print(arg, end=" ") + print(Color.three + exitvalue + Color.reset) + else: + # leave regular stdout/stderr alone. we only want syscalls + print(line) + print(Color.reset + Color.bold + Color.nine + end_line + Color.reset) if __name__ == "__main__": diff --git a/bin/virttop b/bin/virttop index 34c93ba..64d53be 100755 --- a/bin/virttop +++ b/bin/virttop @@ -10,9 +10,9 @@ import csv import dataclasses import enum import sys - import typing from xml.dom.minidom import Document + from defusedxml import ElementTree # type:ignore from defusedxml import minidom import libvirt # type:ignore diff --git a/docker/bitlbee-purple/conf/bitlbee.conf b/docker/bitlbee-purple/conf/bitlbee.conf index 4a1540b..7d04efd 100644 --- a/docker/bitlbee-purple/conf/bitlbee.conf +++ b/docker/bitlbee-purple/conf/bitlbee.conf @@ -118,7 +118,7 @@ ConfigDir = /var/lib/bitlbee ## ## Proxy = http://john:doe@proxy.localnet.com:8080 ## Proxy = socks4://socksproxy.localnet.com -## Proxy = socks5://socksproxy.localnet.com +Proxy = socks5://192.168.1.214:9995 [defaults] diff --git a/docker/bitlbee-purple/docker-compose.yaml b/docker/bitlbee-purple/docker-compose.yaml index 6a9547e..193a14f 100644 --- a/docker/bitlbee-purple/docker-compose.yaml +++ b/docker/bitlbee-purple/docker-compose.yaml @@ -1,16 +1,22 @@ version: "3.7" services: bitlbee: - # image: ezkrg/bitlbee-libpurple - image: luzifer/bitlbee + image: bitlbee_devi networks: - bitlbeenet ports: - - "127.0.0.1:6667:6667" + - "8667:6667" restart: unless-stopped - # this is causing permission issues - # user: "bitlbee:bitlbee" - # volumes: - # - ./conf:/var/lib/bitlbee + network_mode: bridge + user: "bitlbee:bitlbee" + command: ["/usr/sbin/bitlbee", "-F","-n","-u","bitlbee","-c","/var/lib/bitlbee/bitlbee.conf", "-d","bitlbee-user-data"] + volumes: + - ./conf/bitlbee.conf:/var/lib/bitlbee/bitlbee.conf networks: bitlbeenet: + ipam: + driver: overlay + config: + - subnet: 172.18.0.0/16 + - ip_range: 172.18.5.0.24 + - gateway: 172.18.0.1 diff --git a/tmux/vcs_info.sh b/tmux/vcs_info.sh index 77773d6..ba8b6a8 100755 --- a/tmux/vcs_info.sh +++ b/tmux/vcs_info.sh @@ -23,6 +23,7 @@ tmux_path=$(get_tmux_cwd) # fi # done +cd "${tmux_path}" function gitadditions { if cd "${tmux_path}" && git rev-parse --git-dir >/dev/null 2>&1; then insertions=$(git --no-pager diff --numstat | awk '{sum1+=$1}END{print sum1}') |