Giter Club home page Giter Club logo

Comments (3)

strangeh21 avatar strangeh21 commented on June 18, 2024

Add verbose :)
pproxy -r socks5://{proxy['host']}:{proxy['port']}#{proxy['username']}:{proxy['password']} -l socks5://:{server_port} -vv

This prints out the current usage to stdout.
What I did is sent stdout to a class, and parsed the data.
Search for data_usage as such:

	class OutputHandler:
		def __init__(self):
			pass

		def write(self, message):
			self.parse_and_handle_output(message.strip())

		def flush(self):
			pass

		def print_to_output(self, message):
			print(message, file=sys.__stdout__)

		def parse_and_handle_output(self, output):
			websites = re.findall(r'->\s(?:.*)->\s(.*):\d+', output)
			data_usage = re.search(
				"DIRECT: \d+ \(([\d.]+[KM])/s,([\d.]+[KM])/s\)   PROXY: \d+ \(([\d.]+[KM])/s,([\d.]+[KM])/s\)",
				output)
			if websites:  # Parse the websites
				for website in websites:
					self.print_to_output(f"URL: {website}")
			elif data_usage and data_usage != "":  # Parse the data usage
				try:
					direct, direct2, proxy, proxy2 = data_usage.groups()
					direct_combined = self.to_megabytes(direct) + self.to_megabytes(direct2)
					proxy_combined = self.to_megabytes(proxy) + self.to_megabytes(proxy2)
					combined = float(direct_combined + proxy_combined)
					self.print_to_output(round(combined, 4))
			else:
				if output and output != "":
					self.print_to_output(output)

		@staticmethod
		def to_megabytes(value):
			if value[-1] == 'M':
				return float(value[:-1])
			elif value[-1] == 'K':
				return float(value[:-1]) / 1024
			else:
				return 0
sys.stdout = self.OutputHandler()

from python-proxy.

maxiedaniels avatar maxiedaniels commented on June 18, 2024

@strangeh21 Sorry, can you explain further? Are you running python proxy within a Python script? I'm running via command-line so I'm unclear on how I would adjust your solution.

from python-proxy.

strangeh21 avatar strangeh21 commented on June 18, 2024

@strangeh21 Sorry, can you explain further? Are you running python proxy within a Python script? I'm running via command-line so I'm unclear on how I would adjust your solution.

In short, verbose level 2 within commandline adds traffic logging. This is done by adding "-vv" When it is running you can press enter at any time to get a complete list of data usage.

from python-proxy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.