mirror of
https://github.com/SystemRage/py-kms.git
synced 2024-11-28 19:24:16 +01:00
better managed messages formattation and abbreviations parsing
This commit is contained in:
parent
319c6b3ef0
commit
a8a94ce7ab
@ -140,19 +140,21 @@ You can also enable other suboptions of `-F` doing what is reported in the follo
|
|||||||
-S or --logsize <MAXSIZE>
|
-S or --logsize <MAXSIZE>
|
||||||
> Use this flag to set a maximum size (in MB) to the output log file. Deactivated by default.
|
> Use this flag to set a maximum size (in MB) to the output log file. Deactivated by default.
|
||||||
|
|
||||||
|
##### subparser `connect`
|
||||||
|
|
||||||
-n or --listen <'IP,PORT'>
|
-n or --listen <'IP,PORT'>
|
||||||
> Use this subparser `connect` option to add multiple listening ip address - port couples. Note the format with the comma between the ip address and the port number. You can use this option more than once.
|
> Use this option to add multiple listening ip address - port couples. Note the format with the comma between the ip address and the port number. You can use this option more than once.
|
||||||
|
|
||||||
-b or --backlog <BACKLOG>
|
-b or --backlog <BACKLOG>
|
||||||
> Use this subparser `connect` option to specify the maximum length of the queue of pending connections, referred to a ip address - port couple.
|
> Use this option to specify the maximum length of the queue of pending connections, referred to a ip address - port couple.
|
||||||
If placed just after `connect` refers to the main address and all additive couples without `-b` or `-u` options. Default is 5.
|
If placed just after `connect` refers to the main address and all additive couples without `-b` option. Default is 5.
|
||||||
|
|
||||||
-u or --no-reuse
|
-u or --no-reuse
|
||||||
> Use this subparser `connect` option not to allow binding / listening to the same ip address - port couple specified with `-n`.
|
> Use this option not to allow binding / listening to the same ip address - port couple specified with `-n`.
|
||||||
If placed just after `connect` refers to the main address and all additive couples without `-b` or `-u` options. Reusing port is activated by default (except when running inside the Windows Sandbox and the current user is `WDAGUtilityAccount`).
|
If placed just after `connect` refers to the main address and all additive couples without `-u` option. Reusing port is activated by default (except when running inside the Windows Sandbox and the current user is `WDAGUtilityAccount`).
|
||||||
|
|
||||||
-d or --dual
|
-d or --dual
|
||||||
> Use this subparser `connect` option to allow listening to an IPv6 address also accepting connections via IPv4.
|
> Use this option to allow listening to an IPv6 address also accepting connections via IPv4.
|
||||||
If used it refers to all addresses (main and additional). Deactivated by default.
|
If used it refers to all addresses (main and additional). Deactivated by default.
|
||||||
|
|
||||||
examples (with fictitious addresses and ports):
|
examples (with fictitious addresses and ports):
|
||||||
|
@ -82,32 +82,32 @@ ColorExtraMap = dict(ColorMap, **ExtraMap)
|
|||||||
ColorMapReversed = dict(zip(ColorMap.values(), ColorMap.keys()))
|
ColorMapReversed = dict(zip(ColorMap.values(), ColorMap.keys()))
|
||||||
ExtraMapReversed = dict(zip(ExtraMap.values(), ExtraMap.keys()))
|
ExtraMapReversed = dict(zip(ExtraMap.values(), ExtraMap.keys()))
|
||||||
|
|
||||||
MsgMap = {0 : {'text' : "{yellow}\n\t\t\tClient generating RPC Bind Request...{end}", 'align' : ()},
|
MsgMap = {0 : {'text' : "{{yellow}}{}{}Client generating RPC Bind Request...{{end}}" .format('\n', '\t' * 3)},
|
||||||
1 : {'text' : "{white}<==============={end}{yellow}\tClient sending RPC Bind Request...{end}", 'align' : ()},
|
1 : {'text' : "{{white}}<==============={{end}}{{yellow}}{}Client sending RPC Bind Request...{{end}}" .format('\t')},
|
||||||
2 : {'text' : "{yellow}Server received RPC Bind Request !!!\t\t\t\t{end}{white}<==============={end}", 'align' : ()},
|
2 : {'text' : "{{yellow}}Server received RPC Bind Request !!!{}{{end}}{{white}}<==============={{end}}" .format('\t' * 4)},
|
||||||
3 : {'text' : "{yellow}Server parsing RPC Bind Request...{end}", 'align' : ()},
|
3 : {'text' : "{{yellow}}Server parsing RPC Bind Request...{{end}}" .format()},
|
||||||
4 : {'text' : "{yellow}Server generating RPC Bind Response...{end}", 'align' : ()},
|
4 : {'text' : "{{yellow}}Server generating RPC Bind Response...{{end}}" .format()},
|
||||||
5 : {'text' : "{yellow}Server sending RPC Bind Response...\t\t\t\t{end}{white}===============>{end}", 'align' : ()},
|
5 : {'text' : "{{yellow}}Server sending RPC Bind Response...{}{{end}}{{white}}===============>{{end}}" .format('\t' * 4)},
|
||||||
6 : {'text' : "{green}{bold}\nRPC Bind acknowledged !!!{end}", 'align' : ()},
|
6 : {'text' : "{{green}}{{bold}}{}RPC Bind acknowledged !!!{{end}}" .format('\n')},
|
||||||
7 : {'text' : "{white}===============>{end}{yellow}\tClient received RPC Bind Response !!!{end}", 'align' : ()},
|
7 : {'text' : "{{white}}===============>{{end}}{{yellow}}{}Client received RPC Bind Response !!!{{end}}" .format('\t')},
|
||||||
8 : {'text' : "{green}{bold}\t\t\tRPC Bind acknowledged !!!{end}", 'align' : ()},
|
8 : {'text' : "{{green}}{{bold}}{}RPC Bind acknowledged !!!{{end}}" .format('\t' * 3)},
|
||||||
9 : {'text' : "{blue}\t\t\tClient generating Activation Request dictionary...{end}", 'align' : ()},
|
9 : {'text' : "{{blue}}{}Client generating Activation Request dictionary...{{end}}" .format('\t' * 3)},
|
||||||
10 : {'text' : "{blue}\t\t\tClient generating Activation Request data...{end}", 'align' : ()},
|
10 : {'text' : "{{blue}}{}Client generating Activation Request data...{{end}}" .format('\t' * 3)},
|
||||||
11 : {'text' : "{blue}\t\t\tClient generating RPC Activation Request...{end}", 'align' : ()},
|
11 : {'text' : "{{blue}}{}Client generating RPC Activation Request...{{end}}" .format('\t' * 3)},
|
||||||
12 : {'text' : "{white}<==============={end}{blue}\tClient sending RPC Activation Request...{end}", 'align' : ()},
|
12 : {'text' : "{{white}}<==============={{end}}{{blue}}{}Client sending RPC Activation Request...{{end}}" .format('\t')},
|
||||||
13 : {'text' : "{blue}Server received RPC Activation Request !!!\t\t\t{end}{white}<==============={end}", 'align' : ()},
|
13 : {'text' : "{{blue}}Server received RPC Activation Request !!!{}{{end}}{{white}}<==============={{end}}" .format('\t' * 3)},
|
||||||
14 : {'text' : "{blue}Server parsing RPC Activation Request...{end}", 'align' : ()},
|
14 : {'text' : "{{blue}}Server parsing RPC Activation Request...{{end}}" .format()},
|
||||||
15 : {'text' : "{blue}Server processing KMS Activation Request...{end}", 'align' : ()},
|
15 : {'text' : "{{blue}}Server processing KMS Activation Request...{{end}}" .format()},
|
||||||
16 : {'text' : "{blue}Server processing KMS Activation Response...{end}", 'align' : ()},
|
16 : {'text' : "{{blue}}Server processing KMS Activation Response...{{end}}" .format()},
|
||||||
17 : {'text' : "{blue}Server generating RPC Activation Response...{end}", 'align' : ()},
|
17 : {'text' : "{{blue}}Server generating RPC Activation Response...{{end}}" .format()},
|
||||||
18 : {'text' : "{blue}Server sending RPC Activation Response...\t\t\t{end}{white}===============>{end}", 'align' : ()},
|
18 : {'text' : "{{blue}}Server sending RPC Activation Response...{}{{end}}{{white}}===============>{{end}}" .format('\t' * 3)},
|
||||||
19 : {'text' : "{green}{bold}\nServer responded, now in Stand by...\n{end}", 'align' : ()},
|
19 : {'text' : "{{green}}{{bold}}{}Server responded, now in Stand by...{}{{end}}" .format('\n','\n')},
|
||||||
20 : {'text' : "{white}===============>{end}{blue}\tClient received Response !!!{end}", 'align' : ()},
|
20 : {'text' : "{{white}}===============>{{end}}{{blue}}{}Client received Response !!!{{end}}" .format('\t')},
|
||||||
21 : {'text' : "{green}{bold}\t\t\tActivation Done !!!{end}", 'align' : ()},
|
21 : {'text' : "{{green}}{{bold}}{}Activation Done !!!{{end}}" .format('\t' * 3)},
|
||||||
-1 : {'text' : "{white}Server receiving{end}", 'align' : ()},
|
-1 : {'text' : "{{white}}Server receiving{{end}}" .format()},
|
||||||
-2 : {'text' : "{white}\t\t\t\t\t\t\t\tClient sending{end}", 'align' : ()},
|
-2 : {'text' : "{{white}}{}Client sending{{end}}" .format('\t' * 8)},
|
||||||
-3 : {'text' : "{white}\t\t\t\t\t\t\t\tClient receiving{end}", 'align' : ()},
|
-3 : {'text' : "{{white}}{}Client receiving{{end}}" .format('\t' * 8)},
|
||||||
-4 : {'text' : "{white}Server sending{end}", 'align' : ()},
|
-4 : {'text' : "{{white}}Server sending{{end}}" .format()},
|
||||||
}
|
}
|
||||||
|
|
||||||
def unformat_message(symbolic_string_list):
|
def unformat_message(symbolic_string_list):
|
||||||
@ -211,7 +211,7 @@ class ShellMessage(object):
|
|||||||
pass
|
pass
|
||||||
self.msgfrmt = msgtofrmt.format(**ColorExtraMap)
|
self.msgfrmt = msgtofrmt.format(**ColorExtraMap)
|
||||||
if self.get_text:
|
if self.get_text:
|
||||||
self.plaintext.append(unshell_message(self.msgfrmt, count = 0)[0]["tag00"]['text'])
|
self.plaintext.append(unshell_message(self.msgfrmt, count = 0)[0]["tag00"]['text'].strip())
|
||||||
|
|
||||||
def newlines_file(self, mode, *args):
|
def newlines_file(self, mode, *args):
|
||||||
try:
|
try:
|
||||||
|
@ -392,19 +392,24 @@ def kms_parser_check_optionals(userarg, zeroarg, onearg, msg = 'optional py-kms
|
|||||||
allarg = zeroarg + onearg
|
allarg = zeroarg + onearg
|
||||||
|
|
||||||
def is_abbrev(allarg, arg_to_check):
|
def is_abbrev(allarg, arg_to_check):
|
||||||
|
extended = []
|
||||||
for opt in allarg:
|
for opt in allarg:
|
||||||
if len(opt) > 2 and opt[2] == arg_to_check[2]:
|
if len(opt) > 2 and opt[2] == arg_to_check[2]:
|
||||||
for indx in range(-1, -len(opt), -1):
|
for indx in range(-1, -len(opt), -1):
|
||||||
if opt[:indx] == arg_to_check:
|
if opt[:indx] == arg_to_check:
|
||||||
raise KmsParserException("%s argument `%s` abbreviation not allowed for `%s`" %(msg, arg_to_check, opt))
|
extended.append(opt)
|
||||||
return False
|
return extended
|
||||||
|
|
||||||
# Check abbreviations, joining, not existing.
|
# Check abbreviations, joining, not existing.
|
||||||
for arg in userarg:
|
for arg in userarg:
|
||||||
if arg not in allarg:
|
if arg not in allarg:
|
||||||
if arg.startswith('-'):
|
if arg.startswith('-'):
|
||||||
if arg == '--' or arg[:2] != '--' or not is_abbrev(allarg, arg):
|
if arg == '--' or arg[:2] != '--':
|
||||||
raise KmsParserException("unrecognized %s arguments: `%s`" %(msg, arg))
|
raise KmsParserException("unrecognized %s arguments: `%s`" %(msg, arg))
|
||||||
|
else:
|
||||||
|
extended = is_abbrev(allarg, arg)
|
||||||
|
if extended:
|
||||||
|
raise KmsParserException("%s argument `%s` abbreviation not allowed for `%s`" %(msg, arg, ', '.join(extended)))
|
||||||
|
|
||||||
# Check duplicates.
|
# Check duplicates.
|
||||||
founds = [i for i in userarg if i in allarg]
|
founds = [i for i in userarg if i in allarg]
|
||||||
|
Loading…
Reference in New Issue
Block a user