Skip to content

Commit

Permalink
build(python): Make default config py3 compatible (#692)
Browse files Browse the repository at this point in the history
  • Loading branch information
BYK authored Oct 2, 2020
1 parent e333dbd commit acbaec6
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions sentry/sentry.conf.example.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,25 @@ def get_internal_network():
import socket
import struct

iface = "eth0"
iface = b"eth0"
sockfd = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
ifreq = struct.pack("16sH14s", iface, socket.AF_INET, b"\x00" * 14)
ifreq = struct.pack(b"16sH14s", iface, socket.AF_INET, b"\x00" * 14)

try:
ip = struct.unpack(
"!I", struct.unpack("16sH2x4s8x", fcntl.ioctl(sockfd, 0x8915, ifreq))[2]
b"!I", struct.unpack(b"16sH2x4s8x", fcntl.ioctl(sockfd, 0x8915, ifreq))[2]
)[0]
netmask = socket.ntohl(
struct.unpack("16sH2xI8x", fcntl.ioctl(sockfd, 0x891B, ifreq))[2]
struct.unpack(b"16sH2xI8x", fcntl.ioctl(sockfd, 0x891B, ifreq))[2]
)
except IOError:
return ()
base = socket.inet_ntoa(struct.pack("!I", ip & netmask))
base = socket.inet_ntoa(struct.pack(b"!I", ip & netmask))
netmask_bits = 32 - int(round(math.log(ctypes.c_uint32(~netmask).value + 1, 2), 1))
return ("{0:s}/{1:d}".format(base, netmask_bits),)
return "{0:s}/{1:d}".format(base, netmask_bits)


INTERNAL_SYSTEM_IPS = get_internal_network()
INTERNAL_SYSTEM_IPS = (get_internal_network(),)


DATABASES = {
Expand Down

0 comments on commit acbaec6

Please sign in to comment.