less buggy and faster way of converting IP address to signed int, also
means we don't need IPy.
This commit is contained in:
@@ -21,10 +21,10 @@ from tomograph import cache
|
|||||||
|
|
||||||
import base64
|
import base64
|
||||||
import StringIO
|
import StringIO
|
||||||
import IPy
|
|
||||||
import time
|
import time
|
||||||
import random
|
import random
|
||||||
import socket
|
import socket
|
||||||
|
import struct
|
||||||
import sys
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
import atexit
|
import atexit
|
||||||
@@ -67,9 +67,6 @@ def send(span):
|
|||||||
|
|
||||||
def ip_to_i32(ip_str):
|
def ip_to_i32(ip_str):
|
||||||
"""convert an ip address from a string to a signed 32-bit number"""
|
"""convert an ip address from a string to a signed 32-bit number"""
|
||||||
a = -0x80000000 + (IPy.IP(ip_str).int() & 0x7fffffff)
|
return struct.unpack('!i', socket.inet_aton(ip_str))[0]
|
||||||
if not -2147483648 <= a <= 2147483647:
|
|
||||||
print "ARGARG {0}".format(a)
|
|
||||||
return a
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
eventlet
|
eventlet
|
||||||
webob
|
webob
|
||||||
statsd
|
statsd
|
||||||
IPy
|
|
||||||
thrift
|
thrift
|
||||||
|
|||||||
Reference in New Issue
Block a user