function stringlengths 11 56k | repo_name stringlengths 5 60 | features list |
|---|---|---|
def get_long_running_output(pipeline_response):
if cls:
return cls(pipeline_response, None, {}) | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def get_long_running_output(pipeline_response):
deserialized = self._deserialize('PublicIPAddress', pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def list_all(
self,
**kwargs: Any | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def prepare_request(next_link=None):
# Construct headers
header_parameters = {} # type: Dict[str, Any]
header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
if not next_link:
# Construct URL
url = self.list_all.met... | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def list(
self,
resource_group_name: str,
**kwargs: Any | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def prepare_request(next_link=None):
# Construct headers
header_parameters = {} # type: Dict[str, Any]
header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
if not next_link:
# Construct URL
url = self.list.metadat... | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def list_virtual_machine_scale_set_public_ip_addresses(
self,
resource_group_name: str,
virtual_machine_scale_set_name: str,
**kwargs: Any | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def prepare_request(next_link=None):
# Construct headers
header_parameters = {} # type: Dict[str, Any]
header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
if not next_link:
# Construct URL
url = self.list_virtual... | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def list_virtual_machine_scale_set_vm_public_ip_addresses(
self,
resource_group_name: str,
virtual_machine_scale_set_name: str,
virtualmachine_index: str,
network_interface_name: str,
ip_configuration_name: str,
**kwargs: Any | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def prepare_request(next_link=None):
# Construct headers
header_parameters = {} # type: Dict[str, Any]
header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
if not next_link:
# Construct URL
url = self.list_virtual... | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def doWarnings():
import twisted
from twisted.python import versions
if (twisted.version < versions.Version('twisted', 8, 0, 0)):
LOG.warning("You should get Twisted 8 or later. Previous versions "
"have some bugs that affect Dtella.")
try:
import dtella.bridge
... | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def __init__(self, main):
self.main = main
self.nickmap = {} # {nick.lower() -> Node} | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def lookupNick(self, nick):
# Might raise KeyError
return self.nickmap[nick.lower()] | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def addNode(self, n):
if not n.nick:
return
lnick = n.nick.lower()
if lnick in self.nickmap:
raise NickError("collision")
so = self.main.getStateObserver()
if so:
# Might raise NickError
so.event_AddNick(n)
so.event_... | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def __init__(self, main):
self.main = main
self.remap_ip = None
self.choke_time = seconds() - self.CHOKE_PERIOD
self.choke_reported = seconds() - 999
# True iff we're shutting down after a socket failure.
self.stopping_protocol = False | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def getSocketState(self):
# Figure out the state of our UDP socket.
if self.stopping_protocol:
return 'dying'
elif not self.transport:
return 'dead'
elif hasattr(self.transport, "d"):
return 'dying'
else:
return 'alive' | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def datagramReceived(self, rawdata, addr, altport=False):
ad = Ad().setAddrTuple(addr)
if not ad.port:
return
# This will remap a router's internal IP to its external IP,
# if the remapping is known.
if self.remap_ip and ad.ip == self.remap_ip[0]:
ad.or... | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def decodeString1(self, data, factor=1):
try:
length, = struct.unpack('!B', data[:1])
except struct.error:
raise BadPacketError("Can't decode 1string")
length *= factor
if len(data) < 1+length:
raise BadPacketError("Bad 1string length")
retu... | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def decodeChunkList(self, fmt, data):
size = struct.calcsize(fmt)
try:
return [struct.unpack(fmt, data[i:i+size])
for i in range(0, len(data), size)]
except struct.error:
raise BadPacketError("Can't decode chunk list") | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def decodeNodeTimeList(self, data):
nbs, rest = self.decodeString1(data, 6+4)
nbs = [(ipp, age) for (ipp, age) in self.decodeChunkList('!6sI', nbs)
if Ad().setRawIPPort(ipp).auth('sx', self.main)]
return nbs, rest | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def handleBroadcast(self, ad, data, check_cb, bridgey=False):
(kind, nb_ipp, hop, flags, src_ipp, rest
) = self.decodePacket('!2s6sBB6s+', data)
osm = self.main.osm
if not osm:
raise BadTimingError("Not ready to route '%s' packet" % kind)
# Make sure nb_ipp agrees ... | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def sendAckPacket(self, ipp, mode, flags, ack_key):
packet = ['AK']
packet.append(self.main.osm.me.ipp)
packet.append(struct.pack("!BB", mode, flags))
packet.append(ack_key)
ad = Ad().setRawIPPort(ipp)
self.main.ph.sendPacket(''.join(packet), ad.getAddrTuple()) | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def isMyStatus(self, src_ipp, pktnum, sendfull):
# This makes corrections to any stray messages on the network that
# would have an adverse effect on my current state.
osm = self.main.osm
# If it's not for me, nothing's wrong.
if src_ipp != osm.me.ipp:
return False
... | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def handlePacket_IQ(self, ad, data):
# Initialization Request; someone else is trying to get online
(kind, myip, port
) = self.decodePacket('!2s4sH', data)
if port == 0:
raise BadPacketError("Zero Port")
# The IPPort which is allegedly mine
my_ad = Ad().set... | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def handlePacket_IR(self, ad, data):
# Initialization Response
(kind, src_ipp, myip, code, rest
) = self.decodePacket('!2s6s4sB+', data)
src_ad = Ad().setRawIPPort(src_ipp)
if ad.isPrivate():
if not src_ad.auth('sx', self.main):
raise BadPacketError(... | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def check_cb(src_n, src_ipp, rest):
(pktnum, expire, sesid, uptime, flags, rest
) = self.decodePacket('!IH4sIB+', rest)
nick, rest = self.decodeString1(rest)
info, rest = self.decodeString1(rest)
persist = bool(flags & PERSIST_BIT)
# 2011-08-2... | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def handlePacket_NH(self, ad, data):
# Broadcast: Node Status Hash (keep-alive)
osm = self.main.osm
def check_cb(src_n, src_ipp, rest):
(pktnum, expire, infohash
) = self.decodePacket('!IH4s', rest)
if not (5 <= expire <= 30*60):
raise Bad... | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def check_cb(src_n, src_ipp, rest):
(sesid,
) = self.decodePacket('!4s', rest)
if osm.syncd:
if src_ipp == osm.me.ipp and sesid == osm.me.sesid:
# Yikes! Make me a new session id and rebroadcast it.
osm.me.sesid = randbytes(4... | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def handlePacket_NF(self, ad, data):
# Broadcast: Node failure
osm = self.main.osm
def check_cb(src_n, src_ipp, rest):
(pktnum, sesid,
) = self.decodePacket('!I4s', rest)
# Make sure this isn't about me
if self.isMyStatus(src_ipp, pktnum, send... | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def handlePacket_CH(self, ad, data):
# Broadcast: Chat message
osm = self.main.osm
def check_cb(src_n, src_ipp, rest):
(pktnum, nhash, flags, rest
) = self.decodePacket('!I4sB+', rest)
text, rest = self.decodeString2(rest)
if rest:
... | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def check_cb(src_n, src_ipp, rest):
(pktnum, nhash, rest
) = self.decodePacket('!I4s+', rest)
topic, rest = self.decodeString1(rest)
if rest:
raise BadPacketError("Extra data")
if src_ipp == osm.me.ipp:
# Possibly a spoofed ... | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def handlePacket_SQ(self, ad, data):
# Broadcast: Search Request
osm = self.main.osm
def check_cb(src_n, src_ipp, rest):
(pktnum, rest
) = self.decodePacket("!I+", rest)
string, rest = self.decodeString1(rest)
if rest:
raise Ba... | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def handlePacket_CA(self, ad, data):
# Direct: ConnectToMe
def cb(dch, n, rest):
# SSLHACK: newer Dtella versions have an extra flags byte, to allow
# for SSL connection requests. Try to decode both forms.
try:
flags, port = self.decodePacke... | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def cb(dch, n, rest):
if rest:
raise BadPacketError("Extra data")
n.openRevConnectWindow()
dch.pushRevConnectToMe(n.nick) | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def handlePacket_PM(self, ad, data):
# Direct: Private Message
def cb(dch, n, rest):
flags, rest = self.decodePacket('!B+', rest)
text, rest = self.decodeString2(rest)
if rest:
raise BadPacketError("Extra data")
notice = bool(flags & N... | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def handlePacket_YQ(self, ad, data):
# Sync Request
(kind, nb_ipp, hop, flags, src_ipp, sesid
) = self.decodePacket('!2s6sBB6s4s', data)
osm = self.main.osm
if not (osm and osm.syncd):
raise BadTimingError("Not ready to handle a sync request")
# Hidden nod... | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def handlePacket_EC(self, ad, data):
# Login echo
osm = self.main.osm
if not osm:
raise BadTimingError("Not ready for login echo")
(kind, rand
) = self.decodePacket('!2s8s', data)
osm.receivedLoginEcho(ad, rand) | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def __init__(self, ipp, seen):
self.ipp = ipp
self.seen = seen
self.inheap = True
self.timeout_dcall = None
self.alt_reply = False
self.bad_code = False | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def start(self):
CHECK(self.deferred is None)
self.deferred = defer.Deferred()
self.main.showLoginStatus("Scanning For Online Nodes...", counter=1)
# Get the main UDP socket's bind interface (usually empty)
bind_ip = self.main.ph.transport.interface
# Listen on an arbi... | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def scheduleInitRequest(self):
if not self.deferred:
return
if self.initrequest_dcall:
return
def cb():
self.initrequest_dcall = None
try:
p = heapq.heappop(self.heap)
except IndexError:
self.checkStatu... | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def cb():
p.timeout_dcall = None
self.waitreply.remove(p)
if p.alt_reply:
self.recordResultType('dead_port')
self.checkStatus() | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def cancelPeerContactTimeout(self, p):
try:
self.waitreply.remove(p)
except KeyError:
return False
dcall_discard(p, 'timeout_dcall')
return True | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def recordResultType(self, kind):
self.main.logPacket("Recording result: '%s'" % kind)
self.counters[kind] += 1
# Finish init after 5 seconds of inactivity
if self.finish_dcall:
self.finish_dcall.reset(5.0)
return
def cb():
self.finish_dcal... | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def initCompleted(self, good):
self.shutdown()
if good:
self.deferred.callback(('good', self.node_ipps))
else:
# In a tie, prefer 'banned_ip' over 'foreign_ip', etc.
rank = []
i = 3
for name in ('banned_ip', 'foreign_ip', 'dead_port')... | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def shutdown(self):
# Cancel all dcalls
dcall_discard(self, 'initrequest_dcall')
dcall_discard(self, 'finish_dcall')
for p in self.peers.values():
dcall_discard(p, 'timeout_dcall')
# Close socket
if self.transport:
self.transport.stopListening() | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def __init__(self, ipp):
# Dtella Tracking stuff
self.ipp = ipp # 6-byte IP:Port
self.sesid = None # 4-byte session ID
self.dist = None # 16-byte md5 "distance"
self.expire_dcall = None # dcall for expiring stale nodes
self.status_pktnum = Non... | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def nickHash(self):
# Return a 4-byte hash to prevent a transient nick mismapping
if self.nick:
return md5(self.ipp + self.sesid + self.nick).digest()[:4]
else:
return None | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def getPMAckKey(self):
# Generate random packet ID for messages going TO this node
while 1:
ack_key = randbytes(8)
if ack_key not in self.msgkeys_out:
break
return ack_key | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def cb():
self.msgkeys_in.pop(ack_key) | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def setInfo(self, info):
old_dcinfo = self.dcinfo
self.dcinfo, self.location, self.shared = (
parse_incoming_info(SSLHACK_filter_flags(info)))
if self.sesid is None:
# Node is uninitialized
self.infohash = None
else:
self.infohash = md5(
... | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def openRevConnectWindow(self):
# When get a RevConnect, create a 5-second window during
# which errors are suppressed for outgoing connects.
if self.rcWindow_dcall:
self.rcWindow_dcall.reset(5.0)
return
def cb():
del self.rcWindow_dcall
sel... | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def sendPrivateMessage(self, ph, ack_key, packet, fail_cb):
# Send an ACK-able direct message to this node
def cb(tries):
if tries == 0:
del self.msgkeys_out[ack_key]
fail_cb("Timeout")
return
ad = Ad().setRawIPPort(self.ipp)
... | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def event_PrivateMessage(self, main, text, fail_cb):
osm = main.osm
if len(text) > 1024:
text = text[:1024-12] + ' [Truncated]'
flags = 0
ack_key = self.getPMAckKey()
packet = ['PM']
packet.append(osm.me.ipp)
packet.append(ack_key)
packet.... | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def event_RevConnectToMe(self, main, fail_cb):
osm = main.osm
ack_key = self.getPMAckKey()
packet = ['CP']
packet.append(osm.me.ipp)
packet.append(ack_key)
packet.append(osm.me.nickHash())
packet.append(self.nickHash())
packet = ''.join(packet)
... | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def shutdown(self, main):
dcall_discard(self, 'expire_dcall')
dcall_discard(self, 'rcWindow_dcall')
self.nickRemoved(main)
if self.bridge_data:
self.bridge_data.shutdown() | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def event_PrivateMessage(self, main, text, fail_cb):
dch = main.getOnlineDCH()
if dch:
dch.pushPrivMsg(dch.nick, text)
else:
fail_cb("I'm not online!") | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def event_RevConnectToMe(self, main, fail_cb):
fail_cb("can't get files from yourself!") | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def __init__(self, ipp):
self.ipp = ipp
self.timeout_dcall = None
self.fail_limit = 2
# Used for stats
self.in_total = False
self.in_done = False
self.proxy_request = False | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def updateStats(self, s, done, total):
# Update the sync statistics for a single node.
if done > 0 and not s.in_done:
s.in_done = True
self.stats_done += 1
elif done < 0 and s.in_done:
s.in_done = False
self.stats_done -= 1
if total > 0 an... | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def cb():
self.showProgress_dcall = None
if bar == self.stats_lastbar:
return
self.stats_lastbar = bar
progress = '>'*bar + '_'*(MAX-bar)
self.main.showLoginStatus(
"[%s] (%d/%d)" % (progress, done, total)) | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def advanceQueue(self):
# Raise request limit the first time it fills up
if self.request_limit < 5 and self.waitcount >= 5:
self.request_limit = 5
while self.waitcount < self.request_limit:
try:
# Grab an arbitrary (semi-pseudorandom) uncontacted node.
... | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def receivedSyncReply(self, src_ipp, c_nbs, u_nbs):
my_ipp = self.main.osm.me.ipp
# Loop through all the nodes that were just contacted by proxy
for ipp in c_nbs:
if ipp == my_ipp:
continue
try:
s = self.info[ipp]
except KeyEr... | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def cb():
s.timeout_dcall = None
self.waitcount -= 1
s.fail_limit -= 1
if s.fail_limit > 0:
# Try again later
self.uncontacted.add(s.ipp)
else:
self.updateStats(s, 0, -1)
self.showProgress()
... | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def cancelSyncTimeout(self, s):
if not s.timeout_dcall:
return
dcall_discard(s, 'timeout_dcall')
self.waitcount -= 1
self.advanceQueue() | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def __init__(self, main, my_ipp, node_ipps, bcm=None, bsm=None):
self.main = main
self.main.osm = self
self.syncd = False
# Don't allow myself in the nodes list
if node_ipps:
node_ipps.discard(my_ipp)
# Create a Node for me
self.me = MeNode(my_ipp)
... | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def refreshNodeStatus(self, src_ipp, pktnum, expire, sesid, uptime,
persist, nick, info):
CHECK(src_ipp != self.me.ipp)
try:
n = self.lookup_ipp[src_ipp]
in_nodes = True
except KeyError:
n = Node(src_ipp)
in_nodes = False
... | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def addNodeToNodesList(self, n):
if self.syncd:
n.calcDistance(self.me)
bisect.insort(self.nodes, n)
else:
self.nodes.append(n)
self.lookup_ipp[n.ipp] = n | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def reorderNodesList(self):
# Recalculate and sort all nodes in the nodes list.
for n in self.nodes:
n.calcDistance(self.me)
self.nodes.sort() | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def cb():
n.expire_dcall = None
self.nodeExited(n, "Node Timeout") | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def getStatus(self):
status = []
# My Session ID
status.append(self.me.sesid)
# My Uptime and Flags
status.append(struct.pack('!I', int(seconds() - self.me.uptime)))
status.append(self.me.flags())
# My Nick
status.append(struct.pack('!B', len(self.me.n... | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def sendMyStatus(self, sendfull=True):
# Immediately send my status, and keep sending updates over time.
# This should never be called for a bridge.
CHECK(not self.bsm)
# Skip this stuff for hidden nodes.
if self.main.hide_node:
return
self.checkStatusLimit... | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def cb():
self.statusLimit_dcall = None
self.main.showLoginStatus("*** YIKES! Too many status updates!")
self.main.shutdown(reconnect='max') | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def isModerated(self):
if self.bcm:
return self.bcm.isModerated()
if self.bsm:
return self.bsm.isModerated()
return False | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def cb():
self.loginEcho_dcall = None
self.loginEcho_rand = None
self.main.logPacket("No EC response") | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def receivedLoginEcho(self, ad, rand):
if rand != self.loginEcho_rand:
raise BadPacketError("EC Rand mismatch")
myad = Ad().setRawIPPort(self.me.ipp)
dcall_discard(self, 'loginEcho_dcall')
self.loginEcho_rand = None
if ad.ip == myad.ip:
return
... | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def shutdown(self):
# Cancel all the dcalls here
dcall_discard(self, 'sendStatus_dcall')
dcall_discard(self, 'statusLimit_dcall')
# If I'm still syncing, shutdown the SyncManager
if self.sm:
self.sm.shutdown()
# Shut down the MessageRoutingManager (and broa... | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def __init__(self, ipp):
self.ipp = ipp
self.outbound = False
self.inbound = False
self.ping_reqs = {} # {ack_key: time sent}
self.sendPing_dcall = None # dcall for sending pings
self.deadNb_dcall = None # keep track of node failu... | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def stronglyConnected(self):
# return True if both ends are willing to accept broadcast traffic
return (self.got_ack and self.u_got_ack) | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def __init__(self, main):
self.main = main
self.chopExcessLinks_dcall = None
self.makeNewLinks_dcall = None
# All of my ping neighbors: ipp -> PingNeighbor()
self.pnbs = {}
self.onlineTimeout_dcall = None
self.scheduleOnlineTimeout() | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def i_req():
if not (pn.outbound or pn.inbound):
# Don't request an ack for an unwanted connection
return False
if not pn.stillAlive():
# Try to revitalize this connection
return True
if (ping_now and
h... | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def pingWithRetransmit(self, pn, tries, later, ack_key=None):
dcall_discard(pn, 'sendPing_dcall')
pn.ping_reqs.clear()
def cb(tries):
pn.sendPing_dcall = None
# Send the ping
self.sendPing(pn, True)
# While tries is positive, use 1 second inter... | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def instaKillNeighbor(self, pn):
# Unconditionally drop neighbor connection (used for bans)
iwant = pn.outbound
pn.inbound = False
pn.outbound = False
self.cancelInactiveLink(pn)
if iwant:
self.scheduleMakeNewLinks() | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def cb():
pn.deadNb_dcall = None | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def scheduleMakeNewLinks(self):
# Call this whenever a new sync'd node is added
# Or when a connected link dies
# This never needs to run more than once per reactor loop
if self.makeNewLinks_dcall:
return
def cb():
self.makeNewLinks_dcall = None
... | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def cb():
self.chopExcessLinks_dcall = None
osm = self.main.osm
# Keep a set of unwanted outbound neighbors. We will remove
# wanted neighbors from this set, and kill what remains.
unwanted = set(pn.ipp for pn in self.pnbs.itervalues()
... | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def scheduleOnlineTimeout(self):
# This will automatically shut down the node if we don't get any
# ping acknowledgements for a while
if self.onlineTimeout_dcall:
self.onlineTimeout_dcall.reset(ONLINE_TIMEOUT)
return
def cb():
self.onlineTimeout_dcal... | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def sendPing(self, pn, i_req, ack_key=None):
# Transmit a single ping to the given node
osm = self.main.osm
# Expire old ack requests
if pn.ping_reqs:
now = seconds()
for req_key, when in pn.ping_reqs.items():
if now - when > 15.0:
... | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def __init__(self, data, tries, sendto, ph):
# Message expiration timer.
self.expire_dcall = None
# If no tries remain, don't try to send anything.
if not tries > 0:
return
# {neighbor ipp -> retry dcall}
self.sending = {}
... | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def cb(tries):
# Ack timeout/retransmit callback
send_data = data
# Decrease the hop count by the number of seconds the packet
# has been buffered.
buffered_time = int(seconds() - create_time)
if buffered_time > 0:
... | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def cancelSendToNeighbor(self, nb_ipp):
# This neighbor already has the message, so don't send it.
try:
self.sending.pop(nb_ipp).cancel()
except (AttributeError, KeyError):
return
self.cleanupIfDoneSending() | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def scheduleExpire(self, msgs, ack_key):
# Forget about this message, eventually.
if self.expire_dcall:
self.expire_dcall.reset(180.0)
return
def cb():
self.expire_dcall = None
self.cancelAllSends()
del ... | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def __init__(self, main):
self.main = main
self.msgs = {}
self.rcollide_last_NS = None
self.rcollide_ipps = set()
r = random.randint(0, 0xFFFFFFFF)
self.search_pktnum = r
self.chat_pktnum = r
self.main.osm.me.status_pktnum = r | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def pokeMessage(self, ack_key, nb_ipp):
# If we know about this message, then mark down that this neighbor
# has acknowledged it.
try:
m = self.msgs[ack_key]
except KeyError:
# Don't know about this message
return False
# Extend the expiratio... | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def receivedRejection(self, ack_key, ipp):
# Broadcast rejection, sent in response to a previous broadcast if
# another node doesn't recognize us on the network.
# We attach a status_pktnum to any broadcast which could possibly
# be rejected. If this matches my status_pktnum now, then ... | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def getPacketNumber_chat(self):
self.chat_pktnum = (self.chat_pktnum + 1) % 0x100000000
return self.chat_pktnum | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def broadcastHeader(self, kind, src_ipp, hops=32, flags=0):
# Build the header used for all broadcast packets
packet = [kind]
packet.append(self.main.osm.me.ipp)
packet.append(struct.pack('!BB', hops, flags))
packet.append(src_ipp)
return packet | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def __init__(self):
self.nbs = {} # {ipp: max hop count}
self.expire_dcall = None | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def cb():
del msgs[key] | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def __init__(self, main):
self.main = main
self.msgs = {} | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
def sendSyncReply(self, src_ipp, cont, uncont):
ad = Ad().setRawIPPort(src_ipp)
osm = self.main.osm
CHECK(osm and osm.syncd)
# Build Packet
packet = ['YR']
# My IP:Port
packet.append(osm.me.ipp)
# My last pktnum
packet.append(struct.pack('!I', ... | pmarks-net/dtella | [
5,
2,
5,
11,
1426380623
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.