Ejemplo n.º 1
0
 def do_CONNECT(self):
     print('===== do_CONNECT =====')
     warp_path = warp_url('https://' + self.path)
     gpy.var_dump(warp_path)
     soc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     gpy.var_dump((socket.AF_INET, socket.SOCK_STREAM))
     gpy.var_dump((self.path, soc))
     gpy.var_dump((warp_path.urn, soc))
     if warp_path.urn != self.path:
         print
         printLog(self.server.logger,
                  '-----------------------------------------')
         #print(self.path)
         printLog(self.server.logger, self.path)
         print('----------')
         #print(warp_path)
         printLog(self.server.logger, warp_path.urn)
         print('-----------------------------------------')
         print
     try:
         if self._connect_to(warp_path.urn, soc):
             self.log_request(200)
             self.wfile.write(self.protocol_version +
                              " 200 Connection established\r\n")
             self.wfile.write("Proxy-agent: %s\r\n" % self.version_string())
             self.wfile.write("\r\n")
             self._read_write(soc, 300)
     finally:
         soc.close()
         self.connection.close()
Ejemplo n.º 2
0
	def do_CONNECT(self):
		print('===== do_CONNECT =====')
		warp_path = warp_url('https://'+self.path)
		gpy.var_dump(warp_path)
		soc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
		gpy.var_dump((socket.AF_INET, socket.SOCK_STREAM))
		gpy.var_dump((self.path, soc))
		gpy.var_dump((warp_path.urn, soc))
		if warp_path.urn != self.path:
			print 
			printLog(self.server.logger, '-----------------------------------------')
			#print(self.path)
			printLog(self.server.logger, self.path)
			print('----------')
			#print(warp_path)
			printLog(self.server.logger, warp_path.urn)
			print('-----------------------------------------')
			print 
		try:
			if self._connect_to(warp_path.urn, soc):
				self.log_request(200)
				self.wfile.write(self.protocol_version +
								 " 200 Connection established\r\n")
				self.wfile.write("Proxy-agent: %s\r\n" % self.version_string())
				self.wfile.write("\r\n")
				self._read_write(soc, 300)
		finally:
			soc.close()
			self.connection.close()
Ejemplo n.º 3
0
def warp_url(sUrl):
    #print('warp_url proxy_ini')urn
    oUrl = Url(sUrl)
    sUrl = oUrl.urn

    print('def warp_url')
    for tUrl in proxy_ini:
        #if tUrl[0][0:1] == '^':
        #sReSrcUrl = '^http://' + tUrl[0][1:]
        #else:
        #sReSrcUrl = 'http://' + tUrl[0]
        #pdb.set_trace()
        if tUrl[3]:
            if not re.compile('^.+:\d').match(tUrl[0]):
                tUrl[0] = tUrl[0] + ':443'
        rUrl = re.compile(tUrl[0] + '$')
        #pdb.set_trace()
        gpy.var_dump((tUrl[0], sUrl))
        gpy.var_dump(rUrl.match(sUrl))

        if rUrl.match(sUrl):
            oUrl.isLocalFile = tUrl[2]
            oUrl.isHttps = tUrl[3]
            oUrl.host = tUrl[4]
            if tUrl[2]:
                sCDir = os.getcwd()
                #print(sCDir)
                sUrl = sCDir + '/devproxy_temp_file' + tUrl[1]
                oUrl.protocol = 'file://'
                if sUrl.find('\\') > -1:
                    sUrl = sUrl.replace('/', '\\')
            else:
                sReUrl = tUrl[1].replace('$', '\\')
                #pdb.set_trace()
                print('rUrl.sub')
                gpy.var_dump(rUrl.pattern)
                gpy.var_dump((sReUrl, sUrl))
                sUrl = rUrl.sub(sReUrl, sUrl)
            oUrl.urn = sUrl
            break
    #return sUrl
    #print('%%%%%')
    #gpy.var_dump(proxy_ini)
    #print('%%%%%')
    if not oUrl:
        oUrl = Url(sUrl)
    #pdb.set_trace()
    #print(sUrl)
    return oUrl
Ejemplo n.º 4
0
def warp_url(sUrl):
	#print('warp_url proxy_ini')urn
	oUrl = Url(sUrl)
	sUrl = oUrl.urn

	print('def warp_url')
	for tUrl in proxy_ini:
		#if tUrl[0][0:1] == '^':
			#sReSrcUrl = '^http://' + tUrl[0][1:]
		#else:
			#sReSrcUrl = 'http://' + tUrl[0]
		#pdb.set_trace()
		if tUrl[3]:
			if not re.compile('^.+:\d').match(tUrl[0]):
				tUrl[0] = tUrl[0] + ':443'
		rUrl = re.compile(tUrl[0] + '$')
		#pdb.set_trace()
		gpy.var_dump((tUrl[0], sUrl))
		gpy.var_dump(rUrl.match(sUrl))

		if rUrl.match(sUrl):
			oUrl.isLocalFile = tUrl[2]
			oUrl.isHttps = tUrl[3]
			oUrl.host = tUrl[4]
			if tUrl[2]:
				sCDir = os.getcwd()
				#print(sCDir)
				sUrl = sCDir + '/devproxy_temp_file' + tUrl[1]
				oUrl.protocol = 'file://'
				if sUrl.find('\\') > -1:
					sUrl = sUrl.replace('/', '\\')
			else:
				sReUrl = tUrl[1].replace('$', '\\')
				#pdb.set_trace()
				print('rUrl.sub')
				gpy.var_dump(rUrl.pattern)
				gpy.var_dump((sReUrl,sUrl))
				sUrl = rUrl.sub(sReUrl,sUrl)
			oUrl.urn = sUrl
			break
	#return sUrl
	#print('%%%%%')
	#gpy.var_dump(proxy_ini)
	#print('%%%%%')
	if not oUrl:
		oUrl = Url(sUrl)
	#pdb.set_trace()
	#print(sUrl)
	return oUrl
Ejemplo n.º 5
0
    logfile = None
    daemon = False
    max_log_size = 20
    port = 8000
    allowed = []
    run_event = threading.Event()
    local_hostname = socket.gethostname()

    try:
        opts, args = getopt.getopt(sys.argv[1:], "l:dhp:i:j:os", [])
    except getopt.GetoptError, e:
        usage(str(e))
        return 1

    gpy.var_dump(sys.argv)

    #gpy.var_dump(opts)

    sExIniPath = ''
    bOldVerIni = False
    bLog = False
    #gpy.var_dump(opts);
    for opt, value in opts:
        if opt == "-p": port = int(value)
        if opt == "-l":
            logfile = value
            bLog = True
        if opt == "-i": sExIniPath = value
        if opt == "-d": daemon = not daemon
        if opt == "-h":
Ejemplo n.º 6
0
	global proxy_ini, sIniPath, bOldVerIni, bLog

	logfile = None
	daemon  = False
	max_log_size = 20
	port = 8000
	allowed = []
	run_event = threading.Event ()
	local_hostname = socket.gethostname ()

	try: opts, args = getopt.getopt (sys.argv[1:], "l:dhp:i:j:os", [])
	except getopt.GetoptError, e:
		usage (str (e))
		return 1

	gpy.var_dump(sys.argv)

	#gpy.var_dump(opts)

	sExIniPath = ''
	bOldVerIni = False
	bLog = False
	#gpy.var_dump(opts);
	for opt, value in opts:
		if opt == "-p": port = int (value)
		if opt == "-l":
			logfile = value
			bLog = True
		if opt == "-i": sExIniPath = value
		if opt == "-d": daemon = not daemon
		if opt == "-h":