def parseRequest(self, urlpart): self.customRules = self.request.get_all('c') self.customRules += (urlsafe_b64decode(r.encode('ascii')) for r in self.request.get_all('e')) match = self.userPacRegxp.match(unquote(urlpart).strip()) if match: setting = UserSetting.gql('WHERE pacName=:1', match.group(1).lower()).get() if setting is None: return urlpart = match.group(2) or setting.defaultProxy self.customRules += setting.customRules self.settingTime = setting.lastModified else: self.settingTime = datetime.min match = self.proxyRegxp.match(urlpart.lower()) if match is None: return self.proxyDict = match.groupdict() if self.proxyDict['name']: if self.proxyDict['name'] not in PRESET_PROXIES: return self.proxyString = PRESET_PROXIES[self.proxyDict['name']][1] elif self.proxyDict['type']: self.proxyDict['type'] = 'SOCKS' if self.proxyDict[ 'type'] == 'socks' else 'PROXY' self.proxyString = '%(type)s %(host)s:%(port)s' % self.proxyDict # Chrome expects 'SOCKS5' instead of 'SOCKS', see http://j.mp/pac-test if useragent.family() == 'Chrome': self.proxyString = self.proxyString.replace('SOCKS ', 'SOCKS5 ') return True
def parseRequest(self, urlpart): self.customRules = self.request.get_all('c') self.customRules += (urlsafe_b64decode(r.encode('ascii')) for r in self.request.get_all('e')) match = self.userPacRegxp.match(unquote(urlpart).strip()) if match: setting = UserSetting.gql('WHERE pacName=:1', match.group(1).lower()).get() if setting is None: return urlpart = match.group(2) or setting.defaultProxy self.customRules += setting.customRules self.settingTime = setting.lastModified else: self.settingTime = datetime.min match = self.proxyRegxp.match(urlpart.lower()) if match is None: return self.proxyDict = match.groupdict() if self.proxyDict['name']: if self.proxyDict['name'] not in PRESET_PROXIES: return self.proxyString = PRESET_PROXIES[self.proxyDict['name']][1] elif self.proxyDict['type']: self.proxyDict['type'] = 'SOCKS' if self.proxyDict['type'] == 'socks' else 'PROXY' self.proxyString = '%(type)s %(host)s:%(port)s' % self.proxyDict # Chrome expects 'SOCKS5' instead of 'SOCKS', see http://j.mp/pac-test if useragent.family() == 'Chrome': self.proxyString = self.proxyString.replace('SOCKS ', 'SOCKS5 ') return True
def get(self): self.lastModified(template.mtime('usage.html')) url = self.request.get('u') if url: url = 'http://%s/%s%s' % (self.request.host, PAC_URL_PREFIX, url) self.response.out.write(template.render('usage.html', url=url, browser=useragent.family(), ))
def get(self): self.lastModified(template.mtime('usage.html')) url = self.request.get('u') if url: url = 'http://%s/%s%s' % (self.request.host, PAC_URL_PREFIX, url) self.response.out.write( template.render( 'usage.html', url=url, browser=useragent.family(), ))
def parseProxyString(self, urlpart): if urlpart in PRESET_PROXIES: ps = PRESET_PROXIES[urlpart][1] else: match = self.urlPartRegxp.match(urlpart) if match is None: return None type, host, port = match.groups() type = 'SOCKS' if type == 'socks' else 'PROXY' ps = '%s %s:%s' % (type, host, port) # Chrome expects 'SOCKS5' instead of 'SOCKS', see http://j.mp/pac-test if useragent.family() == 'Chrome': ps = ps.replace('SOCKS', 'SOCKS5') return ps