yumusb
2023-01-15 11:37:26 +08:00
def SetPing(self,get):
if get.status == '1':
get.status = '0'
else:
get.status = '1'
filename = '/etc/sysctl.conf'
conf = public.readFile(filename)
if conf.find('net.ipv4.icmp_echo') != -1:
rep = r"net\.ipv4\.icmp_echo.*"
conf = re.sub(rep,'net.ipv4.icmp_echo_ignore_all='+get.status,conf)
else:
conf += "\nnet.ipv4.icmp_echo_ignore_all="+get.status
if public.writeFile(filename,conf):
public.ExecShell('sysctl -p')
return public.return_msg_gettext(True,'Setup successfully!')
else:
return public.returnMsg(False,'Setup failed!')