Comments (3)
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.
@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 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)
- Empty reply from proxy server - even when remote target port is closed HOT 1
- Question about iptables
- Backward Proxy GET => Empty reply from server
- Dynamically set a username and password for the remote proxy
- How to print all request headers
- Possibility of redirecting traffic to warp?
- how to set systme proxy in python code,like 'dict(rserver=[remote])' ?
- Rules seem to be ignored with 'direct' HOT 3
- 有没有办法拦截特定的路径并返回特定的响应 HOT 1
- ProxyBackward' object has no attribute 'sockets
- feature request, proxy bypass
- HTTPS request
- rules file not work. HOT 1
- How to support multiple usernames and passwords
- Protocol table
- python-proxy如何获取用户来源IP? How to get user source ip? HOT 1
- Configuring a Python Proxy on One Computer to Allow Another to Access the Internet
- 连接被重置
- Proxy CONNECT aborted
- Support _ in the username
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-proxy.