Giter VIP home page Giter VIP logo

ptadapter's People

Contributors

therealvincentvangogh avatar twisteroidambassador avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ptadapter's Issues

support passing arguments to PT program

For obfs4proxy, I could pass arguments to enable logging:

[ronlam@localhost pluggabletransportadapter]$ obfs4proxy --help
Usage of obfs4proxy:
  -enableLogging
        Log to TOR_PT_STATE_LOCATION/obfs4proxy.log
  -logLevel string
        Log level (ERROR/WARN/INFO/DEBUG) (default "ERROR")
  -obfs4-distBias
        Enable obfs4 using ScrambleSuit style table generation
  -unsafeLogging
        Disable the address scrubber
  -version
        Print version and exit

But using the script to pass arguments will cause error:

[ronlam@localhost pluggabletransportadapter]$ ./standalone_server.py standalone_server_config.ini -vv
[2016-08-24 14:13:16,839] root   DEBUG    Verbosity level set
[2016-08-24 14:13:16,839] root   DEBUG    Arguments:
[2016-08-24 14:13:16,839] root   DEBUG    Namespace(configfile=<_io.TextIOWrapper name='standalone_server_config.ini' mode='r' encoding='UTF-8'>, verbose=2)
[2016-08-24 14:13:16,840] root   INFO     Read config file
[2016-08-24 14:13:16,840] root   DEBUG    Transports:
[2016-08-24 14:13:16,840] root   DEBUG    {'obfs4': {'bindaddr': '127.0.0.1:7900'}}
[2016-08-24 14:13:16,840] pluggabletransportadapter INFO     Environment variables prepared for server /usr/local/bin/obfs4proxy -enableLogging
[2016-08-24 14:13:16,840] pluggabletransportadapter DEBUG    Environment variables:
[2016-08-24 14:13:16,840] pluggabletransportadapter DEBUG    {'TOR_PT_ORPORT': '127.0.0.1:7000', 'TOR_PT_SERVER_BINDADDR': 'obfs4-127.0.0.1:7900', 'TOR_PT_MANAGED_TRANSPORT_VER': '1', 'TOR_PT_STATE_LOCATION': '/tmp/.pt-state', 'TOR_PT_SERVER_TRANSPORTS': 'obfs4'}
Traceback (most recent call last):
  File "./standalone_server.py", line 91, in <module>
    main_cli()
  File "./standalone_server.py", line 73, in main_cli
    server.start()
  File "/home/ronlam/pluggabletransportadapter/pluggabletransportadapter/baseserverclient.py", line 187, in start
    self.run_ptexec()
  File "/home/ronlam/pluggabletransportadapter/pluggabletransportadapter/baseserverclient.py", line 49, in run_ptexec
    env=self.env, universal_newlines=True)
  File "/usr/lib64/python3.4/subprocess.py", line 859, in __init__
    restore_signals, start_new_session)
  File "/usr/lib64/python3.4/subprocess.py", line 1457, in _execute_child
    raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: '/usr/local/bin/obfs4proxy -enableLogging'

standalone_server_config.ini :

[ronlam@localhost pluggabletransportadapter]$ cat standalone_server_config.ini
[common]
exec = /usr/local/bin/obfs4proxy -enableLogging
statedir = /tmp/.pt-state
forward = 127.0.0.1:7000

[transports]
obfs4 = 127.0.0.1:7900

As stated in code, the standalone_server.py use subprocess.Popen(). The script pass whole '/usr/local/bin/obfs4proxy -enableLogging' as string, so the problem occurred.

May this script possible to use something like shlex.split() to split exec string to list before passing to the subprocess.Popen()?

Problem with ptadapter obfs3 and OPENVPN

I want to connect with ptadapter and obfs3 to openvpn server the config files are below:

##Client config:
[client]
exec = "D:\MyApp\ptadapter_config\obfs4proxy.exe"
#state = "D:\MyApp\ptadapter_config\state"
tunnels = fn_obfs_4 fn_obfs_3
[fn_obfs_3]
transport = obfs3
listen = 127.0.0.1:3883
upstream = x.x.x.x:10113

##Server Config
[server]
exec = /usr/bin/obfs4proxy -enableLogging
state = ./state
forward = 127.0.0.1:1194
tunnels = server_obfs4 server_obfs3
[server_obfs3]
transport = obfs3
listen = 127.0.0.1:10113

i did use socks proxy on openvpn client also and after i click on connect button the below error occured on client terminal:

[2023-01-04 16:03:32,857] WARNING handler PT reported error while connecting to upstream ('x.x.x.x', 10113): PTSOCKS5ConnectError(<SOCKS5Reply.GENERAL_FAILURE: b'\x01'>)
[2023-01-04 16:03:32,859] ERROR handler Unexpected error
Traceback (most recent call last):
File "C:\Users\Mori\AppData\Roaming\Python\Python311\site-packages\ptadapter\contexts.py", line 45, in log_unhandled_exc
yield
File "C:\Users\Mori\AppData\Roaming\Python\Python311\site-packages\ptadapter\console_script.py", line 52, in handle_client_connection
async with contexts.log_unhandled_exc(handler_logger),
File "C:\Program Files\Python311\Lib\contextlib.py", line 211, in aexit
await anext(self.gen)
File "C:\Users\Mori\AppData\Roaming\Python\Python311\site-packages\ptadapter\contexts.py", line 29, in aclosing_multiple_writers
close_tasks, _ = await asyncio.wait([w.wait_closed() for w in writers])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\asyncio\tasks.py", line 415, in wait
raise TypeError("Passing coroutines is forbidden, use tasks explicitly.")
TypeError: Passing coroutines is forbidden, use tasks explicitly.
C:\Users\Mori\AppData\Roaming\Python\Python311\site-packages\ptadapter\console_script.py:52: RuntimeWarning: coroutine 'StreamWriter.wait_closed' was never awaited
async with contexts.log_unhandled_exc(handler_logger),
RuntimeWarning: Enable tracemalloc to get the object allocation traceback

