示例#1
0
    def get(self):
        if lindenip.inrange(os.environ['REMOTE_ADDR']) != 'Production':
            self.error(403)
        elif self.request.headers['X-SecondLife-Shard'] != 'Production':
            logging.warning("Attempt while on beta grid %s" %
                            (self.request.headers['X-SecondLife-Shard']))
            self.response.set_status(305)
        else:
            self.response.headers['Content-Type'] = 'text/plain'
            #look for an item with the requested name
            name = cgi.escape(self.request.get('object'))
            version = cgi.escape(self.request.get('version'))
            update = cgi.escape(self.request.get('update'))

            #logging.info('%s checked %s version %s' % (self.request.headers['X-SecondLife-Owner-Name'], name, version))

            item = tools.get_item(name, True)
            if item is None:
                self.response.out.write("NSO %s" % (name))
                return
            if item['baseprice'] > 0:
                self.response.out.write("NSO %s" % (name))
                logging.error(
                    'Rejecting request: Regquesting a paid item using the update check url by %s, vendor %s located in %s at %s. Item:%s'
                    % (self.request.headers['X-SecondLife-Owner-Name'],
                       self.request.headers['X-SecondLife-Object-Name'],
                       self.request.headers['X-SecondLife-Region'],
                       self.request.headers['X-SecondLife-Local-Position'],
                       name))
                return
            logging.debug('baseprice:%s' % item['baseprice'])
            thisversion = 0.0
            try:
                thisversion = float(version)
            except ValueError:
                avname = self.request.headers['X-SecondLife-Owner-Name']
                logging.error(
                    '%s is using %s with bad version "%s" and will be sent an update'
                    % (avname, name, version))

            if thisversion < float(item['version']):
                #get recipient key from http headers or request
                rcpt = self.request.headers['X-SecondLife-Owner-Key']

                #enqueue delivery, if queue does not already contain this delivery
                name_version = "%s - %s" % (name, item['version'])
                if update != "no":
                    if tools.enqueue_delivery(item['giver'], rcpt,
                                              name_version,
                                              self.request.host_url) == False:
                        self.error(403)
                #queue = FreebieDelivery.gql("WHERE rcptkey = :1 AND itemname = :2", rcpt, name_version)
                #if queue.count() == 0:
                #    delivery = FreebieDelivery(giverkey = item.freebie_giver, rcptkey = rcpt, itemname = name_version)
                #    delivery.put()
                #in the future return null key instead of giver's key
                self.response.out.write("%s|%s - %s" %
                                        (null_key, name, item['version']))
            else:
                self.response.out.write('current')
