Skip to content

Commit

Permalink
Fix IP address printing
Browse files Browse the repository at this point in the history
This commit will check if we have an ipv6 vs ipv4 and print out the
address formatted correctly. This includes handling ipv4 embedded ipv6
addresses.
  • Loading branch information
LaserEyess committed Jul 28, 2024
1 parent b8e3252 commit 656a44b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tarpyt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ from argparse import ArgumentParser, Namespace
import asyncio
import ctypes
import enum
import ipaddress as ip
import logging
from logging.handlers import SysLogHandler
import random
Expand Down Expand Up @@ -88,7 +89,11 @@ class Handler():
if host is None:
raise ValueError("what the fuck?")

hostname = host[0]
hostname = ip.ip_address(host[0])

# check if we got an embedded ipv4
if (hostname.version) == 6 and (addr := hostname.ipv4_mapped):
hostname = addr

try:
self.counter += 1
Expand Down

0 comments on commit 656a44b

Please sign in to comment.