File tree Expand file tree Collapse file tree 2 files changed +41
-8
lines changed
Expand file tree Collapse file tree 2 files changed +41
-8
lines changed Original file line number Diff line number Diff line change @@ -12,14 +12,20 @@ def set_auth(username, password):
1212 filedata = file .read ()
1313
1414 if settings .config ["no_auth" ]:
15- filedata = filedata .replace ("\n sudo sed -i 's/#BasicAuth user pass.*/BasicAuth username password/g' /etc/tinyproxy/tinyproxy.conf" , "" )
15+ # Remove auth configuration for 3proxy
16+ filedata = filedata .replace ('users username:CL:password\n auth strong cache 60\n ' , '' )
17+ filedata = filedata .replace ('allow username * *' , 'allow * * *' )
1618 else :
19+ # Replace username and password in 3proxy config
1720 filedata = filedata .replace ("username" , username )
1821 filedata = filedata .replace ("password" , password )
1922
2023 if settings .config ["only_host_ip" ]:
2124 ip_address = requests .get ('https://ipecho.net/plain' ).text .strip ()
25+ # Update UFW rules
2226 filedata = filedata .replace ("sudo ufw allow 22/tcp" , f"sudo ufw allow from { ip_address } to any port 22 proto tcp" )
2327 filedata = filedata .replace ("sudo ufw allow 8899/tcp" , f"sudo ufw allow from { ip_address } to any port 8899 proto tcp" )
28+ # Update 3proxy access rule to require both username and IP
29+ filedata = filedata .replace ("allow username * *" , f"allow username * { ip_address } " )
2430
2531 return filedata
Original file line number Diff line number Diff line change 11#! /bin/bash
22sudo apt-get -y update
3- sudo apt-get install -y ca-certificates tinyproxy
4- sudo sed -i ' s/Port 8888/Port 8899/g' /etc/tinyproxy/tinyproxy.conf
5- sudo sed -i ' s/Allow 127.0.0.1/#Allow 127.0.0.1/g' /etc/tinyproxy/tinyproxy.conf
6- sudo sed -i ' s/Allow ::1/#Allow ::1/g' /etc/tinyproxy/tinyproxy.conf
7- sudo sed -i ' s/#BasicAuth user pass.*/BasicAuth username password/g' /etc/tinyproxy/tinyproxy.conf
8- sudo sed -i ' s/#DisableViaHeader Yes/DisableViaHeader Yes/g' /etc/tinyproxy/tinyproxy.conf
9- sudo systemctl restart tinyproxy
3+ sudo apt-get install -y ca-certificates 3proxy
4+
5+ # Create 3proxy config directory and config
6+ sudo mkdir -p /etc/3proxy
7+ sudo cat > /etc/3proxy/3proxy.cfg << EOF
8+ # Main settings
9+ daemon
10+ maxconn 100
11+ nserver 1.1.1.1
12+ nserver 8.8.8.8
13+ nscache 65536
14+ timeouts 1 5 30 60 180 1800 15 60
15+
16+ # Access control and authentication
17+ users username:CL:password
18+ auth strong cache 60
19+
20+ # Privacy settings
21+ deny * * 127.0.0.1,192.168.1.1-192.168.255.255
22+ # IP-based access will be configured here if enabled
23+ allow username * *
24+
25+ # Proxy settings
26+ proxy -p8899 -n -a
27+ EOF
28+
29+ # Create log directory
30+ sudo mkdir -p /var/log/3proxy
31+
32+ # Setup firewall
1033sudo ufw default deny incoming
1134sudo ufw allow 22/tcp
1235sudo ufw allow 8899/tcp
1336sudo ufw --force enable
37+
38+ # Start service
39+ sudo systemctl enable 3proxy
40+ sudo systemctl start 3proxy
You can’t perform that action at this time.
0 commit comments