Browse Source

refactor: python package of ProxyBuilder

master
Dnomd343 3 years ago
parent
commit
8da30de6be
  1. 6
      ProxyBuilder/__init__.py
  2. 3
      ProxyBuilder/__main__.py
  3. 4
      ProxyBuilder/builder.py
  4. 12
      demo.py

6
ProxyBuilder/__init__.py

@ -1,6 +1,6 @@
#!/usr/bin/python
# -*- coding:utf-8 -*-
from ProxyBuilder.main import build
from ProxyBuilder.main import check
from ProxyBuilder.main import destroy
from ProxyBuilder.builder import *
__all__ = [ 'build', 'check', 'destroy' ]

3
ProxyBuilder/__main__.py

@ -0,0 +1,3 @@
import ProxyBuilder.builder
ProxyBuilder.builder.test()

4
ProxyBuilder/main.py → ProxyBuilder/builder.py

@ -7,6 +7,7 @@ import ctypes
import random
import socket
import subprocess
from ProxyBuilder import Shadowsocks
from ProxyBuilder import ShadowsocksR
@ -129,3 +130,6 @@ def destroy(taskInfo): # 结束客户端并清理
try:
os.remove(taskInfo['file']) # 删除配置文件
except: pass
def test():
print("ProxyBuilder test")

12
demo.py

@ -1,7 +1,7 @@
import time
import socket
import requests
import ProxyBuilder
import ProxyBuilder as Builder
def checkSocksPort(port):
try:
@ -40,11 +40,14 @@ testInfo = {
}
print("start")
print(dir(Builder))
print(testInfo)
task = ProxyBuilder.build(testInfo, '/tmp/ProxyC')
task = Builder.build(testInfo, '/tmp/ProxyC')
print(task)
time.sleep(1)
if ProxyBuilder.check(task) == False:
if Builder.check(task) == False:
print("error exit")
else:
print("test with gstatic")
@ -55,6 +58,5 @@ else:
print("ok")
else:
print("error")
ProxyBuilder.destroy(task)
Builder.destroy(task)
print("stop")
Loading…
Cancel
Save