mirror of
https://github.com/r4sas/proxychecker
synced 2025-03-13 05:41:31 +00:00
proxy checker
This commit is contained in:
commit
a55c42e0f1
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/list.ini
|
||||
/result.txt
|
41
README.md
Normal file
41
README.md
Normal file
@ -0,0 +1,41 @@
|
||||
Proxy checker
|
||||
=====
|
||||
|
||||
Written on python, requires at least version 3.4.
|
||||
|
||||
For work needed PySocks and urllib3, install it with pip:
|
||||
```
|
||||
$ python3 -m pip install PySocks
|
||||
$ python3 -m pip install urllib3
|
||||
```
|
||||
|
||||
That script written primary for checking I2P proxy tunnels.
|
||||
|
||||
Configuring
|
||||
-----
|
||||
|
||||
Fill `list.ini` with your tunnels options as in example file.
|
||||
|
||||
At same time you need that tunnels configured in your tunnels.conf (i2pd) or tunnels page (i2p).
|
||||
|
||||
Example for *false.i2p* outproxy usage in i2pd:
|
||||
```
|
||||
[FALSE]
|
||||
type = httpproxy
|
||||
address = 127.0.0.1
|
||||
port = 4450
|
||||
outproxy = http://77mpz4z6s4eenjexleclqb36uxvqjtztqikjfqa4sovojh6gwwha.b32.i2p
|
||||
keys = false.dat
|
||||
```
|
||||
|
||||
And, according to that tunnel, proxy checker config:
|
||||
```
|
||||
[4450]
|
||||
type = http
|
||||
address = 77mpz4z6s4eenjexleclqb36uxvqjtztqikjfqa4sovojh6gwwha.b32.i2p
|
||||
name = false.i2p
|
||||
owner = meeh
|
||||
info = httpproxy
|
||||
```
|
||||
|
||||
**Note that fields PORT and TYPE is required!** Other fields is not required and used only for filling table output.
|
84
bin/checker.py
Executable file
84
bin/checker.py
Executable file
@ -0,0 +1,84 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import sys, configparser
|
||||
from datetime import datetime
|
||||
import socket, urllib.request
|
||||
## PySocks
|
||||
import socks
|
||||
from sockshandler import SocksiPyHandler
|
||||
|
||||
TESTURI = "https://google.com/"
|
||||
PROXYHOST = "127.0.0.1"
|
||||
TIMEOUT = 30
|
||||
|
||||
## https://stackoverflow.com/a/14906787
|
||||
class Logger(object):
|
||||
def __init__(self):
|
||||
self.terminal = sys.stdout
|
||||
self.log = open("result.txt", "w")
|
||||
|
||||
def write(self, message):
|
||||
self.terminal.write(message)
|
||||
self.log.write(message)
|
||||
|
||||
def flush(self):
|
||||
self.terminal.flush()
|
||||
|
||||
sys.stdout = Logger()
|
||||
|
||||
def checkproxy(port, type):
|
||||
if type == 'http':
|
||||
handler = socks.HTTP
|
||||
elif type == 'socks':
|
||||
handler = socks.SOCKS5
|
||||
elif type == 'http0':
|
||||
proxy = urllib.request.ProxyHandler({'http': PROXYHOST +':' + str(port)})
|
||||
else:
|
||||
print("[unsupported type]")
|
||||
return
|
||||
|
||||
if type == 'http0':
|
||||
opener = urllib.request.build_opener(proxy)
|
||||
else:
|
||||
opener = urllib.request.build_opener(
|
||||
SocksiPyHandler(handler, PROXYHOST, port)
|
||||
)
|
||||
|
||||
try:
|
||||
response = opener.open(TESTURI, timeout=TIMEOUT).read()
|
||||
except Exception as e:
|
||||
print("[%5s]" % ('dead'))
|
||||
return
|
||||
|
||||
print("[%5s]" % ('alive'))
|
||||
|
||||
def main():
|
||||
# Read list with ports and information
|
||||
config = configparser.ConfigParser()
|
||||
config.read('list.ini')
|
||||
proxyList = config.sections()
|
||||
|
||||
print("Started check at %s UTC" % (datetime.utcnow()))
|
||||
print("Types: HTTP - using SocksiPyHandler, HTTP0 - using urllib, SOCKS - only 5th version using SocksiPyHandler")
|
||||
print("[%5s] [%5s] [%60s] [%16s] [%16s] [%16s] [%5s]" %
|
||||
('PORT','TYPE','B32 ADDRESS','NAME','OWNER','INFO','STATUS'))
|
||||
|
||||
for currentProxy in proxyList:
|
||||
tunnel = dict(config.items(str(currentProxy)))
|
||||
|
||||
print(
|
||||
"[%5d] [%5s] [%60s] [%16s] [%16s] [%16s] " % (
|
||||
int(currentProxy),
|
||||
tunnel['type'] if ("type" in tunnel) else "none",
|
||||
tunnel['address'] if ("address" in tunnel) else "",
|
||||
tunnel['name'] if ("name" in tunnel) else "",
|
||||
tunnel['owner'] if ("owner" in tunnel) else "",
|
||||
tunnel['info'] if ("info" in tunnel) else ""
|
||||
),
|
||||
end='', flush=True
|
||||
)
|
||||
|
||||
checkproxy(int(currentProxy), str(config[currentProxy]['type']))
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
9
check
Executable file
9
check
Executable file
@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
findpy3=$(which python3)
|
||||
if [ -z $findpy3 ]; then
|
||||
echo "Can't find 'pyhton3' installed. That script needs it!";
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
$findpy3 bin/checker.py
|
32
check.bat
Normal file
32
check.bat
Normal file
@ -0,0 +1,32 @@
|
||||
@echo off
|
||||
title Checking tunnels...
|
||||
SET PY_PYTHON=3
|
||||
|
||||
for %%X in (python3.exe) do (set FOUND=%%~$PATH:X)
|
||||
if defined FOUND (
|
||||
set xPy=%FOUND%
|
||||
goto RUN_CHECK
|
||||
)
|
||||
|
||||
for %%X in (python.exe) do (set FOUND=%%~$PATH:X)
|
||||
if defined FOUND (
|
||||
%FOUND% -c "import sys; print(sys.version_info[0])" | find "3" >nul && set xyes=1 || set xyes=0
|
||||
if "%xyes%" == 1 (
|
||||
set xPy=%FOUND%
|
||||
goto RUN_CHECK
|
||||
) else (
|
||||
echo Error: Python3 not found!
|
||||
pause
|
||||
exit
|
||||
)
|
||||
) else (
|
||||
echo Error: Python3 not found!
|
||||
pause
|
||||
exit
|
||||
)
|
||||
|
||||
:RUN_CHECK
|
||||
%xPy% bin\checker.py
|
||||
|
||||
echo Done...
|
||||
pause > nul
|
34
list.example.ini
Normal file
34
list.example.ini
Normal file
@ -0,0 +1,34 @@
|
||||
; REQIRED FIELDS IS PORT and TYPE!
|
||||
; Other fields is not required
|
||||
;
|
||||
; Указание полей PORT и TYPE обязательно!
|
||||
; Остальные можно заполнять чем угодно,
|
||||
; они используются только для вывода информации в таблицу
|
||||
;
|
||||
; [PORT]
|
||||
; type = type of proxy (http - using SocksiPyHandler, http0 - using urllib, socks - only 5th version using SocksiPyHandler)
|
||||
; address = base32 address
|
||||
; name = name of tunnel
|
||||
; owner = name of owner
|
||||
; info = some info
|
||||
|
||||
[4450]
|
||||
type = http
|
||||
address = 77mpz4z6s4eenjexleclqb36uxvqjtztqikjfqa4sovojh6gwwha.b32.i2p
|
||||
name = false.i2p
|
||||
owner = meeh
|
||||
info = httpproxy
|
||||
|
||||
[4465]
|
||||
type = socks
|
||||
address = hob3qpw7c6yaurusuzlden66tp4opksrqqukywefnqyj6lhauhoa.b32.i2p
|
||||
name = public
|
||||
owner = r4sas
|
||||
info = client
|
||||
|
||||
[4470]
|
||||
type = http
|
||||
address = wfigbdfs6tvajiw24xwohbwwy5pq3jcgzevwnsky2ucwzwgodumq.b32.i2p
|
||||
name = blue
|
||||
owner = arctic
|
||||
info = httpproxy
|
Loading…
x
Reference in New Issue
Block a user