示例#2
0
    def post(self):
        #check linden IP  and allowed avs
        if lindenip.inrange(os.environ['REMOTE_ADDR']) != 'Production':
            self.error(403)
        elif self.request.headers['X-SecondLife-Shard'] != 'Production':
            logging.warning("Attempt while on beta grid %s" % (self.request.headers['X-SecondLife-Shard']))
            self.response.set_status(305)
        elif not distributors.Distributor_authorized(self.request.headers['X-SecondLife-Owner-Key']):
            logging.info("Illegal attempt to request an item from %s, box %s located in %s at %s" % (self.request.headers['X-SecondLife-Owner-Name'], self.request.headers['X-SecondLife-Object-Name'], self.request.headers['X-SecondLife-Region'], self.request.headers['X-SecondLife-Local-Position']))
            self.error(403)
        else:
            #populate a dictionary with what we've been given in post
            #should be newline-delimited, token=value
            lines = self.request.body.split('\n')
            params = {}
            for line in lines:
                params[line.split('=')[0]] = line.split('=')[1]

            try:
                name = params['objname']
                item = tools.get_item(name, True)
                if item is None:
                    #could not find item to look up its deliverer.  return an error
                    logging.error('Error, freebie %s not found. Requested by %s using %s.' % (name, self.request.headers['X-SecondLife-Owner-Name'], self.request.headers['X-SecondLife-Object-Name']))
                    self.error(403)
                    return
                # Support new 3.7x collars that have no version in the name.
                if item['version'] == 'NOVERSION':
                    name_version = name
                else:
                    name_version = "%s - %s" % (name, item['version'])
                rcpt = str(params['rcpt'])
                if item['baseprice'] > 0:
                    self.response.out.write("NSO %s" % (name))
                    logging.error('Rejecting request: Regquesting a paid item using the free url by %s, vendor %s located in %s at %s. Item:%s Rcpt:%s' % 
                              (self.request.headers['X-SecondLife-Owner-Name'],
                               self.request.headers['X-SecondLife-Object-Name'],
                               self.request.headers['X-SecondLife-Region'],
                               self.request.headers['X-SecondLife-Local-Position'],
                               name,
                               rcpt
                               ))
                    return
                
                if tools.enqueue_delivery(item['giver'], rcpt, name_version, self.request.host_url):
                    self.response.out.write('%s|%s' % (rcpt, name_version))
                    count_token = 'item_count_%s' % name
                    memcache.incr(count_token, initial_value=0)
                else:
                    logging.error('Enqueing failed for vendor %s, queue entry: %s|%s' % (item['giver'], rcpt, name_version))
                    self.error(403)
            except KeyError:
                logging.error('Key error for vendor %s, queue entry: %s|%s' % (item['giver'], rcpt, name_version))
                self.error(403)
示例#3
0
    def get(self):
        if lindenip.inrange(os.environ['REMOTE_ADDR']) != 'Production':
            self.error(403)
        elif self.request.headers['X-SecondLife-Shard'] != 'Production':
            logging.warning("Attempt while on beta grid %s" % (self.request.headers['X-SecondLife-Shard']))
            self.response.set_status(305)
        else:
            self.response.headers['Content-Type'] = 'text/plain'
            #look for an item with the requested name
            name = cgi.escape(self.request.get('object'))
            version = cgi.escape(self.request.get('version'))
            update = cgi.escape(self.request.get('update'))

            #logging.info('%s checked %s version %s' % (self.request.headers['X-SecondLife-Owner-Name'], name, version))

            item = tools.get_item(name, True)
            if item is None:
                self.response.out.write("NSO %s" % (name))
                return
            if item['baseprice'] > 0:
                    self.response.out.write("NSO %s" % (name))
                    logging.error('Rejecting request: Regquesting a paid item using the update check url by %s, vendor %s located in %s at %s. Item:%s' % 
                              (self.request.headers['X-SecondLife-Owner-Name'],
                               self.request.headers['X-SecondLife-Object-Name'],
                               self.request.headers['X-SecondLife-Region'],
                               self.request.headers['X-SecondLife-Local-Position'],
                               name
                               ))
                    return
            logging.debug('baseprice:%s' % item['baseprice'])
            thisversion = 0.0
            try:
                thisversion = float(version)
            except ValueError:
                avname = self.request.headers['X-SecondLife-Owner-Name']
                logging.error('%s is using %s with bad version "%s" and will be sent an update' % (avname, name, version))

            if thisversion < float(item['version']):
                #get recipient key from http headers or request
                rcpt = self.request.headers['X-SecondLife-Owner-Key']

                #enqueue delivery, if queue does not already contain this delivery
                name_version = "%s - %s" % (name, item['version'])
                if update != "no":
                    if tools.enqueue_delivery(item['giver'], rcpt, name_version, self.request.host_url)==False:
                        self.error(403)
                #queue = FreebieDelivery.gql("WHERE rcptkey = :1 AND itemname = :2", rcpt, name_version)
                #if queue.count() == 0:
                #    delivery = FreebieDelivery(giverkey = item.freebie_giver, rcptkey = rcpt, itemname = name_version)
                #    delivery.put()
                #in the future return null key instead of giver's key
                self.response.out.write("%s|%s - %s" % (null_key, name, item['version']))
            else:
                self.response.out.write('current')