Created
December 3, 2019 01:13
-
-
Save jhseodev/8698402f0c17a99de0e294dbfe5c79e6 to your computer and use it in GitHub Desktop.
nginx map parser
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from reconfigure.parsers import NginxParser | |
conf = '''map $ssl_server_name $proxy_tcp { | |
hostnames; | |
default upstream_tcp; | |
*.test.com upstream_tcp2; | |
"~*test[1-9].com" upstream_tcp3; | |
} | |
''' | |
def main(): | |
np = NginxParser() | |
np.tokens.append((r".+?;", lambda s, t: ('option', t))) | |
print np.parse(conf) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment