Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
epsylon
GitHub Repository: epsylon/ufonet
Path: blob/master/core/randomip.py
1207 views
1
#!/usr/bin/env python3
2
# -*- coding: utf-8 -*-"
3
"""
4
This file is part of the UFONet project, https://ufonet.03c8.net
5
6
Copyright (c) 2013/2020 | psy <[email protected]>
7
8
You should have received a copy of the GNU General Public License along
9
with UFONet; if not, write to the Free Software Foundation, Inc., 51
10
Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
11
"""
12
from random import randrange
13
14
class RandomIP(object):
15
"""
16
Class to generate random valid IP's
17
"""
18
def _generateip(self, string):
19
notvalid = [10, 127, 169, 172, 192]
20
first = randrange(1, 256)
21
while first is notvalid:
22
first = randrange(1, 256)
23
_ip = ".".join([str(first), str(randrange(1, 256)),
24
str(randrange(1, 256)), str(randrange(1, 256))])
25
return _ip
26
27