Skip to content

Commit c1ecc82

Browse files
committed
new lists, write lists to files instead of catching stdout
1 parent c8dff12 commit c1ecc82

File tree

4 files changed

+70
-18
lines changed

4 files changed

+70
-18
lines changed

.github/workflows/mullvad-socks.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,22 @@ jobs:
2727
git config user.email "${{ github.actor }}@users.noreply.github.com"
2828
git checkout list
2929
git pull
30+
rm *.txt
31+
echo "TAG_NAME=$(date +"%Y-%m-%dT%H-%M-%S")" >> $GITHUB_ENV
3032
31-
- name: Generate list
33+
- name: Download and install script dependencies
3234
run: |
35+
wget https://github.com/P3TERX/GeoLite.mmdb/raw/download/GeoLite2-City.mmdb
3336
pip3 install -r requirements.txt
34-
python3 mullvad-socks-list.py > repo/mullvad-socks-list.txt
35-
echo "TAG_NAME=$(date +"%Y-%m-%d_%H-%M-%S")" >> $GITHUB_ENV
37+
38+
- name: Generate list
39+
run: |
40+
python3 mullvad-socks-list.py
3641
3742
- name: Push result to "list" branch
3843
run: |
3944
cd repo
40-
git add mullvad-socks-list.txt
45+
git add .
4146
git commit -m "${{ env.TAG_NAME }}"
4247
git push -u origin list
4348
@@ -48,7 +53,7 @@ jobs:
4853
with:
4954
tag_name: ${{ env.TAG_NAME }}
5055
body: ${{ env.TAG_NAME }}
51-
files: repo/mullvad-socks-list.txt
56+
files: repo/*
5257

5358
- name: Remove old Releases
5459
uses: dev-drprasad/delete-older-releases@v0.2.0

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# Mullvad socks proxy list
22
[![Publish mullvad-socks-list.txt](https://github.com/maximko/mullvad-socks-list/actions/workflows/mullvad-socks.yml/badge.svg)](https://github.com/maximko/mullvad-socks-list/actions/workflows/mullvad-socks.yml)
33

4-
[LINK TO ACTUAL LIST](https://github.com/maximko/mullvad-socks-list/blob/list/mullvad-socks-list.txt) [[RAW](https://raw.githubusercontent.com/maximko/mullvad-socks-list/list/mullvad-socks-list.txt)]
4+
[ALL ACTIVE SOCKS DETAILED LIST](https://raw.githubusercontent.com/maximko/mullvad-socks-list/list/mullvad-socks-list.txt)
55

6-
This is a list of socks5 proxy servers usable in mullvad vpn network, as well as the script that generates this list. The script runs every day by github actions and pushes result to [list branch](https://github.com/maximko/mullvad-socks-list/tree/list).
6+
[Socks and ipv4_in list](https://raw.githubusercontent.com/maximko/mullvad-socks-list/list/socks-ipv4_in-list.txt)
7+
8+
[Socks and timezone list](https://raw.githubusercontent.com/maximko/mullvad-socks-list/list/socks-timezone-list.txt)
9+
10+
These are lists of socks5 proxy servers usable in mullvad vpn network, as well as the script that generates these lists. The script runs every day by github actions and pushes result to [list branch](https://github.com/maximko/mullvad-socks-list/tree/list).
711

812
Please note that all socks dns names are resolved and this is a purpose of this project.

mullvad-socks-list.py

Lines changed: 53 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from datetime import datetime,timezone
77
from threading import Thread
88
from queue import Queue
9+
import geoip2.database
910

1011
def resolver(queue, resolved, failed):
1112
resolver = pydig.Resolver(nameservers=['1.1.1.1'])
@@ -26,20 +27,31 @@ def resolver(queue, resolved, failed):
2627
#print("Left to resolve:", queue.qsize(), end="\r")
2728
queue.task_done()
2829

30+
geoip2_reader = geoip2.database.Reader("GeoLite2-City.mmdb")
31+
32+
def ip_to_timezone(ipv4):
33+
global geoip2_reader
34+
try:
35+
response = geoip2_reader.city(ipv4)
36+
timezone = response.location.time_zone
37+
if timezone:
38+
return timezone
39+
else:
40+
return None
41+
except:
42+
return None
43+
2944
queue = Queue()
3045
resolved = {}
3146
failed = {}
3247

33-
now_utc = datetime.now(timezone.utc)
34-
print('Date:', now_utc.strftime('%Y-%m-%d %H-%M-%S %Z'))
35-
3648
r = requests.get('https://api.mullvad.net/www/relays/wireguard/').json()
3749

3850
for host in r:
3951
if host['socks_name'] is not None and host['active']:
4052
queue.put(host['socks_name'])
4153

42-
print("Total active proxies:", queue.qsize())
54+
total_proxies = queue.qsize()
4355
threads = []
4456
for i in range(0, 3):
4557
threads.append(Thread(target=resolver, args=(queue,resolved,failed), daemon=True))
@@ -48,48 +60,79 @@ def resolver(queue, resolved, failed):
4860
queue.join()
4961

5062
good = PrettyTable()
51-
good.field_names = ["flag", "country", "city", "socks", "ip", "speed", "multihop", "owned", "provider", "hostname"]
63+
good.field_names = ["flag", "country", "city", "socks5", "ipv4", "ipv6", "speed", "multihop", "owned", "provider", "stboot", "hostname"]
5264
good.align = 'l'
5365
good.border = False
5466

5567
bad = PrettyTable()
56-
bad.field_names = ["flag", "country", "city", "socks", "ip", "speed", "multihop", "owned", "provider", "hostname"]
68+
bad.field_names = ["flag", "country", "city", "socks5", "ipv4", "ipv6", "speed", "multihop", "owned", "provider", "stboot", "hostname"]
5769
bad.align = 'l'
5870
bad.border = False
5971

72+
socks_ipv4_list = []
73+
socks_timezone_list = []
74+
6075
for host in r:
6176
if host['socks_name'] is not None and host['active']:
77+
6278
fl = flag.flag(host['country_code'])
6379
owned = '✔️' if host['owned'] else '❌'
80+
stboot = '✔️' if host['stboot'] else '❌'
81+
6482
if host['socks_name'] in resolved:
6583
socks_addr = resolved[host['socks_name']]
6684
good.add_row([fl,
6785
host['country_name'],
6886
host['city_name'],
6987
socks_addr,
7088
host['ipv4_addr_in'],
89+
host['ipv6_addr_in'],
7190
host['network_port_speed'],
7291
host['multihop_port'],
7392
owned,
7493
host['provider'],
94+
stboot,
7595
host['hostname'],
7696
])
97+
98+
# socks and ipv4 list
99+
socks_ipv4_list.append('%s %s' % (socks_addr, host['ipv4_addr_in']))
100+
101+
# socks and timezone list
102+
ip_timezone = ip_to_timezone(host['ipv4_addr_in'])
103+
if ip_timezone:
104+
socks_timezone_list.append(f'{socks_addr} {ip_timezone}')
105+
77106
elif host['socks_name'] in failed:
78107
bad.add_row([fl,
79108
host['country_name'],
80109
host['city_name'],
81110
host['socks_name'],
82111
host['ipv4_addr_in'],
112+
host['ipv6_addr_in'],
83113
host['network_port_speed'],
84114
host['multihop_port'],
85115
owned,
86116
host['provider'],
117+
stboot,
87118
host['hostname'],
88119
])
89120
else:
90121
break
91122

92-
print(good)
93-
if len(failed) > 0:
94-
print('Failed to resovle:')
95-
print(bad)
123+
with open('repo/mullvad-socks-list.txt', 'a') as file:
124+
now_utc = datetime.now(timezone.utc)
125+
file.write('Date: %s\n' % now_utc.strftime('%Y-%m-%d %H-%M-%S %Z'))
126+
file.write('Total active proxies: %s\n' % total_proxies)
127+
file.write(good.get_string()+ '\n')
128+
if len(failed) > 0:
129+
file.write('Failed to resovle:\n')
130+
file.write(bad.get_string() + '\n')
131+
132+
with open('repo/socks-ipv4_in-list.txt', 'a') as file:
133+
for item in socks_ipv4_list:
134+
file.write("%s\n" % item)
135+
136+
with open('repo/socks-timezone-list.txt', 'a') as file:
137+
for item in socks_timezone_list:
138+
file.write("%s\n" % item)

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
emoji_country_flag==1.3.1
2-
flag==0.1.1
32
prettytable==3.3.0
43
pydig==0.4.0
54
requests==2.28.1
5+
geoip2==4.6.0

0 commit comments

Comments
 (0)