mirror of
https://github.com/house-of-vanity/Wireguard-Peer-Manager.git
synced 2025-07-06 09:14:07 +00:00
fix
This commit is contained in:
33
gen.py
33
gen.py
@ -26,21 +26,22 @@ my_parser.add_argument('--delete', action='store', type=str)
|
||||
my_parser.add_argument('--config', action='store', type=str)
|
||||
|
||||
## Reading config
|
||||
config = configparser.ConfigParser()
|
||||
config.read('wpm.conf')
|
||||
ips = config['Interface'].get('allowed_ips', '0.0.0.0/0')
|
||||
dns = config['Interface'].get('dns', '8.8.8.8/32')
|
||||
|
||||
|
||||
#ips = "0.0.0.0/5, 8.0.0.0/7, 10.150.200.0/24, 11.0.0.0/8, 12.0.0.0/6, 16.0.0.0/4, 32.0.0.0/3, 64.0.0.0/2, 128.0.0.0/3, 160.0.0.0/5, 168.0.0.0/6, 172.0.0.0/12, 172.32.0.0/11, 172.64.0.0/10, 172.128.0.0/9, 173.0.0.0/8, 174.0.0.0/7, 176.0.0.0/4, 192.0.0.0/9, 192.128.0.0/11, 192.160.0.0/13, 192.169.0.0/16, 192.170.0.0/15, 192.172.0.0/14, 192.176.0.0/12, 192.192.0.0/10, 193.0.0.0/8, 194.0.0.0/7, 196.0.0.0/6, 200.0.0.0/5, 208.0.0.0/4"
|
||||
|
||||
# Execute the parse_args() method
|
||||
args = my_parser.parse_args()
|
||||
peer_name = args.peer
|
||||
del_name = args.delete
|
||||
config = args.config if args.config else (config['Interface'].get('config', 'wg0'))
|
||||
log.info('Using %s WG config file.', config)
|
||||
is_update = args.update
|
||||
wpm_config = configparser.ConfigParser()
|
||||
wpm_config.read('wpm.conf')
|
||||
ips = wpm_config['Interface'].get('allowed_ips', '0.0.0.0/0')
|
||||
dns = wpm_config['Interface'].get('dns', '8.8.8.8/32')
|
||||
hostname = wpm_config['Interface'].get('hostname', getfqdn())
|
||||
config = args.config if args.config else (wpm_config['Interface'].get('config', 'wg0'))
|
||||
log.info('Using %s WG config file.', config)
|
||||
|
||||
|
||||
#ips = "0.0.0.0/5, 8.0.0.0/7, 10.150.200.0/24, 11.0.0.0/8, 12.0.0.0/6, 16.0.0.0/4, 32.0.0.0/3, 64.0.0.0/2, 128.0.0.0/3, 160.0.0.0/5, 168.0.0.0/6, 172.0.0.0/12, 172.32.0.0/11, 172.64.0.0/10, 172.128.0.0/9, 173.0.0.0/8, 174.0.0.0/7, 176.0.0.0/4, 192.0.0.0/9, 192.128.0.0/11, 192.160.0.0/13, 192.169.0.0/16, 192.170.0.0/15, 192.172.0.0/14, 192.176.0.0/12, 192.192.0.0/10, 193.0.0.0/8, 194.0.0.0/7, 196.0.0.0/6, 200.0.0.0/5, 208.0.0.0/4"
|
||||
|
||||
|
||||
|
||||
class Peer:
|
||||
@ -106,7 +107,7 @@ class Helper:
|
||||
self,
|
||||
cfg_path):
|
||||
self.cfg_path = cfg_path
|
||||
self.server_addr = self.hostname
|
||||
self.server_addr = hostname
|
||||
self.dns = dns
|
||||
self.wg = wgconfig.WGConfig(cfg_path)
|
||||
self.wg.read_file()
|
||||
@ -142,16 +143,6 @@ class Helper:
|
||||
ip_list.sort()
|
||||
return ip_list
|
||||
|
||||
@property
|
||||
def hostname(self):
|
||||
try:
|
||||
f = open('hostname', 'rb')
|
||||
hostname = f.read().decode('utf-8').strip()
|
||||
except OSError:
|
||||
hostname = getfqdn()
|
||||
|
||||
return hostname
|
||||
|
||||
@property
|
||||
def next_ip(self):
|
||||
"""Return next free IP"""
|
||||
|
@ -5,5 +5,8 @@ allowed_ips = 0.0.0.0/0
|
||||
## DNS for peer configs
|
||||
dns = 8.8.8.8
|
||||
|
||||
## server address if it deiffers form FQDN
|
||||
# hostname = vpn.example.com
|
||||
|
||||
## wg0 is default config.
|
||||
# config = wg0
|
||||
|
Reference in New Issue
Block a user