class Mailgun(object): def __init__(self, domain, api_key): self._client = Transport(domain, api_key) def get(self, action, *args, **kwargs): """ HTTP GET method """ return self._client.process(action, "get", *args, **kwargs) def post(self, action, *args, **kwargs): """ HTTP POST method """ return self._client.process(action, "post", *args, **kwargs) def delete(self, action, *args, **kwargs): """ HTTP DELETE method """ return self._client.process(action, "delete", *args, **kwargs) def put(self, action, *args, **kwargs): """ HTTP PUT method """ return self._client.process(action, "put", *args, **kwargs)
class Client: def __init__(self, user): self.user = user self.ip = str(54) + '.' + str(random.randrange(0, 255)) + '.' + str(random.randrange(0, 255)) + '.' + str(random.randrange(0, 255)) self.connections = [] self.routerBuffer = [] self.inbox = {} self.transportLayer = Transport(self) self.applicationLayer = Application(self) # Adds a link between this client and another def addConnection(self, client): if client == self: return if client.ip in self.connections: return self.connections.append(client.ip) # Sends a message (tells the application layer to make a packet) def sendMessage(self, source, destination, message , time): applicationPacket = self.applicationLayer.generatePacket(time, source, destination, message) tcpPackets = self.transportLayer.process(applicationPacket, time) def __repr__(self): return self.ip def __str__(self): return self.ip + ' - ' + str(self.connections) + " => Router Buffer: " + str(self.routerBuffer) + " Inbox: " + str(self.inbox)