tproxy support for script cli args

Offen
#5 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
35/100
Issue-Typ
Feature
Klarheit
Größtenteils klar
Aktivitätsstatus
Veraltet
Tech-Stack
python
Bereich
cli

Rechercherichtung

Beginne mit dem Lesen von tproxy.app.run und tproxy.config und vergleiche sie anschließend mit dem Workaround dproxy.py und dem Beispiel transparent2.py im Issue. Verfolge, wie Argumente das aufgerufene Skript erreichen, und lege fest, wie zusätzliche Argumente weitergeleitet und ohne argparse abgerufen werden sollen. Erledigt ist die Aufgabe, wenn ein aufgerufenes Skript zusätzliche Befehlszeilenargumente über tproxy empfangen und verwenden kann.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

extend tproxy such that command line arguments can be passed all the way to the called script.

Current workaround:

assume the following command line (notice the extra --remote argument):

$ dproxy.py --daemon --log-file=MyLogFile.log --bind=127.0.0.1:5678 --remote=130.130.130.130:6789 transparent2.py

where dproxy.py replaces tproxy by supporting the --remote cli argument as follows:

from tproxy.app import run
from tproxy.config import *
import os

class RemoteAddress(Setting):
    name = "remote"
    section = "the address of the remote host"
    cli = ["-r", "--remote"]
    meta = "REMOTEADDRESS"
    default = "127.0.0.1:8080"
    validator = validate_string
    desc = """\
        address of remote host to connect to
        """
run() 

while transparent2.py would look as follows:

import argparse

# parse the arguments
parser          = argparse.ArgumentParser()
parser.add_argument('--remote',     dest='remote',      action='store', type=str, default=None)
args, remainder = parser.parse_known_args()

ip, port        = args.remote.split(':')

def proxy(data):
    return {'remote': (ip, int(port))}

although this approach works, it's still nicer if tproxy would provide support for extra cli arguments and possibly facilitate access to them without going through argparse in the called script.

Vorherrschende Sprache
Python
Sterne
269
Forks
33
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Entwicklungsumgebung

Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus benoitc/tproxy

Alle Issues in benoitc/tproxy

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.