Maybe its a bug idk but i have same problem when i tried obfs4 connection btw.
Tanks for your great work.

--server does not auto-generate obfs4 keys (when removing predefined keys from config), error instead

In the current version, I run the program with
python3 ./standalone.py --server --verbose ./standalone_server_config.ini
with the recent version of obfs4proxy for TorBrowser.
The config file:

[obfs4-options]
iat-mode = 0

(In other words, the config options node-id, private-key, public-key, drbg-seed are left out, like the manual suggests.)

The program does not run, instead it produces error
future: <Future finished exception=PTExecSMethodError("SMETHOD-ERROR obfs4 missing argument 'node-id'",)>

PT options-* misread

Declaring any options-* in the config file results in ValueError: too many values to unpack (expected 2)

standalone.py

I am following instructions on installing obfs4proxy with openvpn here: https://mosin.ca/index.php/2018/09/05/setting-up-openvpn-with-obfs4proxy/

The startup script includes:
ExecStart=/usr/bin/python3 /etc/openvpn/pluggabletransportadapter/standalone.py --server /etc/openvpn/pluggabletransportadapter/standalone_server_config.ini

However, the git clone directory does not include the scripts 'standalone.py' or 'standalone_server_config.ini'. I have created the server ini file from the example_config.ini, but am stuck without the standalone.py file.

I am also using a redhat fork (like centos) which has python 3.6 installed. The original howto called for python3. Will 3.6 work the same?

I am assuming the files have changed since the howto was published. Can you please advise the current procedure?

Solved: Multiple server forward just like client?

This is the "standalone_client_config.ini".

[transports]
# Define transports supported by the PT here. Each supported transport type may
# have several clients with different options. Syntax:
# <config-section> = <transport-name>
# config-section is case-insensitive, and must not be "common" or "default".
obfs4-client1 = obfs4
obfs4-client2 = obfs4
obfs4-client3 = obfs4

We can use single client process manage three-more client instance.
And is there any possible to forward so much more address and port by single server process?
("standalone_server_config.ini")

either configparser not installed , or SyntaxError

Downloading/unpacking https://pypi.python.org/packages/61/a7/48f627413200d5dfd0a5da8b494d34ccac03f8a87a6b2d765b7d81e175e
3/configparser-3.5.0b2.tar.gz
Downloading configparser-3.5.0b2.tar.gz
Running setup.py (path:/tmp/pip-GbaYGD-build/setup.py) egg_info for package from https://pypi.python.org/packages/61/a
7/48f627413200d5dfd0a5da8b494d34ccac03f8a87a6b2d765b7d81e175e3/configparser-3.5.0b2.tar.gz

Installing collected packages: configparser
Running setup.py install for configparser

Skipping installation of /usr/local/lib/python2.7/dist-packages/backports/__init__.py (namespace package)
Installing /usr/local/lib/python2.7/dist-packages/configparser-3.5.0b2-nspkg.pth

Successfully installed configparser
Cleaning up...
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/pluggabletransportadapter/standalone_server.py", line 13, in
from pluggabletransportadapter import PluggableTransportServerAdapter
File "/usr/local/lib/python2.7/dist-packages/pluggabletransportadapter/pluggabletransportadapter/init.py", line 1,
in
from .baseserverclient import PluggableTransportServerAdapter,
File "/usr/local/lib/python2.7/dist-packages/pluggabletransportadapter/pluggabletransportadapter/baseserverclient.py",
line 439
buf = yield from reader.read(self.RELAY_BUFFER_SIZE)
^
SyntaxError: invalid syntax

Tutorial: If you want this to be pyinstaller.exe

Just give me the file

Github not support upload 7z so this is not a zip archive,
download and rename to 7z
ptadapter-3.0.0_windows_x64.zip
ptadapter-3.0.0_linux_x64.zip

Purpose

Pack ptadapter to pyinstaller then later use in other environment

Before pack

  • Add these (1) to very first line in main.py
  • Search and replace every "from . import something" to "import something"
  • Create dependencies list and include them by "--hidden-import" (2)

(1)

# Process PYTHONPATH
import os
import sys
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
sys.path.append(os.path.dirname(SCRIPT_DIR))

# Other code from upstream

(2)

  • Search "import" use VSCode from "*.py" under source directory
  • Right click and choose Copy all to a new text file
  • Delete py file name use regex replace
    .*\.py\n
  • Delete line number
    .*:
  • Delete comment if green lines appears too much
    #.*\n
  • Manual clean rest artifacts, keep each line one include without space or tab
  • Delete duplicate lines, sort alphabet
  • Delete extra subinclude (If import os, delete os.path etc.)
  • Replace import as --hidden-import
  • Use multi-line edit convert linebreak to space (merge into same line as command line argument)

Pack

  • Install pyinstaller in global python environment
  • Run pyinstaller (2) main.py
  • Copy all source code to dist folder

Imagine main.exe as main.py, it can't survive without other source files.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.