mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-27 02:24:18 +00:00
Nicer port specification for pathoc
This commit is contained in:
parent
6d8431ab3e
commit
384abbfdd5
@ -38,23 +38,20 @@ def go_pathoc():
|
||||
"-n", dest='repeat', default=1, type=int, metavar="N",
|
||||
help='Repeat requests N times'
|
||||
)
|
||||
parser.add_argument(
|
||||
"-p", dest="port", type=int, default=None,
|
||||
help="Port. Defaults to 80, or 443 if SSL is active"
|
||||
)
|
||||
parser.add_argument(
|
||||
"-t", dest="timeout", type=int, default=None,
|
||||
help="Connection timeout"
|
||||
)
|
||||
parser.add_argument(
|
||||
'host', type=str,
|
||||
help='Host to connect to'
|
||||
metavar = "host[:port]",
|
||||
help='Host and port to connect to'
|
||||
)
|
||||
parser.add_argument(
|
||||
'request', type=str, nargs="+",
|
||||
help="""
|
||||
Request specification, or path to a file containing a request
|
||||
specifcation
|
||||
Request specification, or path to a file containing request
|
||||
specifcations
|
||||
"""
|
||||
)
|
||||
group = parser.add_argument_group(
|
||||
@ -127,10 +124,18 @@ def go_pathoc():
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
args.port = None
|
||||
if ":" in args.host:
|
||||
h, p = args.host.rsplit(":", 1)
|
||||
try:
|
||||
p = int(p)
|
||||
except ValueError:
|
||||
parser.error("Invalid port in host spec: %s" % args.host)
|
||||
args.host = h
|
||||
args.port = p
|
||||
|
||||
if args.port is None:
|
||||
args.port = 443 if args.ssl else 80
|
||||
else:
|
||||
args.port = args.port
|
||||
|
||||
try:
|
||||
args.ignorecodes = [int(i) for i in args.ignorecodes.split(",") if i]
|
||||
|
Loading…
Reference in New Issue
Block a user