Skip to content

Instantly share code, notes, and snippets.

@lixingcong
Created May 25, 2018 07:29
Show Gist options
  • Save lixingcong/3d3187fd31c689857c31c1e985844f4d to your computer and use it in GitHub Desktop.
Save lixingcong/3d3187fd31c689857c31c1e985844f4d to your computer and use it in GitHub Desktop.
dante配置ACL生成器
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# 用于打印dante.conf的socks pass/block的
# 目标规则(Target IPs)
# Document: https://www.inet.no/dante/doc/1.4.x/sockd.conf.5.html
TELEGRAM_PASS_CIDR=(
"91.108.4.0/22",
"91.108.8.0/21",
"91.108.16.0/21",
"91.108.36.0/23",
"91.108.38.0/23",
"91.108.56.0/22",
"149.154.160.0/2",
)
DEFAULT_BLOCK_CIDR=(
"0.0.0.0/0",
)
def parse_cidr(cidr,isPass):
for line in cidr:
if isPass is True:
print "socks pass {"
else:
print "socks block {"
print "\tfrom: 0.0.0.0/0 to: "+line
print "}"
print ""
if __name__ == "__main__":
parse_cidr(TELEGRAM_PASS_CIDR,True)
parse_cidr(DEFAULT_BLOCK_CIDR,False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment