- 
                Notifications
    
You must be signed in to change notification settings  - Fork 226
 
Some Improvements (Outlined Below) #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| 
           dear nvv1d  | 
    
| 
           6 month ago i extensively optimized this code to work in low-ram-vps  | 
    
| 
           Asyncio brings efficient resource usage and better code safety.  | 
    
| 
           @byehack yes we finally need to add into xray-core  | 
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just correct a mistake
| from logging.handlers import TimedRotatingFileHandler | ||
| 
               | 
          ||
| import configparser | ||
| import random | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import itertools
| global listen_PORT, Cloudflare_IPs, Cloudflare_port, L_fragment, fragment_sleep, my_socket_timeout, first_time_sleep, accept_time_sleep | ||
| listen_PORT = int(config.get('settings', 'listen_PORT')) | ||
| Cloudflare_IPs = [ip.strip() for ip in config.get('settings', 'Cloudflare_IP').split(',')] | ||
| Cloudflare_port = int(config.get('settings', 'Cloudflare_port')) | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cloudflare_IPs = itertools.cycle(Cloudflare_IPs)
| global Cloudflare_IPs | ||
| selected_ip = random.choice(Cloudflare_IPs) | ||
| Cloudflare_IPs = Cloudflare_IPs[1:] + [selected_ip] | ||
| return selected_ip | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def get_next_backend_ip():
global Cloudflare_IPs
return next(Cloudflare_IPs)
UPDATE:
Here's an outline of the changes made in both the config.ini and gfw_resist_tls_proxy.py files:
config.ini file:
Cloudflare_IPsection to include a comma-separated list of IP addresses instead of a single IP address..py file:
randommodule to enable random selection of IP addresses.load_config()function to:Cloudflare_IPsection as a comma-separated list of IP addresses and store them in theCloudflare_IPsglobal variable.get_next_backend_ip()to:my_upstream()function to:get_next_backend_ip()function to get the next backend IP address for each request.main()function to:These changes allow the proxy server to accept a list of IP addresses and use a round-robin load balancing algorithm to randomly select and rotate IP addresses for each request.
(#12 (comment))
configparserlibrary to read settings from a configuration file.config.inifile with the necessary settings.parse_args()function to handle command-line arguments.load_config()function to load settings from the configuration file.main()function to use the new configuration handling functions.argparselibrary to handle command-line arguments.parse_args()function to accept a--configargument for specifying a custom configuration file.argparsemodule.configparsermodule.ThreadedServerclass with aThreadPoolExecutorto handle multiple client connections concurrently.send_data_in_fragmentfunction outside of theThreadedServerclass and made it a standalone function.my_upstreamandmy_downstreamfunctions to use the "with" statement for better resource management.